本文整理汇总了PHP中permissions::get_perms方法的典型用法代码示例。如果您正苦于以下问题:PHP permissions::get_perms方法的具体用法?PHP permissions::get_perms怎么用?PHP permissions::get_perms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类permissions
的用法示例。
在下文中一共展示了permissions::get_perms方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute()
{
$perms_obj = new permissions();
$perms_obj->db =& $this->db;
$perms_obj->pre =& $this->pre;
if (isset($this->get['s']) && $this->get['s'] == 'user') {
if (!isset($this->get['id'])) {
header("Location: {$this->self}?a=member&s=perms");
}
$this->post['group'] = intval($this->get['id']);
$mode = 'user';
$title = 'User Control';
$link = '&s=user&id=' . $this->post['group'];
$perms_obj->get_perms(-1, $this->post['group']);
} else {
if (!isset($this->post['group'])) {
return $this->message('User Groups', "\n\t\t\t\t<form action='{$this->self}?a=perms' method='post'><div>\n\t\t\t\t\t{$this->lang->perms_edit_for}\n\t\t\t\t\t<select name='group'>\n\t\t\t\t\t" . $this->select_groups(-1) . "\n\t\t\t\t\t</select>\n\t\t\t\t\t<input type='submit' value='{$this->lang->submit}' /></div>\n\t\t\t\t</form>");
}
$this->post['group'] = intval($this->post['group']);
$mode = 'group';
$title = $this->lang->perms_title;
$link = null;
$perms_obj->get_perms($this->post['group'], -1);
}
$this->set_title($title);
$this->tree($title);
$forums_only = $this->db->query('SELECT forum_id, forum_name FROM ' . $this->pre . 'forums ORDER BY forum_name');
$forums_list = array();
while ($forum = $this->db->nqfetch($forums_only)) {
$forums_list[] = $forum;
}
$perms = array('board_view' => $this->lang->perms_board_view, 'board_view_closed' => $this->lang->perms_board_view_closed, 'do_anything' => $this->lang->perms_do_anything, 'is_admin' => $this->lang->perms_is_admin, 'email_use' => $this->lang->perms_email_use, 'topic_global' => $this->lang->perms_topic_global, 'pm_noflood' => $this->lang->perms_pm_noflood, 'search_noflood' => $this->lang->perms_search_noflood, 'forum_view' => $this->lang->perms_forum_view, 'post_viewip' => $this->lang->perms_post_viewip, 'topic_view' => $this->lang->perms_topic_view, 'poll_create' => $this->lang->perms_poll_create, 'poll_vote' => $this->lang->perms_poll_vote, 'post_create' => $this->lang->perms_post_create, 'topic_create' => $this->lang->perms_topic_create, 'post_noflood' => $this->lang->perms_post_noflood, 'post_delete' => $this->lang->perms_post_delete, 'post_delete_own' => $this->lang->perms_post_delete_own, 'topic_delete' => $this->lang->perms_topic_delete, 'topic_delete_own' => $this->lang->perms_topic_delete_own, 'post_edit' => $this->lang->perms_post_edit, 'post_edit_own' => $this->lang->perms_post_edit_own, 'topic_edit' => $this->lang->perms_topic_edit, 'topic_edit_own' => $this->lang->perms_topic_edit_own, 'topic_lock' => $this->lang->perms_topic_lock, 'topic_lock_own' => $this->lang->perms_topic_lock_own, 'topic_unlock' => $this->lang->perms_topic_unlock, 'topic_unlock_mod' => $this->lang->perms_topic_unlock_mod, 'topic_unlock_own' => $this->lang->perms_topic_unlock_own, 'topic_pin' => $this->lang->perms_topic_pin, 'topic_pin_own' => $this->lang->perms_topic_pin_own, 'topic_split' => $this->lang->perms_topic_split, 'topic_split_own' => $this->lang->perms_topic_split_own, 'topic_unpin' => $this->lang->perms_topic_unpin, 'topic_unpin_own' => $this->lang->perms_topic_unpin_own, 'topic_move' => $this->lang->perms_topic_move, 'topic_move_own' => $this->lang->perms_topic_move_own, 'post_attach' => $this->lang->perms_post_attach, 'post_attach_download' => $this->lang->perms_post_attach_download);
if (!isset($this->post['submit'])) {
$count = count($forums_list) + 1;
if ($mode == 'user') {
$query = $this->db->fetch("SELECT user_name, user_perms FROM {$this->pre}users WHERE user_id={$this->post['group']}");
$label = "User '{$query['user_name']}'";
} else {
$query = $this->db->fetch("SELECT group_name FROM {$this->pre}groups WHERE group_id={$this->post['group']}");
$label = "Group '{$query['group_name']}'";
}
$out = "\n\t\t\t<script type='text/javascript'>\n\t\t\t<!--\n\t\t\tfunction checkrow(element, check)\n\t\t\t{\n\t\t\t\tvar elements = document.forms['form'].elements;\n\t\t\t\tvar count = elements.length;\n\n\t\t\t\tfor (var i=0; i<count; i++) {\n\t\t\t\t\tvar current = elements[i];\n\t\t\t\t\tvar temp = current.name.split('[');\n\n\t\t\t\t\tif (!temp[1]) continue;\n\t\t\t\t\ttemp2 = temp[1].split(']');\n\n\t\t\t\t\tif (temp2[0] == element) {\n\t\t\t\t\t\tcurrent.checked = check;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction changeall(element, check)\n\t\t\t{\n\t\t\t\tif (!check) {\n\t\t\t\t\tcheckallbox(element, false);\n\t\t\t\t} else if (areallchecked(element)) {\n\t\t\t\t\tcheckallbox(element, true);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction checkallbox(element, check)\n\t\t\t{\n\t\t\t\tvar elements = document.forms['form'].elements;\n\t\t\t\tvar count = elements.length;\n\n\t\t\t\tvar allchecked = true;\n\n\t\t\t\tfor (var i=0; i<count; i++) {\n\t\t\t\t\tvar current = elements[i];\n\n\t\t\t\t\tif (current.name == ('perms[' + element + '][-1]')) {\n\t\t\t\t\t\tcurrent.checked = check;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction areallchecked(element)\n\t\t\t{\n\t\t\t\tvar elements = document.forms['form'].elements;\n\t\t\t\tvar count = elements.length;\n\n\t\t\t\tvar allchecked = true;\n\n\t\t\t\tfor (var i=0; i<count; i++) {\n\t\t\t\t\tvar current = elements[i];\n\n\t\t\t\t\tif (current.name == ('perms[' + element + '][-1]')) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar temp = current.name.split('[');\n\n\t\t\t\t\tif (!temp[1]) continue;\n\t\t\t\t\ttemp2 = temp[1].split(']');\n\n\t\t\t\t\tif (temp2[0] == element) {\n\t\t\t\t\t\tif (!current.checked) {\n\t\t\t\t\t\t\tallchecked = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn allchecked;\n\t\t\t}\n\t\t\t//-->\n\t\t\t</script>\n\n\t\t\t<form id='form' action='{$this->self}?a=perms{$link}' method='post'>\n\t\t\t<div align='center'><span style='font-size:14px;'><b>Permissions For {$label}</b></span>";
if ($mode == 'user') {
$out .= "<br />{$this->lang->perms_override_user}<br /><br />\n\t\t\t\t<div style='border:1px dashed #ff0000; width:25%; padding:5px'><input type='checkbox' name='usegroup' id='usegroup' style='vertical-align:middle'" . (!$query['user_perms'] ? ' checked' : '') . " /> <label for='usegroup' style='vertical-align:middle'>{$this->lang->perms_only_user}</label></div>";
}
$out .= "</div>" . $this->table . "\n\t\t\t<tr>\n\t\t\t\t<td colspan='" . ($count + 1) . "' class='header'>{$label}</td>\n\t\t\t</tr>";
$out .= $this->show_headers($forums_list);
$this->iterator_init('tablelight', 'tabledark');
$i = 0;
foreach ($perms as $perm => $label) {
$out .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='" . $this->iterate() . "'>{$label}</td>\n\t\t\t\t\t<td class='" . $this->lastValue() . "' align='center'>\n\t\t\t\t\t\t<input type='checkbox' name='perms[{$perm}][-1]' id='perms_{$perm}' onclick='checkrow(\"{$perm}\", this.checked)'" . ($perms_obj->auth($perm) ? ' checked=\'checked\'' : '') . " />All\n\t\t\t\t\t</td>";
if (!isset($perms_obj->globals[$perm])) {
foreach ($forums_list as $forum) {
if ($perms_obj->auth($perm, $forum['forum_id'])) {
$checked = " checked='checked'";
} else {
$checked = '';
}
$out .= "\n<td class='" . $this->lastValue() . "' align='center'><input type='checkbox' name='perms[{$perm}][{$forum['forum_id']}]' onclick='changeall(\"{$perm}\", this.checked)'{$checked} /></td>";
}
} elseif ($forums_list) {
$out .= "\n<td class='" . $this->lastValue() . "' colspan='{$count}' align='center'>N/A</td>";
}
$out .= "\n\t\t\t\t</tr>";
$i++;
if ($i % 12 == 0) {
$out .= $this->show_headers($forums_list);
}
}
return $out . "\n\t\t\t<tr>\n\t\t\t\t<td colspan='" . ($count + 1) . "' class='footer' align='center'><input type='hidden' name='group' value='{$this->post['group']}' /><input type='submit' name='submit' value='Update Permissions' /></td>\n\t\t\t</tr>" . $this->etable . "</form>";
} else {
if ($mode == 'user' && isset($this->post['usegroup'])) {
$perms_obj->cube = '';
$perms_obj->update();
return $this->message($this->lang->perms, $this->lang->perms_user_inherit);
}
$perms_obj->reset_cube(false);
if (!isset($this->post['perms'])) {
$this->post['perms'] = array();
}
foreach ($this->post['perms'] as $name => $data) {
if (isset($data[-1]) || isset($data['-1']) || count($data) == count($forums_list)) {
$perms_obj->set_xy($name, true);
} else {
foreach ($data as $forum => $on) {
$perms_obj->set_xyz($name, intval($forum), true);
}
}
}
$perms_obj->update();
return $this->message($this->lang->perms, $this->lang->perms_updated);
}
}
示例2: while
/**
* Delete subscriptions that have now been made
* illegal due to permissions change
*
* @param string $mode contains group or user
* @param integer $group group or user id
* @author Jonathan West <jon@quicksilverforums.com>
* @since 1.1.6
**/
function check_subscriptions($mode, $group)
{
if ($mode == 'user') {
$query = $this->db->query("SELECT s.subscription_user, s.subscription_item, s.subscription_type, u.user_id, u.user_group, u.user_perms\r\n\t\t\t\t\t\t\t\t\tFROM ({$this->pre}subscriptions s, {$this->pre}users u)\r\n\t\t\t\t\t\t\t\t\tWHERE s.subscription_user = {$group}\r\n\t\t\t\t\t\t\t\t\tAND s.subscription_user = u.user_id\r\n\t\t\t\t\t\t\t\t\t");
while ($sub = $this->db->nqfetch($query)) {
$perms = new permissions();
$perms->db =& $this->db;
$perms->pre =& $this->pre;
$perms->get_perms($sub['user_group'], $sub['user_id'], $sub['user_perms']);
if ($sub['subscription_type'] == 'forum') {
if (!$perms->auth('forum_view', $sub['subscription_item'])) {
//if user can no longer view forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
if (!$perms->auth('forum_subscribe', $sub['subscription_item'])) {
//if user can no longer subscribe to a forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
} else {
$check = $this->db->fetch("SELECT topic_forum FROM {$this->pre}topics WHERE topic_id={$sub['subscription_item']}");
if (!$perms->auth('forum_view', $check['topic_forum'])) {
//if user can no longer view forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
if (!$perms->auth('forum_subscribe', $check['topic_forum'])) {
//if user can no longer subscribe to a forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
}
}
} else {
//if a member of the group has subscriptions
$query = $this->db->query("SELECT s.subscription_user, s.subscription_item, s.subscription_type, u.user_id, u.user_group, g.group_perms\r\n\t\t\t\t\t\t\t\t\tFROM ({$this->pre}subscriptions s, {$this->pre}users u, {$this->pre}groups g)\r\n\t\t\t\t\t\t\t\t\tWHERE g.group_id = {$group}\r\n\t\t\t\t\t\t\t\t\tAND u.user_group = g.group_id\r\n\t\t\t\t\t\t\t\t\tAND s.subscription_user = u.user_id\r\n\t\t\t\t\t\t\t\t\t");
while ($sub = $this->db->nqfetch($query)) {
$perms = new permissions();
$perms->db =& $this->db;
$perms->pre =& $this->pre;
$perms->get_perms($sub['user_group'], $sub['user_id'], $sub['group_perms']);
if ($sub['subscription_type'] == 'forum') {
if (!$perms->auth('forum_view', $sub['subscription_item'])) {
//if user can no longer view forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
if (!$perms->auth('forum_subscribe', $sub['subscription_item'])) {
//if user can no longer subscribe to a forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
} else {
$check = $this->db->fetch("SELECT topic_forum FROM {$this->pre}topics WHERE topic_id={$sub['subscription_item']}");
if (!$perms->auth('forum_view', $check['topic_forum'])) {
//if user can no longer view forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
if (!$perms->auth('forum_subscribe', $check['topic_forum'])) {
//if user can no longer subscribe to a forum
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
}
}
}
}
示例3: while
/**
* Checks Subscriptions to make sure subscribed members can
* still view the forum where the topic has been moved too
*
* @param $newtopic integer of the selected topic
* @author Jonathan West <jon@quicksilverforums.com>
* @since 1.1.6
**/
function update_subscriptions($newtopic)
{
$query = $this->db->query("SELECT s.subscription_user, s.subscription_item, s.subscription_type,\r\n\t\t\t\t\t\t\t\t\tu.user_id, u.user_group, u.user_perms,\r\n\t\t\t\t\t\t\t\t\tg.group_id, g.group_perms,\r\n\t\t\t\t\t\t\t\t\tt.topic_forum\r\n\t\t\t\t\t\t\t\t\tFROM ({$this->pre}subscriptions s, {$this->pre}users u, {$this->pre}groups g, {$this->pre}topics t)\r\n\t\t\t\t\t\t\t\t\tWHERE s.subscription_user = u.user_id\r\n\t\t\t\t\t\t\t\t\tAND u.user_group = g.group_id\r\n\t\t\t\t\t\t\t\t\tAND t.topic_id = {$this->get['t']}\r\n\t\t\t\t\t\t\t\t\t");
while ($sub = $this->db->nqfetch($query)) {
$perms = new permissions();
$perms->db =& $this->db;
$perms->pre =& $this->pre;
$perms->get_perms($sub['user_group'], $sub['user_id'], $sub['user_perms'] ? $sub['user_perms'] : $sub['group_perms']);
if (!$perms->auth('forum_view', $sub['topic_forum'])) {
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
} else {
$this->db->query('UPDATE ' . $this->pre . 'subscriptions SET subscription_item=' . $newtopic . ' WHERE subscription_item=' . $this->get['t'] . " AND subscription_type='topic'");
}
if (!$perms->auth('forum_subscribe', $sub['topic_forum'])) {
$this->db->query("DELETE FROM {$this->pre}subscriptions WHERE subscription_user={$sub['user_id']} AND subscription_item={$sub['subscription_item']}");
}
}
}