index.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Module: Permission setting
00029  *
00030  * $Id: index.php 4569 2008-12-18 18:27:48Z dmitry $
00031  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
00032  * XHTML compliant
00033  *
00034  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00035  */
00036 /**
00037  * [CLASS/FUNCTION INDEX of SCRIPT]
00038  *
00039  *
00040  *
00041  *   90: class SC_mod_web_perm_index
00042  *  194:     public function init()
00043  *  246:     public function menuConfig()
00044  *  277:     public function main()
00045  *  344:     public function printContent()
00046  *  354:     private function getButtons()
00047  *
00048  *              SECTION: Listing and Form rendering
00049  *  398:     public function doEdit()
00050  *  545:     public function notEdit()
00051  *
00052  *              SECTION: Helper functions
00053  *  739:     public function printCheckBox($checkName, $num)
00054  *  752:     public function printPerms($int, $pageId = 0, $who = 'user')
00055  *  772:     public function groupPerms($row, $firstGroup)
00056  *  789:     public function getRecursiveSelect($id,$perms_clause)
00057  *
00058  * TOTAL FUNCTIONS: 11
00059  * (This index is automatically created/updated by the extension "extdeveval")
00060  *
00061  */
00062 
00063 unset($MCONF);
00064 require('conf.php');
00065 require($BACK_PATH.'init.php');
00066 require($BACK_PATH.'template.php');
00067 require('class.sc_mod_web_perm_ajax.php');
00068 $LANG->includeLLFile('EXT:lang/locallang_mod_web_perm.xml');
00069 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
00070 require_once (PATH_t3lib.'class.t3lib_page.php');
00071 require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
00072 
00073 $BE_USER->modAccess($MCONF,1);
00074 
00075 
00076 
00077 
00078 
00079 
00080 /**
00081  * Module: Permission setting
00082  *
00083  * Script Class for the Web > Access module
00084  * This module lets you view and change permissions for pages.
00085  *
00086  * Variables:
00087  * $this->MOD_SETTINGS['depth']: intval 1-3: decides the depth of the list
00088  * $this->MOD_SETTINGS['mode']: 'perms' / '': decides if we view a user-overview or the permissions.
00089  *
00090  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00091  * @author  Andreas Kundoch <typo3@mehrwert.de>
00092  * @package TYPO3
00093  * @subpackage  core
00094  * @version $Id: index.php 4569 2008-12-18 18:27:48Z dmitry $
00095  */
00096 class SC_mod_web_perm_index {
00097 
00098     /**
00099      * Number of levels to enable recursive settings for
00100      * @var integer
00101      */
00102     public $getLevels = 10;
00103 
00104     /**
00105      * Module config
00106      * Internal static
00107      * @var array
00108      */
00109     protected $MCONF = array();
00110 
00111     /**
00112      * Document Template Object
00113      * @var template
00114      */
00115     public $doc;
00116 
00117     /**
00118      * Content accumulation
00119      * @var string
00120      */
00121     public $content;
00122 
00123     /**
00124      * Module menu
00125      * @var array
00126      */
00127     public $MOD_MENU = array();
00128 
00129     /**
00130      * Module settings, cleansed.
00131      * @var aray
00132      */
00133     public $MOD_SETTINGS = array();
00134 
00135     /**
00136      * Page select permissions
00137      * @var string
00138      */
00139     public $perms_clause;
00140 
00141     /**
00142      * Current page record
00143      * @var array
00144      */
00145     public $pageinfo;
00146 
00147     /**
00148      *  Background color 1
00149      * @var string
00150      */
00151     public $color;
00152 
00153     /**
00154      * Background color 2
00155      * @var string
00156      */
00157     public $color2;
00158 
00159     /**
00160      * Background color 3
00161      * @var string
00162      */
00163     public $color3;
00164 
00165     /**
00166      * Set internally if the current user either OWNS the page OR is admin user!
00167      * @var boolean
00168      */
00169     public $editingAllowed;
00170 
00171     /**
00172      * Internal, static: GPvars: Page id.
00173      * @var integer
00174      */
00175     public $id;
00176 
00177     /**
00178      * If set, editing of the page permissions will occur (showing the editing screen). Notice:
00179      * This value is evaluated against permissions and so it will change internally!
00180      * @var boolean
00181      */
00182     public $edit;
00183 
00184     /**
00185      * ID to return to after editing.
00186      * @var integer
00187      */
00188     public $return_id;
00189 
00190     /**
00191      * Id of the page which was just edited.
00192      * @var integer
00193      */
00194     public $lastEdited;
00195 
00196     /**
00197      * Initialization of the class
00198      *
00199      * @return  void
00200      */
00201     public function init() {
00202 
00203             // Setting GPvars:
00204         $this->id = intval(t3lib_div::_GP('id'));
00205         $this->edit = t3lib_div::_GP('edit');
00206         $this->return_id = t3lib_div::_GP('return_id');
00207         $this->lastEdited = t3lib_div::_GP('lastEdited');
00208 
00209             // Module name;
00210         $this->MCONF = $GLOBALS['MCONF'];
00211 
00212             // Page select clause:
00213         $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
00214 
00215             // Initializing document template object:
00216         $this->doc = t3lib_div::makeInstance('template');
00217         $this->doc->backPath = $GLOBALS['BACK_PATH'];
00218         $this->doc->setModuleTemplate('templates/perm.html');
00219         $this->doc->form = '<form action="'.$GLOBALS['BACK_PATH'].'tce_db.php" method="post" name="editform">';
00220         $this->doc->loadJavascriptLib('../t3lib/jsfunc.updateform.js');
00221         $this->doc->loadJavascriptLib('contrib/prototype/prototype.js');
00222         $this->doc->loadJavascriptLib(TYPO3_MOD_PATH . 'perm.js');
00223 
00224             // Setting up the context sensitive menu:
00225         $this->doc->getContextMenuCode();
00226 
00227             // Set up menus:
00228         $this->menuConfig();
00229     }
00230 
00231     /**
00232      * Configuration of the menu and initialization of ->MOD_SETTINGS
00233      *
00234      * @return  void
00235      */
00236     public function menuConfig() {
00237         global $LANG;
00238 
00239             // MENU-ITEMS:
00240             // If array, then it's a selector box menu
00241             // If empty string it's just a variable, that'll be saved.
00242             // Values NOT in this array will not be saved in the settings-array for the module.
00243         $temp = $LANG->getLL('levels');
00244         $this->MOD_MENU = array(
00245             'depth' => array(
00246                 1 => '1 '.$temp,
00247                 2 => '2 '.$temp,
00248                 3 => '3 '.$temp,
00249                 4 => '4 '.$temp,
00250                 10 => '10 '.$temp
00251             ),
00252             'mode' => array(
00253                 0 => $LANG->getLL('user_overview'),
00254                 'perms' => $LANG->getLL('permissions')
00255             )
00256         );
00257 
00258             // Clean up settings:
00259         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00260     }
00261 
00262     /**
00263      * Main function, creating the content for the access editing forms/listings
00264      *
00265      * @return  void
00266      */
00267     public function main() {
00268         global $BE_USER, $LANG;
00269 
00270             // Access check...
00271             // The page will show only if there is a valid page and if this page may be viewed by the user
00272         $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
00273         $access = is_array($this->pageinfo);
00274 
00275             // Checking access:
00276         if (($this->id && $access) || ($BE_USER->isAdmin() && !$this->id)) {
00277             if ($BE_USER->isAdmin() && !$this->id)  {
00278                 $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0);
00279             }
00280 
00281                 // This decides if the editform can and will be drawn:
00282             $this->editingAllowed = ($this->pageinfo['perms_userid']==$BE_USER->user['uid'] || $BE_USER->isAdmin());
00283             $this->edit = $this->edit && $this->editingAllowed;
00284 
00285                 // If $this->edit then these functions are called in the end of the page...
00286             if ($this->edit)    {
00287                 $this->doc->postCode.= $this->doc->wrapScriptTags('
00288                     setCheck("check[perms_user]","data[pages]['.$this->id.'][perms_user]");
00289                     setCheck("check[perms_group]","data[pages]['.$this->id.'][perms_group]");
00290                     setCheck("check[perms_everybody]","data[pages]['.$this->id.'][perms_everybody]");
00291                 ');
00292             }
00293 
00294                 // Draw the HTML page header.
00295             $this->content.=$this->doc->header($LANG->getLL('permissions') . ($this->edit ? ': '.$LANG->getLL('Edit') : ''));
00296             $this->content.=$this->doc->spacer(5);
00297 
00298             $vContent = $this->doc->getVersionSelector($this->id,1);
00299             if ($vContent) {
00300                 $this->content .= $this->doc->section('',$vContent);
00301             }
00302 
00303                 // Main function, branching out:
00304             if (!$this->edit) {
00305                 $this->notEdit();
00306             } else {
00307                 $this->doEdit();
00308             }
00309 
00310             $docHeaderButtons = $this->getButtons();
00311 
00312             $markers['CSH'] = $this->docHeaderButtons['csh'];
00313             $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu($this->id, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']);
00314             $markers['CONTENT'] = $this->content;
00315 
00316                 // Build the <body> for the module
00317             $this->content = $this->doc->startPage($LANG->getLL('permissions'));
00318             $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00319         } else {
00320                 // If no access or if ID == zero
00321             $this->content.=$this->doc->startPage($LANG->getLL('permissions'));
00322             $this->content.=$this->doc->header($LANG->getLL('permissions'));
00323         }
00324         $this->content.= $this->doc->endPage();
00325     }
00326 
00327     /**
00328      * Outputting the accumulated content to screen
00329      *
00330      * @return  void
00331      */
00332     public function printContent() {
00333         $this->content = $this->doc->insertStylesAndJS($this->content);
00334         echo $this->content;
00335     }
00336 
00337     /**
00338      * Create the panel of buttons for submitting the form or otherwise perform operations.
00339      *
00340      * @return  array       all available buttons as an assoc. array
00341      */
00342     protected function getButtons() {
00343 
00344         $buttons = array(
00345             'csh' => '',
00346             'view' => '',
00347             'record_list' => '',
00348             'shortcut' => '',
00349         );
00350             // CSH
00351         $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_info', '', $GLOBALS['BACK_PATH'], '', TRUE);
00352 
00353             // View page
00354         $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewonclick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '">' .
00355                 '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '" hspace="3" alt="" />' .
00356                 '</a>';
00357 
00358             // Shortcut
00359         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00360             $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
00361         }
00362 
00363             // If access to Web>List for user, then link to that module.
00364         if ($GLOBALS['BE_USER']->check('modules','web_list'))   {
00365             $href = $GLOBALS['BACK_PATH'] . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
00366             $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '">' .
00367                     '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/list.gif') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', 1) . '" alt="" />' .
00368                     '</a>';
00369         }
00370         return $buttons;
00371     }
00372 
00373 
00374 
00375 
00376 
00377 
00378 
00379 
00380     /*****************************
00381      *
00382      * Listing and Form rendering
00383      *
00384      *****************************/
00385 
00386     /**
00387      * Creating form for editing the permissions    ($this->edit = true)
00388      * (Adding content to internal content variable)
00389      *
00390      * @return  void
00391      */
00392     public function doEdit() {
00393         global $BE_USER,$LANG;
00394 
00395         if ($BE_USER->workspace!=0) {
00396                 // Adding section with the permission setting matrix:
00397             $this->content.=$this->doc->divider(5);
00398             $this->content.=$this->doc->section($LANG->getLL('WorkspaceWarning'),'<div class="warningbox">'.$LANG->getLL('WorkspaceWarningText').'</div>',0,1,3);
00399         }
00400 
00401             // Get usernames and groupnames
00402         $beGroupArray = t3lib_BEfunc::getListGroupNames('title,uid');
00403         $beGroupKeys = array_keys($beGroupArray);
00404 
00405         $beUserArray = t3lib_BEfunc::getUserNames();
00406         if (!$GLOBALS['BE_USER']->isAdmin()) {
00407             $beUserArray = t3lib_BEfunc::blindUserNames($beUserArray,$beGroupKeys,1);
00408         }
00409         $beGroupArray_o = $beGroupArray = t3lib_BEfunc::getGroupNames();
00410         if (!$GLOBALS['BE_USER']->isAdmin()) {
00411             $beGroupArray = t3lib_BEfunc::blindGroupNames($beGroupArray_o,$beGroupKeys,1);
00412         }
00413         $firstGroup = $beGroupKeys[0] ? $beGroupArray[$beGroupKeys[0]] : '';    // data of the first group, the user is member of
00414 
00415 
00416             // Owner selector:
00417         $options='';
00418         $userset=0; // flag: is set if the page-userid equals one from the user-list
00419         foreach($beUserArray as $uid => $row)   {
00420             if ($uid==$this->pageinfo['perms_userid'])  {
00421                 $userset = 1;
00422                 $selected=' selected="selected"';
00423             } else {
00424                 $selected='';
00425             }
00426             $options.='
00427                 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['username']).'</option>';
00428         }
00429         $options='
00430                 <option value="0"></option>'.$options;
00431         $selector='
00432             <select name="data[pages]['.$this->id.'][perms_userid]">
00433                 '.$options.'
00434             </select>';
00435 
00436         $this->content.=$this->doc->section($LANG->getLL('Owner').':',$selector);
00437 
00438 
00439             // Group selector:
00440         $options='';
00441         $userset=0;
00442         foreach($beGroupArray as $uid => $row)  {
00443             if ($uid==$this->pageinfo['perms_groupid']) {
00444                 $userset = 1;
00445                 $selected=' selected="selected"';
00446             } else {
00447                 $selected='';
00448             }
00449             $options.='
00450                 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['title']).'</option>';
00451         }
00452         if (!$userset && $this->pageinfo['perms_groupid'])  {   // If the group was not set AND there is a group for the page
00453             $options='
00454                 <option value="'.$this->pageinfo['perms_groupid'].'" selected="selected">'.
00455                         htmlspecialchars($beGroupArray_o[$this->pageinfo['perms_groupid']]['title']).
00456                         '</option>'.
00457                         $options;
00458         }
00459         $options='
00460                 <option value="0"></option>'.$options;
00461         $selector='
00462             <select name="data[pages]['.$this->id.'][perms_groupid]">
00463                 '.$options.'
00464             </select>';
00465 
00466         $this->content.=$this->doc->divider(5);
00467         $this->content.=$this->doc->section($LANG->getLL('Group').':',$selector);
00468 
00469             // Permissions checkbox matrix:
00470         $code='
00471             <table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix">
00472                 <tr>
00473                     <td></td>
00474                     <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('1',1)).'</td>
00475                     <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('16',1)).'</td>
00476                     <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('2',1)).'</td>
00477                     <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('4',1)).'</td>
00478                     <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('8',1)).'</td>
00479                 </tr>
00480                 <tr>
00481                     <td align="right" class="bgColor2">'.$LANG->getLL('Owner',1).'</td>
00482                     <td class="bgColor-20">'.$this->printCheckBox('perms_user',1).'</td>
00483                     <td class="bgColor-20">'.$this->printCheckBox('perms_user',5).'</td>
00484                     <td class="bgColor-20">'.$this->printCheckBox('perms_user',2).'</td>
00485                     <td class="bgColor-20">'.$this->printCheckBox('perms_user',3).'</td>
00486                     <td class="bgColor-20">'.$this->printCheckBox('perms_user',4).'</td>
00487                 </tr>
00488                 <tr>
00489                     <td align="right" class="bgColor2">'.$LANG->getLL('Group',1).'</td>
00490                     <td class="bgColor-20">'.$this->printCheckBox('perms_group',1).'</td>
00491                     <td class="bgColor-20">'.$this->printCheckBox('perms_group',5).'</td>
00492                     <td class="bgColor-20">'.$this->printCheckBox('perms_group',2).'</td>
00493                     <td class="bgColor-20">'.$this->printCheckBox('perms_group',3).'</td>
00494                     <td class="bgColor-20">'.$this->printCheckBox('perms_group',4).'</td>
00495                 </tr>
00496                 <tr>
00497                     <td align="right" class="bgColor2">'.$LANG->getLL('Everybody',1).'</td>
00498                     <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',1).'</td>
00499                     <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',5).'</td>
00500                     <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',2).'</td>
00501                     <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',3).'</td>
00502                     <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',4).'</td>
00503                 </tr>
00504             </table>
00505             <br />
00506 
00507             <input type="hidden" name="data[pages]['.$this->id.'][perms_user]" value="'.$this->pageinfo['perms_user'].'" />
00508             <input type="hidden" name="data[pages]['.$this->id.'][perms_group]" value="'.$this->pageinfo['perms_group'].'" />
00509             <input type="hidden" name="data[pages]['.$this->id.'][perms_everybody]" value="'.$this->pageinfo['perms_everybody'].'" />
00510             '.$this->getRecursiveSelect($this->id,$this->perms_clause).'
00511             <input type="submit" name="submit" value="'.$LANG->getLL('Save',1).'" />'.
00512             '<input type="submit" value="'.$LANG->getLL('Abort',1).'" onclick="'.htmlspecialchars('jumpToUrl(\'index.php?id='.$this->id.'\'); return false;').'" />
00513             <input type="hidden" name="redirect" value="'.htmlspecialchars(TYPO3_MOD_PATH.'index.php?mode='.$this->MOD_SETTINGS['mode'].'&depth='.$this->MOD_SETTINGS['depth'].'&id='.intval($this->return_id).'&lastEdited='.$this->id).'" />
00514         ';
00515 
00516             // Adding section with the permission setting matrix:
00517         $this->content.=$this->doc->divider(5);
00518         $this->content.=$this->doc->section($LANG->getLL('permissions').':',$code);
00519 
00520             // CSH for permissions setting
00521         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'],'<br/><br/>');
00522 
00523             // Adding help text:
00524         if ($BE_USER->uc['helpText'])   {
00525             $this->content.=$this->doc->divider(20);
00526             $legendText = '<b>'.$LANG->getLL('1',1).'</b>: '.$LANG->getLL('1_t',1);
00527             $legendText.= '<br /><b>'.$LANG->getLL('16',1).'</b>: '.$LANG->getLL('16_t',1);
00528             $legendText.= '<br /><b>'.$LANG->getLL('2',1).'</b>: '.$LANG->getLL('2_t',1);
00529             $legendText.= '<br /><b>'.$LANG->getLL('4',1).'</b>: '.$LANG->getLL('4_t',1);
00530             $legendText.= '<br /><b>'.$LANG->getLL('8',1).'</b>: '.$LANG->getLL('8_t',1);
00531 
00532             $code=$legendText.'<br /><br />'.$LANG->getLL('def',1);
00533             $this->content.=$this->doc->section($LANG->getLL('Legend',1).':',$code);
00534         }
00535     }
00536 
00537     /**
00538      * Showing the permissions in a tree ($this->edit = false)
00539      * (Adding content to internal content variable)
00540      *
00541      * @return  void
00542      */
00543     public function notEdit() {
00544         global $BE_USER,$LANG,$BACK_PATH;
00545 
00546             // Get usernames and groupnames: The arrays we get in return contains only 1) users which are members of the groups of the current user, 2) groups that the current user is member of
00547         $beGroupKeys = $BE_USER->userGroupsUID;
00548         $beUserArray = t3lib_BEfunc::getUserNames();
00549         if (!$GLOBALS['BE_USER']->isAdmin()) {
00550             $beUserArray = t3lib_BEfunc::blindUserNames($beUserArray,$beGroupKeys,0);
00551         }
00552         $beGroupArray = t3lib_BEfunc::getGroupNames();
00553         if (!$GLOBALS['BE_USER']->isAdmin()) {
00554             $beGroupArray = t3lib_BEfunc::blindGroupNames($beGroupArray,$beGroupKeys,0);
00555         }
00556 
00557             // Length of strings:
00558         $tLen= ($this->MOD_SETTINGS['mode']=='perms' ? 20 : 30);
00559 
00560 
00561             // Selector for depth:
00562         $code.=$LANG->getLL('Depth').': ';
00563         $code.=t3lib_BEfunc::getFuncMenu($this->id,'SET[depth]',$this->MOD_SETTINGS['depth'],$this->MOD_MENU['depth']);
00564         $this->content.=$this->doc->section('',$code);
00565         $this->content.=$this->doc->spacer(5);
00566 
00567             // Initialize tree object:
00568         $tree = t3lib_div::makeInstance('t3lib_pageTree');
00569         $tree->init('AND '.$this->perms_clause);
00570 
00571         $tree->addField('perms_user',1);
00572         $tree->addField('perms_group',1);
00573         $tree->addField('perms_everybody',1);
00574         $tree->addField('perms_userid',1);
00575         $tree->addField('perms_groupid',1);
00576         $tree->addField('hidden');
00577         $tree->addField('fe_group');
00578         $tree->addField('starttime');
00579         $tree->addField('endtime');
00580         $tree->addField('editlock');
00581 
00582             // Creating top icon; the current page
00583         $HTML=t3lib_iconWorks::getIconImage('pages',$this->pageinfo,$BACK_PATH,'align="top"');
00584         $tree->tree[] = array('row'=>$this->pageinfo,'HTML'=>$HTML);
00585 
00586             // Create the tree from $this->id:
00587         $tree->getTree($this->id,$this->MOD_SETTINGS['depth'],'');
00588 
00589             // Make header of table:
00590         $code='';
00591         if ($this->MOD_SETTINGS['mode']=='perms') {
00592             $code.='
00593                 <tr>
00594                     <td class="bgColor2" colspan="2">&nbsp;</td>
00595                     <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00596                     <td class="bgColor2" align="center"><b>'.$LANG->getLL('Owner',1).'</b></td>
00597                     <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00598                     <td class="bgColor2" align="center"><b>'.$LANG->getLL('Group',1).'</b></td>
00599                     <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00600                     <td class="bgColor2" align="center"><b>'.$LANG->getLL('Everybody',1).'</b></td>
00601                     <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00602                     <td class="bgColor2" align="center"><b>'.$LANG->getLL('EditLock',1).'</b></td>
00603                 </tr>
00604             ';
00605         } else {
00606             $code.='
00607                 <tr>
00608                     <td class="bgColor2" colspan="2">&nbsp;</td>
00609                     <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00610                     <td class="bgColor2" align="center" nowrap="nowrap"><b>'.$LANG->getLL('User',1).':</b> '.$BE_USER->user['username'].'</td>
00611                     '.(!$BE_USER->isAdmin()?'<td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00612                     <td class="bgColor2" align="center"><b>'.$LANG->getLL('EditLock',1).'</b></td>':'').'
00613                 </tr>';
00614         }
00615 
00616             // Traverse tree:
00617         foreach ($tree->tree as $data) {
00618             $cells = array();
00619             $pageId = $data['row']['uid'];
00620 
00621                 // Background colors:
00622             $bgCol = ($this->lastEdited == $pageId ? ' class="bgColor-20"' : '');
00623             $lE_bgCol = $bgCol;
00624 
00625                 // User/Group names:
00626             $userName = $beUserArray[$data['row']['perms_userid']] ? $beUserArray[$data['row']['perms_userid']]['username'] : ($data['row']['perms_userid'] ?  $data['row']['perms_userid'] : '');
00627             if ($data['row']['perms_userid'] && (!$beUserArray[$data['row']['perms_userid']])) {
00628                 $userName = SC_mod_web_perm_ajax::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($userName, 20)), false);
00629             } else {
00630                 $userName = SC_mod_web_perm_ajax::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($userName, 20)));
00631             }
00632 
00633             $groupName = $beGroupArray[$data['row']['perms_groupid']] ? $beGroupArray[$data['row']['perms_groupid']]['title']  : ($data['row']['perms_groupid'] ?  $data['row']['perms_groupid']  : '');
00634             if ($data['row']['perms_groupid'] && (!$beGroupArray[$data['row']['perms_groupid']])) {
00635                 $groupName = SC_mod_web_perm_ajax::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($groupName, 20)), false);
00636             } else {
00637                 $groupName = SC_mod_web_perm_ajax::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($groupName, 20)));
00638             }
00639 
00640                 // Seeing if editing of permissions are allowed for that page:
00641             $editPermsAllowed = ($data['row']['perms_userid'] == $BE_USER->user['uid'] || $BE_USER->isAdmin());
00642 
00643 
00644                 // First column:
00645             $cellAttrib = ($data['row']['_CSSCLASS'] ? ' class="'.$data['row']['_CSSCLASS'].'"' : '');
00646             $cells[]='
00647                     <td align="left" nowrap="nowrap"'.($cellAttrib ? $cellAttrib : $bgCol).'>'.$data['HTML'].htmlspecialchars(t3lib_div::fixed_lgd($data['row']['title'],$tLen)).'&nbsp;</td>';
00648 
00649                 // "Edit permissions" -icon
00650             if ($editPermsAllowed && $pageId) {
00651                 $aHref = 'index.php?mode='.$this->MOD_SETTINGS['mode'].'&depth='.$this->MOD_SETTINGS['depth'].'&id='.($data['row']['_ORIG_uid'] ? $data['row']['_ORIG_uid'] : $pageId).'&return_id='.$this->id.'&edit=1';
00652                 $cells[]='
00653                     <td'.$bgCol.'><a href="'.htmlspecialchars($aHref).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/edit2.gif','width="11" height="12"').' border="0" title="'.$LANG->getLL('ch_permissions',1).'" align="top" alt="" /></a></td>';
00654             } else {
00655                 $cells[]='
00656                     <td'.$bgCol.'></td>';
00657             }
00658 
00659                 // Rest of columns (depending on mode)
00660             if ($this->MOD_SETTINGS['mode'] == 'perms') {
00661                 $cells[]='
00662                     <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00663                     <td'.$bgCol.' nowrap="nowrap">'.($pageId ? SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_user'], $pageId, 'user').' '.$userName : '').'</td>
00664 
00665                     <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00666                     <td'.$bgCol.' nowrap="nowrap">'.($pageId ? SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_group'], $pageId, 'group').' '.$groupName : '').'</td>
00667 
00668                     <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00669                     <td'.$bgCol.' nowrap="nowrap">'.($pageId ? ' '.SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_everybody'], $pageId, 'everybody') : '').'</td>
00670 
00671                     <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00672                     <td'.$bgCol.' nowrap="nowrap">'.($data['row']['editlock']?'<span id="el_'.$pageId.'" class="editlock"><a class="editlock" onclick="WebPermissions.toggleEditLock(\''.$pageId.'\', \'1\');"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/recordlock_warning2.gif','width="22" height="16"').' title="'.$LANG->getLL('EditLock_descr',1).'" alt="Edit Lock" /></a></span>' : ( $pageId === 0 ? '' : '<span id="el_'.$pageId.'" class="editlock"><a class="editlock" onclick="WebPermissions.toggleEditLock(\''.$pageId.'\', \'0\');" title="Enable the &raquo;Admin-only&laquo; edit lock for this page">[+]</a></span>')).'</td>
00673                 ';
00674             } else {
00675                 $cells[]='
00676                     <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>';
00677 
00678                 $bgCol = ($BE_USER->user['uid'] == $data['row']['perms_userid'] ? ' class="bgColor-20"' : $lE_bgCol);
00679 
00680                 // FIXME $owner undefined
00681                 $cells[]='
00682                     <td'.$bgCol.' nowrap="nowrap" align="center">'.($pageId ? $owner.SC_mod_web_perm_ajax::renderPermissions($BE_USER->calcPerms($data['row']), $pageId, 'user') : '').'</td>
00683                     '.(!$BE_USER->isAdmin()?'
00684                     <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00685                     <td'.$bgCol.' nowrap="nowrap">'.($data['row']['editlock']?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/recordlock_warning2.gif','width="22" height="16"').' title="'.$LANG->getLL('EditLock_descr',1).'" alt="" />' : '').'</td>
00686                     ':'');
00687                 $bgCol = $lE_bgCol;
00688             }
00689 
00690                 // Compile table row:
00691             $code .= '
00692                 <tr>
00693                     '.implode('
00694                     ',$cells).'
00695                 </tr>';
00696         }
00697 
00698             // Wrap rows in table tags:
00699         $code = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-permissionList" width="99.5%">'.$code.'</table>';
00700 
00701             // Adding the content as a section:
00702         $this->content.=$this->doc->section('',$code);
00703 
00704             // CSH for permissions setting
00705         $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module', $GLOBALS['BACK_PATH'],'<br/>|');
00706 
00707             // Creating legend table:
00708         $legendText = '<b>'.$LANG->getLL('1',1).'</b>: '.$LANG->getLL('1_t',1);
00709         $legendText.= '<br /><b>'.$LANG->getLL('16',1).'</b>: '.$LANG->getLL('16_t',1);
00710         $legendText.= '<br /><b>'.$LANG->getLL('2',1).'</b>: '.$LANG->getLL('2_t',1);
00711         $legendText.= '<br /><b>'.$LANG->getLL('4',1).'</b>: '.$LANG->getLL('4_t',1);
00712         $legendText.= '<br /><b>'.$LANG->getLL('8',1).'</b>: '.$LANG->getLL('8_t',1);
00713 
00714         $code='<table border="0" id="typo3-legendTable">
00715             <tr>
00716                 <td valign="top"><img src="legend.gif" width="86" height="75" alt="" /></td>
00717                 <td valign="top" nowrap="nowrap">'.$legendText.'</td>
00718             </tr>
00719         </table>';
00720         $code.='<div id="perm-legend">'.$LANG->getLL('def',1);
00721         $code.='<br /><br /><span class="perm-allowed">*</span>: '.$LANG->getLL('A_Granted', 1);
00722         $code.='<br /><span class="perm-denied">x</span>: '.$LANG->getLL('A_Denied', 1);
00723         $code.='</div>';
00724 
00725             // Adding section with legend code:
00726         $this->content.=$this->doc->spacer(20);
00727         $this->content.=$this->doc->section($LANG->getLL('Legend').':',$code,0,1);
00728     }
00729 
00730 
00731 
00732 
00733 
00734 
00735 
00736     /*****************************
00737      *
00738      * Helper functions
00739      *
00740      *****************************/
00741 
00742     /**
00743      * Print a checkbox for the edit-permission form
00744      *
00745      * @param   string      Checkbox name key
00746      * @param   integer     Checkbox number index
00747      * @return  string      HTML checkbox
00748      */
00749     public function printCheckBox($checkName, $num) {
00750         $onclick = 'checkChange(\'check['.$checkName.']\', \'data[pages]['.$GLOBALS['SOBE']->id.']['.$checkName.']\')';
00751         return '<input type="checkbox" name="check['.$checkName.']['.$num.']" onclick="'.htmlspecialchars($onclick).'" /><br />';
00752     }
00753 
00754 
00755     /**
00756      * Returns the permissions for a group based of the perms_groupid of $row. If the $row[perms_groupid] equals the $firstGroup[uid] then the function returns perms_everybody OR'ed with perms_group, else just perms_everybody
00757      *
00758      * @param   array       Row array (from pages table)
00759      * @param   array       First group data
00760      * @return  integer     Integer: Combined permissions.
00761      */
00762     public function groupPerms($row, $firstGroup) {
00763         if (is_array($row)) {
00764             $out = intval($row['perms_everybody']);
00765             if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
00766                 $out |= intval($row['perms_group']);
00767             }
00768             return $out;
00769         }
00770     }
00771 
00772     /**
00773      * Finding tree and offer setting of values recursively.
00774      *
00775      * @param   integer     Page id.
00776      * @param   string      Select clause
00777      * @return  string      Select form element for recursive levels (if any levels are found)
00778      */
00779     public function getRecursiveSelect($id,$perms_clause) {
00780 
00781             // Initialize tree object:
00782         $tree = t3lib_div::makeInstance('t3lib_pageTree');
00783         $tree->init('AND '.$perms_clause);
00784         $tree->addField('perms_userid',1);
00785         $tree->makeHTML=0;
00786         $tree->setRecs = 1;
00787 
00788             // Make tree:
00789         $tree->getTree($id,$this->getLevels,'');
00790 
00791             // If there are a hierarchy of page ids, then...
00792         if ($GLOBALS['BE_USER']->user['uid'] && count($tree->orig_ids_hierarchy)) {
00793 
00794                 // Init:
00795             $label_recur = $GLOBALS['LANG']->getLL('recursive');
00796             $label_levels = $GLOBALS['LANG']->getLL('levels');
00797             $label_pA = $GLOBALS['LANG']->getLL('pages_affected');
00798             $theIdListArr=array();
00799             $opts='
00800                         <option value=""></option>';
00801 
00802                 // Traverse the number of levels we want to allow recursive setting of permissions for:
00803             for ($a=$this->getLevels;$a>0;$a--) {
00804                 if (is_array($tree->orig_ids_hierarchy[$a]))    {
00805                     foreach($tree->orig_ids_hierarchy[$a] as $theId)    {
00806                         if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->user['uid']==$tree->recs[$theId]['perms_userid'])    {
00807                             $theIdListArr[]=$theId;
00808                         }
00809                     }
00810                     $lKey = $this->getLevels-$a+1;
00811                     $opts.='
00812                         <option value="'.htmlspecialchars(implode(',',$theIdListArr)).'">'.
00813                             t3lib_div::deHSCentities(htmlspecialchars($label_recur.' '.$lKey.' '.$label_levels)).' ('.count($theIdListArr).' '.$label_pA.')'.
00814                             '</option>';
00815                 }
00816             }
00817 
00818                 // Put the selector box together:
00819             $theRecursiveSelect = '<br />
00820                     <select name="mirror[pages]['.$id.']">
00821                         '.$opts.'
00822                     </select>
00823                 <br /><br />';
00824         } else {
00825             $theRecursiveSelect = '';
00826         }
00827 
00828             // Return selector box element:
00829         return $theRecursiveSelect;
00830     }
00831 }
00832 
00833 
00834 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php'])    {
00835     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php']);
00836 }
00837 
00838 
00839 
00840 
00841 // Make instance:
00842 $SOBE = t3lib_div::makeInstance('SC_mod_web_perm_index');
00843 $SOBE->init();
00844 $SOBE->main();
00845 $SOBE->printContent();
00846 
00847 ?>

Generated on Sat Jan 3 04:23:25 2009 for TYPO3 API by  doxygen 1.4.7