本文整理汇总了PHP中ACL::all_tokens方法的典型用法代码示例。如果您正苦于以下问题:PHP ACL::all_tokens方法的具体用法?PHP ACL::all_tokens怎么用?PHP ACL::all_tokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACL
的用法示例。
在下文中一共展示了ACL::all_tokens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_group
/**
* Handles POST requests to a group's page.
*/
public function post_group()
{
$group = UserGroup::get_by_id($this->handler_vars['id']);
$tokens = ACL::all_tokens();
if (isset($this->handler_vars['nonce'])) {
$wsse = Utils::WSSE($this->handler_vars['nonce'], $this->handler_vars['timestamp']);
if (isset($this->handler_vars['digest']) && $this->handler_vars['digest'] != $wsse['digest']) {
Session::error(_t('WSSE authentication failed.'));
}
if (isset($this->handler_vars['delete'])) {
$group->delete();
Utils::redirect(URL::get('admin', 'page=groups'));
}
if (isset($this->handler_vars['user'])) {
$users = $this->handler_vars['user'];
foreach ($users as $user => $status) {
if ($status == 1) {
$group->add($user);
} else {
$group->remove($user);
}
}
foreach ($tokens as $token) {
$bitmask = new Bitmask(ACL::$access_names);
if (isset($this->handler_vars['tokens'][$token->id]['deny'])) {
$bitmask->value = 0;
$group->deny($token->id);
} else {
foreach (ACL::$access_names as $name) {
if (isset($this->handler_vars['tokens'][$token->id][$name])) {
$bitmask->{$name} = true;
}
}
if (isset($this->handler_vars['tokens'][$token->id]['full'])) {
$bitmask->value = $bitmask->full;
}
if ($bitmask->value != 0) {
$group->grant($token->id, $bitmask);
} else {
$group->revoke($token->id);
}
}
}
}
}
Session::notice(_t('Updated permissions.'), 'permissions');
Utils::redirect(URL::get('admin', 'page=group') . '?id=' . $group->id);
}
示例2: populate_tokens_get
/**
* Get tokens created by this module.
* @param integer $num number of tokens to get, or all if not specified.
* @return array tokens found.
*/
private function populate_tokens_get($num = null)
{
// get all tokens
$alltokens = ACL::all_tokens();
// internal loop to get only our tokens.
$tokens = array();
$count = 0;
foreach ($alltokens as $id => $token) {
if (strpos($token->name, 'opulate_')) {
$tokens[] = $token;
if (isset($num) && $num == ++$count) {
break;
}
}
}
return $tokens;
}