本文整理汇总了PHP中CAccess::getUserCodesArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CAccess::getUserCodesArray方法的具体用法?PHP CAccess::getUserCodesArray怎么用?PHP CAccess::getUserCodesArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAccess
的用法示例。
在下文中一共展示了CAccess::getUserCodesArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canSkipMandatoryByRights
/**
* Check if current user not included to mandatory rights
*
* @return bool
*/
public function canSkipMandatoryByRights()
{
$targetRights = static::getMandatoryRights();
$access = new \CAccess();
$access->updateCodes(array('USER_ID' => $this->getUserId()));
$userRights = $access->getUserCodesArray($this->getUserId());
$existedRights = array_intersect($targetRights, $userRights);
$result = empty($existedRights);
return $result;
}
示例2: canSkipMandatoryByRights
/**
* Check if current user not included to mandatory rights
*
* @return bool
*/
public function canSkipMandatoryByRights()
{
$targetRights = static::getMandatoryRights();
$userRights = \CAccess::getUserCodesArray($this->getUserId());
$existedRights = array_intersect($targetRights, $userRights);
$result = empty($existedRights);
return $result;
}
示例3: canAccess
public function canAccess($userId, $codes)
{
$codes = is_array($codes) ? $codes : array($codes);
$isEmpty = true;
foreach ($codes as $code) {
if (trim($code) != '') {
$isEmpty = false;
break;
}
}
if ($isEmpty) {
$canAccess = false;
} else {
if ($this->getUser()->getId() == (int) $userId) {
$canAccess = $this->getUser()->canAccess($codes);
} else {
if (in_array('G2', $codes)) {
$canAccess = true;
} else {
$canAccess = array_intersect($codes, \CAccess::getUserCodesArray($userId));
}
}
}
return $canAccess;
}