32 public static function assign($itemName, $userId, $bizRule = null,
$data = null)
36 return $authorizer->authManager->assign($itemName, $userId, $bizRule,
$data);
47 public static function revoke($itemName, $userId)
51 return $authorizer->authManager->revoke($itemName, $userId);
65 $user = Yii::app()->getUser();
66 if ($userId === null && $user->isGuest ===
false) {
72 return $authorizer->getAuthItems(CAuthItem::TYPE_ROLE, $userId, null, $sort);
84 return Yii::app()->createUrl($module->baseUrl);
95 CAuthItem::TYPE_OPERATION =>
Rights::t(
'core',
'Operation'),
96 CAuthItem::TYPE_TASK =>
Rights::t(
'core',
'Task'),
97 CAuthItem::TYPE_ROLE =>
Rights::t(
'core',
'Role'),
111 if (isset($options[ $type ]) ===
true) {
112 return $options[ $type ];
114 throw new CException(
Rights::t(
'core',
'Invalid authorization item type.'));
127 switch ((
int) $type) {
128 case CAuthItem::TYPE_OPERATION:
return Rights::t(
'core',
'Operations');
129 case CAuthItem::TYPE_TASK:
return Rights::t(
'core',
'Tasks');
130 case CAuthItem::TYPE_ROLE:
return Rights::t(
'core',
'Roles');
131 default:
throw new CException(
Rights::t(
'core',
'Invalid authorization item type.'));
144 switch ((
int) $type) {
145 case CAuthItem::TYPE_OPERATION:
return array(
'authItem/operations');
146 case CAuthItem::TYPE_TASK:
return array(
'authItem/tasks');
147 case CAuthItem::TYPE_ROLE:
return array(
'authItem/roles');
148 default:
throw new CException(
Rights::t(
'core',
'Invalid authorization item type.'));
161 switch ((
int) $type) {
163 case CAuthItem::TYPE_ROLE:
return;
165 case CAuthItem::TYPE_TASK:
return array(CAuthItem::TYPE_TASK, CAuthItem::TYPE_OPERATION);
167 case CAuthItem::TYPE_OPERATION:
return array(CAuthItem::TYPE_OPERATION);
169 default:
throw new CException(
Rights::t(
'core',
'Invalid authorization item type.'));
185 $items = $authorizer->getAuthItems($type, null, null,
true, $exclude);
203 $items = $authorizer->getAuthItems($type, null, $parent,
true, $exclude);
218 $selectOptions = array();
221 if ($type !== (
int) $type) {
222 foreach ($items as $itemName => $item) {
228 foreach ($items as $itemName => $item) {
229 $selectOptions[ $itemName ] = $item->getNameText();
233 return $selectOptions;
245 return ($csrf = self::getCsrfParam()) !== null ?
', '.$csrf :
'';
256 if (Yii::app()->request->enableCsrfValidation ===
true) {
257 $csrfTokenName = Yii::app()->request->csrfTokenName;
258 $csrfToken = Yii::app()->request->csrfToken;
260 return "'$csrfTokenName':'$csrfToken'";
274 return 'Secured with <a href="http://www.yiiframework.com/extension/rights" rel="external">Rights</a> version '.$module->getVersion().
'.';
282 if (isset(self::$_m) ===
false) {
300 if ($module === null) {
301 $module = Yii::app();
304 if (($m = $module->getModule(
'rights')) !== null) {
308 foreach ($module->getModules() as $id => $c) {
309 if (($m = self::findModule($module->getModule($id))) !== null) {
322 if (isset(self::$_a) ===
false) {
341 public static function t($category, $message, $params = array(), $source = null, $language = null)
343 return Yii::t(
'RightsModule.'.$category, $message, $params, $source, $language);