You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					107 lines
				
				2.4 KiB
			
		
		
			
		
	
	
					107 lines
				
				2.4 KiB
			| 
											13 years ago
										 | <?php
 | ||
|  | /**
 | ||
|  |  * @link http://www.yiiframework.com/
 | ||
|  |  * @copyright Copyright (c) 2008 Yii Software LLC
 | ||
|  |  * @license http://www.yiiframework.com/license/
 | ||
|  |  */
 | ||
|  | 
 | ||
| 
											13 years ago
										 | namespace yii\rbac;
 | ||
| 
											13 years ago
										 | 
 | ||
|  | use Yii;
 | ||
|  | use yii\base\Object;
 | ||
|  | 
 | ||
|  | /**
 | ||
| 
											13 years ago
										 |  * Assignment represents an assignment of a role to a user.
 | ||
|  |  * It includes additional assignment information such as [[bizRule]] and [[data]].
 | ||
|  |  * Do not create a Assignment instance using the 'new' operator.
 | ||
| 
											13 years ago
										 |  * Instead, call [[Manager::assign()]].
 | ||
| 
											13 years ago
										 |  *
 | ||
|  |  * @property mixed $userId User ID (see [[User::id]]).
 | ||
|  |  * @property string $itemName The authorization item name.
 | ||
|  |  * @property string $bizRule The business rule associated with this assignment.
 | ||
|  |  * @property mixed $data Additional data for this assignment.
 | ||
| 
											13 years ago
										 |  *
 | ||
|  |  * @author Qiang Xue <qiang.xue@gmail.com>
 | ||
|  |  * @author Alexander Kochetov <creocoder@gmail.com>
 | ||
|  |  * @since 2.0
 | ||
|  |  */
 | ||
| 
											13 years ago
										 | class Assignment extends Object
 | ||
| 
											13 years ago
										 | {
 | ||
|  | 	private $_auth;
 | ||
|  | 	private $_userId;
 | ||
| 
											13 years ago
										 | 	private $_itemName;
 | ||
| 
											13 years ago
										 | 	private $_bizRule;
 | ||
|  | 	private $_data;
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * Constructor.
 | ||
| 
											13 years ago
										 | 	 * @param Manager $auth the authorization manager
 | ||
| 
											13 years ago
										 | 	 * @param mixed $userId user ID (see [[User::id]])
 | ||
| 
											13 years ago
										 | 	 * @param string $itemName authorization item name
 | ||
| 
											13 years ago
										 | 	 * @param string $bizRule the business rule associated with this assignment
 | ||
|  | 	 * @param mixed $data additional data for this assignment
 | ||
|  | 	 */
 | ||
| 
											13 years ago
										 | 	public function __construct($auth, $userId, $itemName, $bizRule = null, $data = null)
 | ||
| 
											13 years ago
										 | 	{
 | ||
|  | 		$this->_auth = $auth;
 | ||
|  | 		$this->_userId = $userId;
 | ||
| 
											13 years ago
										 | 		$this->_itemName = $itemName;
 | ||
| 
											13 years ago
										 | 		$this->_bizRule = $bizRule;
 | ||
|  | 		$this->_data = $data;
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * @return mixed user ID (see [[User::id]])
 | ||
|  | 	 */
 | ||
|  | 	public function getUserId()
 | ||
|  | 	{
 | ||
|  | 		return $this->_userId;
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * @return string the authorization item name
 | ||
|  | 	 */
 | ||
|  | 	public function getItemName()
 | ||
|  | 	{
 | ||
|  | 		return $this->_itemName;
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * @return string the business rule associated with this assignment
 | ||
|  | 	 */
 | ||
|  | 	public function getBizRule()
 | ||
|  | 	{
 | ||
|  | 		return $this->_bizRule;
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * @param string $value the business rule associated with this assignment
 | ||
|  | 	 */
 | ||
|  | 	public function setBizRule($value)
 | ||
|  | 	{
 | ||
|  | 		if ($this->_bizRule !== $value) {
 | ||
|  | 			$this->_bizRule = $value;
 | ||
| 
											13 years ago
										 | 			$this->_auth->saveAssignment($this);
 | ||
| 
											13 years ago
										 | 		}
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * @return mixed additional data for this assignment
 | ||
|  | 	 */
 | ||
|  | 	public function getData()
 | ||
|  | 	{
 | ||
|  | 		return $this->_data;
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
|  | 	 * @param mixed $value additional data for this assignment
 | ||
|  | 	 */
 | ||
|  | 	public function setData($value)
 | ||
|  | 	{
 | ||
|  | 		if ($this->_data !== $value) {
 | ||
|  | 			$this->_data = $value;
 | ||
| 
											13 years ago
										 | 			$this->_auth->saveAssignment($this);
 | ||
| 
											13 years ago
										 | 		}
 | ||
|  | 	}
 | ||
|  | }
 |