Пример #1
0
 /**
  * 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
0
 /**
  * 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
0
 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;
 }