/** * 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; }
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 { $access = new \CAccess(); $access->updateCodes(array("USER_ID" => $userId)); $canAccess = array_intersect($codes, \CAccess::getUserCodesArray($userId)); } } } return $canAccess; }