CAuthAssignment.php
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* CAuthAssignment class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
/**
* CAuthAssignment represents an assignment of a role to a user.
* It includes additional assignment information such as {@link bizRule} and {@link data}.
* Do not create a CAuthAssignment instance using the 'new' operator.
* Instead, call {@link IAuthManager::assign}.
*
* @property mixed $userId User ID (see {@link IWebUser::getId}).
* @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.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.web.auth
* @since 1.0
*/
class CAuthAssignment extends CComponent
{
private $_auth;
private $_itemName;
private $_userId;
private $_bizRule;
private $_data;
/**
* Constructor.
* @param IAuthManager $auth the authorization manager
* @param string $itemName authorization item name
* @param mixed $userId user ID (see {@link IWebUser::getId})
* @param string $bizRule the business rule associated with this assignment
* @param mixed $data additional data for this assignment
*/
public function __construct($auth,$itemName,$userId,$bizRule=null,$data=null)
{
$this->_auth=$auth;
$this->_itemName=$itemName;
$this->_userId=$userId;
$this->_bizRule=$bizRule;
$this->_data=$data;
}
/**
* @return mixed user ID (see {@link IWebUser::getId})
*/
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;
$this->_auth->saveAuthAssignment($this);
}
}
/**
* @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;
$this->_auth->saveAuthAssignment($this);
}
}
}