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