admin_permissions.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 370 行 · 第 1/2 页
PHP
370 行
<?php
// $Id: admin_permissions.php,v 1.1.1.1 2005/10/19 15:58:12 phppp Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: XOOPS Foundation //
// URL: http://www.xoops.org/ //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
include 'admin_header.php';
include_once XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/class/xoopsformloader.php";
include_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php';
/**
* Add category navigation to forum casscade structure
* <ol>Special points:
* <li> Use negative values for category IDs to avoid conflict between category and forum
* <li> Disabled checkbox for categories to avoid unnecessary permission items for categories in forum permission table
* </ol>
*
* Note: this is a __patchy__ solution. We should have a more extensible and flexible group permission management: not only for data architecture but also for management interface
*/
class newbb_XoopsGroupPermForm extends XoopsGroupPermForm
{
function newbb_XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url = "")
{
$this->XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url);
}
function render()
{
// load all child ids for javascript codes
foreach (array_keys($this->_itemTree)as $item_id) {
$this->_itemTree[$item_id]['allchild'] = array();
$this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']);
}
$gperm_handler =& xoops_gethandler('groupperm');
$member_handler =& xoops_gethandler('member');
$glist =& $member_handler->getGroupList();
foreach (array_keys($glist) as $i) {
// get selected item id(s) for each group
$selected = $gperm_handler->getItemIds($this->_permName, $i, $this->_modid);
$ele = new newbb_XoopsGroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected);
$ele->setOptionTree($this->_itemTree);
$this->addElement($ele);
unset($ele);
}
$tray = new XoopsFormElementTray('');
$tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
$tray->addElement(new XoopsFormButton('', 'reset', _CANCEL, 'reset'));
$this->addElement($tray);
$ret = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br />';
$ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n";
$elements =& $this->getElements();
$hidden = '';
foreach (array_keys($elements) as $i) {
if (!is_object($elements[$i])) {
$ret .= $elements[$i];
} elseif (!$elements[$i]->isHidden()) {
$ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption();
if ($elements[$i]->getDescription() != '') {
$ret .= '<br /><br /><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>';
}
$ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n";
} else {
$hidden .= $elements[$i]->render();
}
}
$ret .= "</table>$hidden</form>";
$ret .= $this->renderValidationJS( true );
return $ret;
}
}
class newbb_XoopsGroupFormCheckBox extends XoopsGroupFormCheckBox
{
function newbb_XoopsGroupFormCheckBox($caption, $name, $groupId, $values = null)
{
$this->XoopsGroupFormCheckBox($caption, $name, $groupId, $values);
}
/**
* Renders checkbox options for this group
*
* @return string
* @access public
*/
function render()
{
$ret = '<table class="outer"><tr><td class="odd"><table><tr>';
$cols = 1;
foreach ($this->_optionTree[0]['children'] as $topitem) {
if ($cols > 4) {
$ret .= '</tr><tr>';
$cols = 1;
}
$tree = '<td valign="top">';
$prefix = '';
$this->_renderOptionTree($tree, $this->_optionTree[$topitem], $prefix);
$ret .= $tree.'</td>';
$cols++;
}
$ret .= '</tr></table></td><td class="even">';
foreach (array_keys($this->_optionTree) as $id) {
if (!empty($id)) {
$option_ids[] = "'".$this->getName().'[groups]['.$this->_groupId.']['.$id.']'."'";
}
}
$checkallbtn_id = $this->getName().'[checkallbtn]['.$this->_groupId.']';
$option_ids_str = implode(', ', $option_ids);
$ret .= _ALL." <input id=\"".$checkallbtn_id."\" type=\"checkbox\" value=\"\" onclick=\"var optionids = new Array(".$option_ids_str."); xoopsCheckAllElements(optionids, '".$checkallbtn_id."');\" />";
$ret .= '</td></tr></table>';
return $ret;
}
function _renderOptionTree(&$tree, $option, $prefix, $parentIds = array())
{
if($option['id'] > 0):
$tree .= $prefix . "<input type=\"checkbox\" name=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" id=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" onclick=\"";
foreach ($parentIds as $pid) {
if($pid <= 0) continue;
$parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']';
$tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if(ele.checked != true) {ele.checked = this.checked;}";
}
foreach ($option['allchild'] as $cid) {
$child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']';
$tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if(this.checked != true) {ele.checked = false;}";
}
$tree .= '" value="1"';
if (in_array($option['id'], $this->_value)) {
$tree .= ' checked="checked"';
}
$tree .= " />" . $option['name'] . "<input type=\"hidden\" name=\"" . $this->getName() . "[parents][" . $option['id'] . "]\" value=\"" . implode(':', $parentIds). "\" /><input type=\"hidden\" name=\"" . $this->getName() . "[itemname][" . $option['id'] . "]\" value=\"" . htmlspecialchars($option['name']). "\" /><br />\n";
else:
$tree .= $prefix . $option['name'] . "<input type=\"hidden\" id=\"" . $this->getName() . "[groups][" . $this->_groupId . "][" . $option['id'] . "]\" /><br />\n";
endif;
if (isset($option['children'])) {
foreach ($option['children'] as $child) {
if($option['id'] > 0){
array_push($parentIds, $option['id']);
}
$this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds);
}
}
}
}
xoops_cp_header();
loadModuleAdminMenu(3);
$action = isset($_REQUEST['action']) ? strtolower($_REQUEST['action']) : "";
$module_id = $xoopsModule->getVar('mid');
$perms = array_map("trim",explode(',', FORUM_PERM_ITEMS));
switch($action){
case "template":
$opform = new XoopsSimpleForm(_AM_NEWBB_PERM_ACTION, 'actionform', 'admin_permissions.php', "get");
$op_select = new XoopsFormSelect("", 'action');
$op_select->setExtra('onchange="document.forms.actionform.submit()"');
$op_select->addOptionArray(array(
"no"=>_SELECT,
"template"=>_AM_NEWBB_PERM_TEMPLATE,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?