本文整理匯總了PHP中UserGroup::id方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserGroup::id方法的具體用法?PHP UserGroup::id怎麽用?PHP UserGroup::id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserGroup
的用法示例。
在下文中一共展示了UserGroup::id方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_id
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: in_group
/**
* 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: get_group_token_access
/**
* 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;
}