📄 index.php
字号:
<?php/**************************************************************** Copyright notice** (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)* All rights reserved** This script is part of the TYPO3 project. The TYPO3 project 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.** The GNU General Public License can be found at* http://www.gnu.org/copyleft/gpl.html.* A copy is found in the textfile GPL.txt and important notices to the license* from the author is found in LICENSE.txt distributed with these scripts.*** This script 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.** This copyright notice MUST APPEAR in all copies of the script!***************************************************************//** * Module: Permission setting * * $Id: index.php 2155 2007-02-27 13:23:42Z masi $ * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj * XHTML compliant * * @author Kasper Skaarhoj <kasperYYYY@typo3.com> *//** * [CLASS/FUNCTION INDEX of SCRIPT] * * * * 89: class SC_mod_web_perm_index * 123: function init() * 183: function menuConfig() * 214: function main() * 288: function printContent() * * SECTION: Listing and Form rendering * 315: function doEdit() * 452: function notEdit() * * SECTION: Helper functions * 647: function printCheckBox($checkName,$num) * 658: function printPerms($int) * 676: function groupPerms($row,$firstGroup) * 693: function getRecursiveSelect($id,$perms_clause) * * TOTAL FUNCTIONS: 10 * (This index is automatically created/updated by the extension "extdeveval") * */unset($MCONF);require('conf.php');require($BACK_PATH.'init.php');require($BACK_PATH.'template.php');$LANG->includeLLFile('EXT:lang/locallang_mod_web_perm.xml');require_once (PATH_t3lib.'class.t3lib_pagetree.php');require_once (PATH_t3lib.'class.t3lib_page.php');$BE_USER->modAccess($MCONF,1);/** * Script Class for the Web > Access module * This module lets you view and change permissions for pages. * * variables: * $this->depth : intval 1-3: decides the depth of the list * $this->mode : 'perms' / '': decides if we view a user-overview or the permissions. * * @author Kasper Skaarhoj <kasperYYYY@typo3.com> * @package TYPO3 * @subpackage core */class SC_mod_web_perm_index { // External, static: var $getLevels = 10; // Number of levels to enable recursive settings for // Internal, static: var $MCONF=array(); // Module config var $doc; // Document template object var $content; // Content accumulation var $MOD_MENU=array(); // Module menu var $MOD_SETTINGS=array(); // Module settings, cleansed. var $perms_clause; // Page select permissions var $pageinfo; // Current page record var $color; // Background color 1 var $color2; // Background color 2 var $color3; // Background color 3 var $editingAllowed; // Set internally if the current user either OWNS the page OR is admin user! // Internal, static: GPvars: var $id; // Page id. var $edit; // If set, editing of the page permissions will occur (showing the editing screen). Notice: This value is evaluated against permissions and so it will change internally! var $return_id; // ID to return to after editing. var $lastEdited; // Id of the page which was just edited. /** * Initialization of the class * * @return void */ function init() { global $BE_USER,$BACK_PATH; // Setting GPvars: $this->id = intval(t3lib_div::_GP('id')); $this->edit = t3lib_div::_GP('edit'); $this->return_id = t3lib_div::_GP('return_id'); $this->lastEdited = t3lib_div::_GP('lastEdited'); // Module name; $this->MCONF = $GLOBALS['MCONF']; // Page select clause: $this->perms_clause = $BE_USER->getPagePermsClause(1); // Initializing document template object: $this->doc = t3lib_div::makeInstance('mediumDoc'); $this->doc->backPath = $BACK_PATH; $this->doc->docType = 'xhtml_trans'; $this->doc->form='<form action="'.$BACK_PATH.'tce_db.php" method="post" name="editform">'; $this->doc->JScode = '<script type="text/javascript" src="'.$BACK_PATH.'../t3lib/jsfunc.updateform.js"></script>'; $this->doc->JScode.= $this->doc->wrapScriptTags(' function checkChange(checknames, varname) { // var res = 0; for (var a=1; a<=5; a++) { if (document.editform[checknames+"["+a+"]"].checked) { res|=Math.pow(2,a-1); } } document.editform[varname].value = res | (checknames=="check[perms_user]"?1:0) ; setCheck (checknames,varname); } function setCheck(checknames, varname) { // if (document.editform[varname]) { var res = document.editform[varname].value; for (var a=1; a<=5; a++) { document.editform[checknames+"["+a+"]"].checked = (res & Math.pow(2,a-1)); } } } function jumpToUrl(URL) { // window.location.href = URL; } '); // Setting up the context sensitive menu: $CMparts=$this->doc->getContextMenuCode(); $this->doc->bodyTagAdditions = $CMparts[1]; $this->doc->JScode.=$CMparts[0]; $this->doc->postCode.= $CMparts[2]; // Set up menus: $this->menuConfig(); } /** * Configuration of the menu and initialization of ->MOD_SETTINGS * * @return void */ function menuConfig() { global $LANG; // MENU-ITEMS: // If array, then it's a selector box menu // If empty string it's just a variable, that'll be saved. // Values NOT in this array will not be saved in the settings-array for the module. $temp = $LANG->getLL('levels'); $this->MOD_MENU = array( 'depth' => array( 1 => '1 '.$temp, 2 => '2 '.$temp, 3 => '3 '.$temp, 4 => '4 '.$temp, 10 => '10 '.$temp ), 'mode' => array( 0 => $LANG->getLL('user_overview'), 'perms' => $LANG->getLL('permissions') ) ); // Clean up settings: $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']); } /** * Main function, creating the content for the access editing forms/listings * * @return void */ function main() { global $BE_USER,$LANG; // Access check... // The page will show only if there is a valid page and if this page may be viewed by the user $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause); $access = is_array($this->pageinfo) ? 1 : 0; // Checking access: if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id)) { if ($BE_USER->user['admin'] && !$this->id) { $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0); } // This decides if the editform can and will be drawn: $this->editingAllowed = ($this->pageinfo['perms_userid']==$BE_USER->user['uid'] || $BE_USER->isAdmin()); $this->edit = $this->edit && $this->editingAllowed; // If $this->edit then these functions are called in the end of the page... if ($this->edit) { $this->doc->postCode.= $this->doc->wrapScriptTags(' setCheck("check[perms_user]","data[pages]['.$this->id.'][perms_user]"); setCheck("check[perms_group]","data[pages]['.$this->id.'][perms_group]"); setCheck("check[perms_everybody]","data[pages]['.$this->id.'][perms_everybody]"); '); } // Draw the HTML page header. $this->content.=$this->doc->startPage($LANG->getLL('permissions')); $this->content.=$this->doc->header($LANG->getLL('permissions').($this->edit?': '.$LANG->getLL('Edit'):'')); $this->content.=$this->doc->spacer(5); $this->content.=$this->doc->section('', $this->doc->funcMenu( $this->doc->getHeader('pages',$this->pageinfo,htmlspecialchars($this->pageinfo['_thePath'])).'<br />'. $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '. '<span title="'.htmlspecialchars($this->pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-50)).'</span>', t3lib_BEfunc::getFuncMenu($this->id,'SET[mode]',$this->MOD_SETTINGS['mode'],$this->MOD_MENU['mode']) )); $this->content.=$this->doc->divider(5); $vContent = $this->doc->getVersionSelector($this->id,1); if ($vContent) { $this->content.=$this->doc->section('',$vContent); } // Main function, branching out: if (!$this->edit) { $this->notEdit(); } else { $this->doEdit(); } // ShortCut if ($BE_USER->mayMakeShortcut()) { $this->content.= $this->doc->spacer(20). $this->doc->section('',$this->doc->makeShortcutIcon('id,edit,return_id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'])); } } else { // If no access or if ID == zero $this->content.=$this->doc->startPage($LANG->getLL('permissions')); $this->content.=$this->doc->header($LANG->getLL('permissions')); } } /** * Outputting the accumulated content to screen * * @return void */ function printContent() { $this->content.= $this->doc->endPage(); $this->content = $this->doc->insertStylesAndJS($this->content); echo $this->content; } /***************************** * * Listing and Form rendering * *****************************/ /** * Creating form for editing the permissions ($this->edit = true) * (Adding content to internal content variable) * * @return void */ function doEdit() { global $BE_USER,$LANG; // Get usernames and groupnames $be_group_Array=t3lib_BEfunc::getListGroupNames('title,uid'); $groupArray=array_keys($be_group_Array); $be_user_Array = t3lib_BEfunc::getUserNames(); if (!$GLOBALS['BE_USER']->isAdmin()) $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,1); $be_group_Array_o = $be_group_Array = t3lib_BEfunc::getGroupNames(); if (!$GLOBALS['BE_USER']->isAdmin()) $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o,$groupArray,1); $firstGroup = $groupArray[0] ? $be_group_Array[$groupArray[0]] : ''; // data of the first group, the user is member of // Owner selector: $options=''; $userset=0; // flag: is set if the page-userid equals one from the user-list foreach($be_user_Array as $uid => $row) { if ($uid==$this->pageinfo['perms_userid']) { $userset = 1; $selected=' selected="selected"'; } else {$selected='';} $options.=' <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['username']).'</option>'; } $options=' <option value="0"></option>'.$options; $selector=' <select name="data[pages]['.$this->id.'][perms_userid]"> '.$options.' </select>'; $this->content.=$this->doc->section($LANG->getLL('Owner').':',$selector); // Group selector: $options=''; $userset=0; foreach($be_group_Array as $uid => $row) { if ($uid==$this->pageinfo['perms_groupid']) { $userset = 1; $selected=' selected="selected"'; } else {$selected='';} $options.=' <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['title']).'</option>'; } if (!$userset && $this->pageinfo['perms_groupid']) { // If the group was not set AND there is a group for the page $options=' <option value="'.$this->pageinfo['perms_groupid'].'" selected="selected">'. htmlspecialchars($be_group_Array_o[$this->pageinfo['perms_groupid']]['title']). '</option>'. $options; } $options=' <option value="0"></option>'.$options; $selector=' <select name="data[pages]['.$this->id.'][perms_groupid]"> '.$options.' </select>'; $this->content.=$this->doc->divider(5); $this->content.=$this->doc->section($LANG->getLL('Group').':',$selector); // Permissions checkbox matrix: $code=' <table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix"> <tr> <td></td> <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('1',1)).'</td> <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('16',1)).'</td> <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('2',1)).'</td> <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('4',1)).'</td> <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('8',1)).'</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -