Example #1
0
 /**
  * Returns an array with overlapping context IDs -- useful for when
  * contexts are used with regular expressions
  *
  * @param string $uri Context
  * @param string $cabin Cabin
  * @return array
  */
 public function getContextIds(string $uri = '', string $cabin = \CABIN_NAME) : array
 {
     if (empty($uri)) {
         $uri = AutoPilot::$path;
     }
     $ctx = $this->db->col(\Airship\queryStringRoot('security.permissions.get_overlap', $this->db->getDriver()), 0, $cabin, $uri);
     if (empty($ctx)) {
         return [];
     }
     return $ctx;
 }
Example #2
0
 /**
  * Is this user a super user? Do they belong in a superuser group?
  * 
  * @param int $user_id - User ID
  * @param bool $ignore_groups - Don't look at their groups
  * @return bool
  */
 public function isSuperUser(int $user_id = 0, bool $ignore_groups = false) : bool
 {
     if (empty($user_id)) {
         // We can short-circuit this for guests...
         return false;
     }
     $statements = ['check_user' => \Airship\queryStringRoot('security.permissions.is_superuser_user', $this->db->getDriver()), 'check_groups' => \Airship\queryStringRoot('security.permissions.is_superuser_group', $this->db->getDriver())];
     if ($this->db->cell($statements['check_user'], $user_id) > 0) {
         return true;
     } elseif (!$ignore_groups) {
         return $this->db->cell($statements['check_groups'], $user_id) > 0;
     }
     return false;
 }