public function gatekeeper($ability = null) {
    if (!isset($ability)) {
      return self::current(true)->is($this);
    }
    // Check the cache to see if we've already checked this user.
    if ($this->gatekeeperCache) {
      $abilities =& $this->gatekeeperCache;
    } else {
      $abilities = $this->abilities;
      if ($this->inheritAbilities) {
        foreach ($this->groups as &$curGroup) {
          if (!isset($curGroup->guid)) {
            continue;
          }
          $abilities = array_merge($abilities, $curGroup->abilities);
        }
        unset($curGroup);
        if (isset($this->group) && isset($this->group->guid)) {
          $abilities = array_merge($abilities, $this->group->abilities);
        }
      }
      $this->gatekeeperCache = $abilities;
    }
    if (!is_array($abilities)) {
      return false;
    }
    return (
      in_array($ability, $abilities) || in_array('system/admin', $abilities)
    );
  }
public function gatekeeper($ability = null) {
    if (!isset($ability)) {
      return self::current(true)->is($this);
    }
    // Check the cache to see if we've already checked this user.
    if ($this->gatekeeperCache) {
      $abilities =& $this->gatekeeperCache;
    } else {
      $abilities = $this->abilities;
      if ($this->inheritAbilities) {
        foreach ($this->groups as &$curGroup) {
          if (!isset($curGroup->guid)) {
            continue;
          }
          $abilities = array_merge($abilities, $curGroup->abilities);
        }
        unset($curGroup);
        if (isset($this->group) && isset($this->group->guid)) {
          $abilities = array_merge($abilities, $this->group->abilities);
        }
      }
      $this->gatekeeperCache = $abilities;
    }
    if (!is_array($abilities)) {
      return false;
    }
    return (
      in_array($ability, $abilities) || in_array('system/admin', $abilities)
    );
  }
public function gatekeeper ( $ ability = null ) { if ( ! isset ( $ ability ) ) { return self :: current ( true ) -> is ( $ this ) ; } // Check the cache to see if we've already checked this user. if ( $ this -> gatekeeperCache ) { $ abilities = & $ this -> gatekeeperCache ; } else { $ abilities = $ this -> abilities ; if ( $ this -> inheritAbilities ) { foreach ( $ this -> groups as & $ curGroup ) { if ( ! isset ( $ curGroup -> guid ) ) { continue ; } $ abilities = array_merge ( $ abilities , $ curGroup -> abilities ) ; } unset ( $ curGroup ) ; if ( isset ( $ this -> group ) && isset ( $ this -> group -> guid ) ) { $ abilities = array_merge ( $ abilities , $ this -> group -> abilities ) ; } } $ this -> gatekeeperCache = $ abilities ; } if ( ! is_array ( $ abilities ) ) { return false ; } return ( in_array ( $ ability , $ abilities ) || in_array ( 'system/admin' , $ abilities ) ) ; }
Check to see if a user has an ability.

This function will check both user and group abilities, if the user is
marked to inherit the abilities of its group.

If $ability is null, it will check to see if the user is currently logged
in.

If the user has the "system/admin" ability, this function will return true.

@param string $ability The ability.
@return bool True or false.
Check to see if a user has an ability .