<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BackendAuthManager
 *
 * @author yzxh24
 */
class BackendAuthorManager extends CDbAuthManager
{
    /**
	 * Initializes the application component.
	 * This method overrides the parent implementation by establishing the database connection.
	 */
	public function init()
	{
		parent::init();
	}

    public function getAssignUser($itemName)
    {
        $sql="SELECT * FROM {$this->assignmentTable} WHERE itemname=:itemname";
		$command=$this->db->createCommand($sql);
		$command->bindValue(':itemname',$itemName);
		$assignments=array();
		foreach($command->queryAll($sql) as $row)
        {
			$assignments[]=$row['userid'];
        }
        
		return $assignments;

    }

    public function setAssignUser($itemName,$userIds)
    {
        if(!isset($userIds))
        {
            return;
        }
        if(!is_array($userIds))
        {
            parent::assign($itemName, $userIds);
        }
        else
        {
            foreach($userIds as $userId)
            {
                parent::assign($itemName, $userId);
            }
        }
    }
}
