Пример #1
0
 public function test_id()
 {
     $group = UserGroup::get("new test group");
     $this->assert_equal(UserGroup::id("new test group"), $group->id, 'Cannot retrieve "new test group" by name.');
     $this->assert_equal(UserGroup::id($group->id), $group->id, 'Cannot retrieve "new test group" by ID.');
     $this->assert_false(UserGroup::id("nonexistent test group"), 'Retrieved an ID for an invalid group name.');
     $this->assert_false(UserGroup::id(-1), 'Retrieved a ID for an invalid group ID.');
 }
Пример #2
0
 /**
  * function in_group
  * Whether or not this user is is in the specified group
  * @param int $group a group ID or name
  * @return bool Whether or not this user is in the specified group
  **/
 public function in_group($group)
 {
     $groups = $this->list_groups();
     return in_array(UserGroup::id($group), $groups);
 }
Пример #3
0
    /**
     * Get the access bitmask of a group for a specific permission token
     * @param integer $group The group ID
     * @param mixed $token_id A permission name or ID
     * @return an access bitmask
     */
    public static function get_group_token_access($group, $token_id)
    {
        // Use only numeric ids internally
        $group = UserGroup::id($group);
        $token_id = self::token_id($token_id);
        $sql = 'SELECT access_mask FROM {group_token_permissions} WHERE
			group_id=? AND token_id=?;';
        $result = DB::get_value($sql, array($group, $token_id));
        if (isset($result)) {
            return self::get_bitmask($result);
        }
        return null;
    }