/src/typo3_src-4.2.0alpha1/typo3/mod/web/perm/index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 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 ***************************************************************/
00062 unset($MCONF);
00063 require('conf.php');
00064 require($BACK_PATH.'init.php');
00065 require($BACK_PATH.'template.php');
00066 $LANG->includeLLFile('EXT:lang/locallang_mod_web_perm.xml');
00067 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
00068 require_once (PATH_t3lib.'class.t3lib_page.php');
00069 
00070 $BE_USER->modAccess($MCONF,1);
00071 
00072 
00073 
00074 
00075 
00076 
00089 class SC_mod_web_perm_index {
00090 
00091                 // External, static:
00092         var $getLevels = 10;                    // Number of levels to enable recursive settings for
00093 
00094                 // Internal, static:
00095         var $MCONF=array();                     // Module config
00096 
00102         var $doc;
00103         var $content;                           // Content accumulation
00104 
00105         var $MOD_MENU=array();          // Module menu
00106         var $MOD_SETTINGS=array();      // Module settings, cleansed.
00107 
00108         var $perms_clause;                      // Page select permissions
00109         var $pageinfo;                          // Current page record
00110 
00111         var $color;                                     // Background color 1
00112         var $color2;                            // Background color 2
00113         var $color3;                            // Background color 3
00114 
00115         var $editingAllowed;            // Set internally if the current user either OWNS the page OR is admin user!
00116 
00117                 // Internal, static: GPvars:
00118         var $id;                                        // Page id.
00119         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!
00120         var $return_id;                         // ID to return to after editing.
00121         var $lastEdited;                        // Id of the page which was just edited.
00122 
00123 
00129         function init() {
00130                 global $BE_USER,$BACK_PATH;
00131 
00132                         // Setting GPvars:
00133                 $this->id = intval(t3lib_div::_GP('id'));
00134                 $this->edit = t3lib_div::_GP('edit');
00135                 $this->return_id = t3lib_div::_GP('return_id');
00136                 $this->lastEdited = t3lib_div::_GP('lastEdited');
00137 
00138                         // Module name;
00139                 $this->MCONF = $GLOBALS['MCONF'];
00140 
00141                         // Page select clause:
00142                 $this->perms_clause = $BE_USER->getPagePermsClause(1);
00143 
00144                         // Initializing document template object:
00145                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00146                 $this->doc->backPath = $BACK_PATH;
00147                 $this->doc->docType = 'xhtml_trans';
00148                 $this->doc->form='<form action="'.$BACK_PATH.'tce_db.php" method="post" name="editform">';
00149                 $this->doc->JScode = '<script type="text/javascript" src="'.$BACK_PATH.'../t3lib/jsfunc.updateform.js"></script>';
00150                 $this->doc->JScode.= $this->doc->wrapScriptTags('
00151                         function checkChange(checknames, varname)       {       //
00152                                 var res = 0;
00153                                 for (var a=1; a<=5; a++)        {
00154                                         if (document.editform[checknames+"["+a+"]"].checked)    {
00155                                                 res|=Math.pow(2,a-1);
00156                                         }
00157                                 }
00158                                 document.editform[varname].value = res | (checknames=="check[perms_user]"?1:0) ;
00159                                 setCheck (checknames,varname);
00160                         }
00161                         function setCheck(checknames, varname)  {       //
00162                                 if (document.editform[varname]) {
00163                                         var res = document.editform[varname].value;
00164                                         for (var a=1; a<=5; a++)        {
00165                                                 document.editform[checknames+"["+a+"]"].checked = (res & Math.pow(2,a-1));
00166                                         }
00167                                 }
00168                         }
00169                         function jumpToUrl(URL) {       //
00170                                 window.location.href = URL;
00171                         }
00172                 ');
00173 
00174                         // Setting up the context sensitive menu:
00175                 $CMparts=$this->doc->getContextMenuCode();
00176                 $this->doc->bodyTagAdditions = $CMparts[1];
00177                 $this->doc->JScode.=$CMparts[0];
00178                 $this->doc->postCode.= $CMparts[2];
00179 
00180                         // Set up menus:
00181                 $this->menuConfig();
00182         }
00183 
00189         function menuConfig()   {
00190                 global $LANG;
00191 
00192                         // MENU-ITEMS:
00193                         // If array, then it's a selector box menu
00194                         // If empty string it's just a variable, that'll be saved.
00195                         // Values NOT in this array will not be saved in the settings-array for the module.
00196                 $temp = $LANG->getLL('levels');
00197                 $this->MOD_MENU = array(
00198                         'depth' => array(
00199                                 1 => '1 '.$temp,
00200                                 2 => '2 '.$temp,
00201                                 3 => '3 '.$temp,
00202                                 4 => '4 '.$temp,
00203                                 10 => '10 '.$temp
00204                         ),
00205                         'mode' => array(
00206                                 0 => $LANG->getLL('user_overview'),
00207                                 'perms' => $LANG->getLL('permissions')
00208                         )
00209                 );
00210 
00211                         // Clean up settings:
00212                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00213         }
00214 
00220         function main() {
00221                 global $BE_USER,$LANG;
00222 
00223                         // Access check...
00224                         // The page will show only if there is a valid page and if this page may be viewed by the user
00225                 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00226                 $access = is_array($this->pageinfo) ? 1 : 0;
00227 
00228                         // Checking access:
00229                 if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id))  {
00230                         if ($BE_USER->user['admin'] && !$this->id)      {
00231                                 $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0);
00232                         }
00233 
00234                                 // This decides if the editform can and will be drawn:
00235                         $this->editingAllowed = ($this->pageinfo['perms_userid']==$BE_USER->user['uid'] || $BE_USER->isAdmin());
00236                         $this->edit = $this->edit && $this->editingAllowed;
00237 
00238                                 // If $this->edit then these functions are called in the end of the page...
00239                         if ($this->edit)        {
00240                                 $this->doc->postCode.= $this->doc->wrapScriptTags('
00241                                         setCheck("check[perms_user]","data[pages]['.$this->id.'][perms_user]");
00242                                         setCheck("check[perms_group]","data[pages]['.$this->id.'][perms_group]");
00243                                         setCheck("check[perms_everybody]","data[pages]['.$this->id.'][perms_everybody]");
00244                                 ');
00245                         }
00246 
00247                                 // Draw the HTML page header.
00248                         $this->content.=$this->doc->startPage($LANG->getLL('permissions'));
00249                         $this->content.=$this->doc->header($LANG->getLL('permissions').($this->edit?': '.$LANG->getLL('Edit'):''));
00250                         $this->content.=$this->doc->spacer(5);
00251                         $this->content.=$this->doc->section('',
00252                                 $this->doc->funcMenu(
00253                                         $this->doc->getHeader('pages',$this->pageinfo,htmlspecialchars($this->pageinfo['_thePath'])).'<br />'.
00254                                                 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.
00255                                                 '<span title="'.htmlspecialchars($this->pageinfo['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-50)).'</span>',
00256                                         t3lib_BEfunc::getFuncMenu($this->id,'SET[mode]',$this->MOD_SETTINGS['mode'],$this->MOD_MENU['mode'])
00257                                 ));
00258                         $this->content.=$this->doc->divider(5);
00259 
00260 
00261 
00262                         $vContent = $this->doc->getVersionSelector($this->id,1);
00263                         if ($vContent)  {
00264                                 $this->content.=$this->doc->section('',$vContent);
00265                         }
00266 
00267 
00268 
00269                                 // Main function, branching out:
00270                         if (!$this->edit)       {
00271                                 $this->notEdit();
00272                         } else {
00273                                 $this->doEdit();
00274                         }
00275 
00276                                 // ShortCut
00277                         if ($BE_USER->mayMakeShortcut())        {
00278                                 $this->content.=
00279                                         $this->doc->spacer(20).
00280                                         $this->doc->section('',$this->doc->makeShortcutIcon('id,edit,return_id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
00281                         }
00282                 } else {
00283                                 // If no access or if ID == zero
00284                         $this->content.=$this->doc->startPage($LANG->getLL('permissions'));
00285                         $this->content.=$this->doc->header($LANG->getLL('permissions'));
00286                 }
00287         }
00288 
00294         function printContent() {
00295                 $this->content.= $this->doc->endPage();
00296                 $this->content = $this->doc->insertStylesAndJS($this->content);
00297                 echo $this->content;
00298         }
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306 
00307 
00308 
00309         /*****************************
00310          *
00311          * Listing and Form rendering
00312          *
00313          *****************************/
00314 
00321         function doEdit()       {
00322                 global $BE_USER,$LANG;
00323 
00324                         // Get usernames and groupnames
00325                 $be_group_Array=t3lib_BEfunc::getListGroupNames('title,uid');
00326                 $groupArray=array_keys($be_group_Array);
00327 
00328                 $be_user_Array = t3lib_BEfunc::getUserNames();
00329                 if (!$GLOBALS['BE_USER']->isAdmin())            $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,1);
00330                 $be_group_Array_o = $be_group_Array = t3lib_BEfunc::getGroupNames();
00331                 if (!$GLOBALS['BE_USER']->isAdmin())            $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o,$groupArray,1);
00332                 $firstGroup = $groupArray[0] ? $be_group_Array[$groupArray[0]] : '';    // data of the first group, the user is member of
00333 
00334 
00335                         // Owner selector:
00336                 $options='';
00337                 $userset=0;     // flag: is set if the page-userid equals one from the user-list
00338                 foreach($be_user_Array as $uid => $row) {
00339                         if ($uid==$this->pageinfo['perms_userid'])      {
00340                                 $userset = 1;
00341                                 $selected=' selected="selected"';
00342                         } else {$selected='';}
00343                         $options.='
00344                                 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['username']).'</option>';
00345                 }
00346                 $options='
00347                                 <option value="0"></option>'.$options;
00348                 $selector='
00349                         <select name="data[pages]['.$this->id.'][perms_userid]">
00350                                 '.$options.'
00351                         </select>';
00352 
00353                 $this->content.=$this->doc->section($LANG->getLL('Owner').':',$selector);
00354 
00355 
00356                         // Group selector:
00357                 $options='';
00358                 $userset=0;
00359                 foreach($be_group_Array as $uid => $row)        {
00360                         if ($uid==$this->pageinfo['perms_groupid'])     {
00361                                 $userset = 1;
00362                                 $selected=' selected="selected"';
00363                         } else {$selected='';}
00364                         $options.='
00365                                 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['title']).'</option>';
00366                 }
00367                 if (!$userset && $this->pageinfo['perms_groupid'])      {       // If the group was not set AND there is a group for the page
00368                         $options='
00369                                 <option value="'.$this->pageinfo['perms_groupid'].'" selected="selected">'.
00370                                                 htmlspecialchars($be_group_Array_o[$this->pageinfo['perms_groupid']]['title']).
00371                                                 '</option>'.
00372                                                 $options;
00373                 }
00374                 $options='
00375                                 <option value="0"></option>'.$options;
00376                 $selector='
00377                         <select name="data[pages]['.$this->id.'][perms_groupid]">
00378                                 '.$options.'
00379                         </select>';
00380 
00381                 $this->content.=$this->doc->divider(5);
00382                 $this->content.=$this->doc->section($LANG->getLL('Group').':',$selector);
00383 
00384                         // Permissions checkbox matrix:
00385                 $code='
00386                         <table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix">
00387                                 <tr>
00388                                         <td></td>
00389                                         <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('1',1)).'</td>
00390                                         <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('16',1)).'</td>
00391                                         <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('2',1)).'</td>
00392                                         <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('4',1)).'</td>
00393                                         <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('8',1)).'</td>
00394                                 </tr>
00395                                 <tr>
00396                                         <td align="right" class="bgColor2">'.$LANG->getLL('Owner',1).'</td>
00397                                         <td class="bgColor-20">'.$this->printCheckBox('perms_user',1).'</td>
00398                                         <td class="bgColor-20">'.$this->printCheckBox('perms_user',5).'</td>
00399                                         <td class="bgColor-20">'.$this->printCheckBox('perms_user',2).'</td>
00400                                         <td class="bgColor-20">'.$this->printCheckBox('perms_user',3).'</td>
00401                                         <td class="bgColor-20">'.$this->printCheckBox('perms_user',4).'</td>
00402                                 </tr>
00403                                 <tr>
00404                                         <td align="right" class="bgColor2">'.$LANG->getLL('Group',1).'</td>
00405                                         <td class="bgColor-20">'.$this->printCheckBox('perms_group',1).'</td>
00406                                         <td class="bgColor-20">'.$this->printCheckBox('perms_group',5).'</td>
00407                                         <td class="bgColor-20">'.$this->printCheckBox('perms_group',2).'</td>
00408                                         <td class="bgColor-20">'.$this->printCheckBox('perms_group',3).'</td>
00409                                         <td class="bgColor-20">'.$this->printCheckBox('perms_group',4).'</td>
00410                                 </tr>
00411                                 <tr>
00412                                         <td align="right" class="bgColor2">'.$LANG->getLL('Everybody',1).'</td>
00413                                         <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',1).'</td>
00414                                         <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',5).'</td>
00415                                         <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',2).'</td>
00416                                         <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',3).'</td>
00417                                         <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',4).'</td>
00418                                 </tr>
00419                         </table>
00420                         <br />
00421 
00422                         <input type="hidden" name="data[pages]['.$this->id.'][perms_user]" value="'.$this->pageinfo['perms_user'].'" />
00423                         <input type="hidden" name="data[pages]['.$this->id.'][perms_group]" value="'.$this->pageinfo['perms_group'].'" />
00424                         <input type="hidden" name="data[pages]['.$this->id.'][perms_everybody]" value="'.$this->pageinfo['perms_everybody'].'" />
00425                         '.$this->getRecursiveSelect($this->id,$this->perms_clause).'
00426                         <input type="submit" name="submit" value="'.$LANG->getLL('Save',1).'" />'.
00427                         '<input type="submit" value="'.$LANG->getLL('Abort',1).'" onclick="'.htmlspecialchars('jumpToUrl(\'index.php?id='.$this->id.'\'); return false;').'" />
00428                         <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).'" />
00429                 ';
00430 
00431                         // Adding section with the permission setting matrix:
00432                 $this->content.=$this->doc->divider(5);
00433                 $this->content.=$this->doc->section($LANG->getLL('permissions').':',$code);
00434 
00435                         // CSH for permissions setting
00436                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'],'<br/><br/>');
00437 
00438                         // Adding help text:
00439                 if ($BE_USER->uc['helpText'])   {
00440                         $this->content.=$this->doc->divider(20);
00441                         $legendText = '<b>'.$LANG->getLL('1',1).'</b>: '.$LANG->getLL('1_t',1);
00442                         $legendText.= '<br /><b>'.$LANG->getLL('16',1).'</b>: '.$LANG->getLL('16_t',1);
00443                         $legendText.= '<br /><b>'.$LANG->getLL('2',1).'</b>: '.$LANG->getLL('2_t',1);
00444                         $legendText.= '<br /><b>'.$LANG->getLL('4',1).'</b>: '.$LANG->getLL('4_t',1);
00445                         $legendText.= '<br /><b>'.$LANG->getLL('8',1).'</b>: '.$LANG->getLL('8_t',1);
00446 
00447                         $code=$legendText.'<br /><br />'.$LANG->getLL('def',1);
00448                         $this->content.=$this->doc->section($LANG->getLL('Legend',1).':',$code);
00449                 }
00450         }
00451 
00458         function notEdit()      {
00459                 global $BE_USER,$LANG,$BACK_PATH;
00460 
00461                         // 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
00462                 $groupArray = $BE_USER->userGroupsUID;
00463                 $be_user_Array = t3lib_BEfunc::getUserNames();
00464                 if (!$GLOBALS['BE_USER']->isAdmin())            $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,0);
00465                 $be_group_Array = t3lib_BEfunc::getGroupNames();
00466                 if (!$GLOBALS['BE_USER']->isAdmin())            $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array,$groupArray,0);
00467 
00468                         // Length of strings:
00469                 $tLen= ($this->MOD_SETTINGS['mode']=='perms' ? 20 : 30);
00470 
00471 
00472                         // Selector for depth:
00473                 $code.=$LANG->getLL('Depth').': ';
00474                 $code.=t3lib_BEfunc::getFuncMenu($this->id,'SET[depth]',$this->MOD_SETTINGS['depth'],$this->MOD_MENU['depth']);
00475                 $this->content.=$this->doc->section('',$code);
00476                 $this->content.=$this->doc->spacer(5);
00477 
00478                         // Initialize tree object:
00479                 $tree = t3lib_div::makeInstance('t3lib_pageTree');
00480                 $tree->init('AND '.$this->perms_clause);
00481 
00482                 $tree->addField('perms_user',1);
00483                 $tree->addField('perms_group',1);
00484                 $tree->addField('perms_everybody',1);
00485                 $tree->addField('perms_userid',1);
00486                 $tree->addField('perms_groupid',1);
00487                 $tree->addField('hidden');
00488                 $tree->addField('fe_group');
00489                 $tree->addField('starttime');
00490                 $tree->addField('endtime');
00491                 $tree->addField('editlock');
00492 
00493                         // Creating top icon; the current page
00494                 $HTML=t3lib_iconWorks::getIconImage('pages',$this->pageinfo,$BACK_PATH,'align="top"');
00495                 $tree->tree[]=Array('row'=>$this->pageinfo,'HTML'=>$HTML);
00496 
00497                         // Create the tree from $this->id:
00498                 $tree->getTree($this->id,$this->MOD_SETTINGS['depth'],'');
00499 
00500                         // Make header of table:
00501                 $code='';
00502                 if ($this->MOD_SETTINGS['mode']=='perms')       {
00503                         $code.='
00504                                 <tr>
00505                                         <td class="bgColor2" colspan="2">&nbsp;</td>
00506                                         <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00507                                         <td class="bgColor2" align="center"><b>'.$LANG->getLL('Owner',1).'</b></td>
00508                                         <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00509                                         <td class="bgColor2" align="center"><b>'.$LANG->getLL('Group',1).'</b></td>
00510                                         <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00511                                         <td class="bgColor2" align="center"><b>'.$LANG->getLL('Everybody',1).'</b></td>
00512                                         <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00513                                         <td class="bgColor2" align="center"><b>'.$LANG->getLL('EditLock',1).'</b></td>
00514                                 </tr>
00515                         ';
00516                 } else {
00517                         $code.='
00518                                 <tr>
00519                                         <td class="bgColor2" colspan="2">&nbsp;</td>
00520                                         <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00521                                         <td class="bgColor2" align="center" nowrap="nowrap"><b>'.$LANG->getLL('User',1).':</b> '.$BE_USER->user['username'].'</td>
00522                                         '.(!$BE_USER->isAdmin()?'<td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00523                                         <td class="bgColor2" align="center"><b>'.$LANG->getLL('EditLock',1).'</b></td>':'').'
00524                                 </tr>';
00525                 }
00526 
00527                         // Traverse tree:
00528                 foreach($tree->tree as $data)   {
00529                         $cells = array();
00530 
00531                                 // Background colors:
00532                         if ($this->lastEdited==$data['row']['uid'])     {$bgCol = ' class="bgColor-20"';} else {$bgCol = '';}
00533                         $lE_bgCol = $bgCol;
00534 
00535                                 // User/Group names:
00536                         $userN = $be_user_Array[$data['row']['perms_userid']] ? $be_user_Array[$data['row']['perms_userid']]['username'] : ($data['row']['perms_userid'] ? '<i>['.$data['row']['perms_userid'].']!</i>' : '');
00537                         $groupN = $be_group_Array[$data['row']['perms_groupid']] ? $be_group_Array[$data['row']['perms_groupid']]['title']  : ($data['row']['perms_groupid'] ? '<i>['.$data['row']['perms_groupid'].']!</i>' : '');
00538                         $groupN = t3lib_div::fixed_lgd_cs($groupN,20);
00539 
00540                                 // Seeing if editing of permissions are allowed for that page:
00541                         $editPermsAllowed=($data['row']['perms_userid']==$BE_USER->user['uid'] || $BE_USER->isAdmin());
00542 
00543                                 // First column:
00544                         $cellAttrib = ($data['row']['_CSSCLASS'] ? ' class="'.$data['row']['_CSSCLASS'].'"' : '');
00545                         $cells[]='
00546                                         <td align="left" nowrap="nowrap"'.($cellAttrib ? $cellAttrib : $bgCol).'>'.$data['HTML'].htmlspecialchars(t3lib_div::fixed_lgd($data['row']['title'],$tLen)).'&nbsp;</td>';
00547 
00548                                 // "Edit permissions" -icon
00549                         if ($editPermsAllowed && $data['row']['uid'])   {
00550                                 $aHref = 'index.php?mode='.$this->MOD_SETTINGS['mode'].'&depth='.$this->MOD_SETTINGS['depth'].'&id='.($data['row']['_ORIG_uid'] ? $data['row']['_ORIG_uid'] : $data['row']['uid']).'&return_id='.$this->id.'&edit=1';
00551                                 $cells[]='
00552                                         <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>';
00553                         } else {
00554                                 $cells[]='
00555                                         <td'.$bgCol.'></td>';
00556                         }
00557 
00558                                 // Rest of columns (depending on mode)
00559                         if ($this->MOD_SETTINGS['mode']=='perms')       {
00560                                 $cells[]='
00561                                         <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00562                                         <td'.$bgCol.' nowrap="nowrap">'.($data['row']['uid']?$this->printPerms($data['row']['perms_user']).' '.$userN:'').'</td>
00563 
00564                                         <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00565                                         <td'.$bgCol.' nowrap="nowrap">'.($data['row']['uid']?$this->printPerms($data['row']['perms_group']).' '.$groupN:'').'</td>
00566 
00567                                         <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00568                                         <td'.$bgCol.' nowrap="nowrap">'.($data['row']['uid']?' '.$this->printPerms($data['row']['perms_everybody']):'').'</td>
00569 
00570                                         <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00571                                         <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>
00572                                 ';
00573                         } else {
00574                                 $cells[]='
00575                                         <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>';
00576 
00577                                 if ($BE_USER->user['uid']==$data['row']['perms_userid'])        {$bgCol = ' class="bgColor-20"';} else {$bgCol = $lE_bgCol;}
00578 // FIXME $owner undefined
00579                                 $cells[]='
00580                                         <td'.$bgCol.' nowrap="nowrap" align="center">'.($data['row']['uid']?$owner.$this->printPerms($BE_USER->calcPerms($data['row'])):'').'</td>
00581                                         '.(!$BE_USER->isAdmin()?'
00582                                         <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
00583                                         <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>
00584                                         ':'');
00585                                 $bgCol = $lE_bgCol;
00586                         }
00587 
00588                                 // Compile table row:
00589                         $code.='
00590                                 <tr>
00591                                         '.implode('
00592                                         ',$cells).'
00593                                 </tr>';
00594                 }
00595 
00596                         // Wrap rows in table tags:
00597                 $code='<table border="0" cellspacing="0" cellpadding="0" id="typo3-permissionList">'.$code.'</table>';
00598 
00599                         // Adding the content as a section:
00600                 $this->content.=$this->doc->section('',$code);
00601 
00602                         // CSH for permissions setting
00603                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module', $GLOBALS['BACK_PATH'],'<br/>|');
00604 
00605                         // Creating legend table:
00606                 $legendText = '<b>'.$LANG->getLL('1',1).'</b>: '.$LANG->getLL('1_t',1);
00607                 $legendText.= '<br /><b>'.$LANG->getLL('16',1).'</b>: '.$LANG->getLL('16_t',1);
00608                 $legendText.= '<br /><b>'.$LANG->getLL('2',1).'</b>: '.$LANG->getLL('2_t',1);
00609                 $legendText.= '<br /><b>'.$LANG->getLL('4',1).'</b>: '.$LANG->getLL('4_t',1);
00610                 $legendText.= '<br /><b>'.$LANG->getLL('8',1).'</b>: '.$LANG->getLL('8_t',1);
00611 
00612                 $code='<table border="0" id="typo3-legendTable">
00613                         <tr>
00614                                 <td valign="top"><img src="legend.gif" width="86" height="75" alt="" /></td>
00615                                 <td valign="top" nowrap="nowrap">'.$legendText.'</td>
00616                         </tr>
00617                 </table>';
00618                 $code.='<br />'.$LANG->getLL('def',1);
00619                 $code.='<br /><br /><span class="perm-allowed">*</span>: '.$LANG->getLL('A_Granted',1);
00620                 $code.='<br /><span class="perm-denied">x</span>: '.$LANG->getLL('A_Denied',1);
00621 
00622                         // Adding section with legend code:
00623                 $this->content.=$this->doc->spacer(20);
00624                 $this->content.=$this->doc->section($LANG->getLL('Legend').':',$code,0,1);
00625         }
00626 
00627 
00628 
00629 
00630 
00631 
00632 
00633 
00634 
00635 
00636 
00637 
00638 
00639 
00640         /*****************************
00641          *
00642          * Helper functions
00643          *
00644          *****************************/
00645 
00653         function printCheckBox($checkName,$num) {
00654                 $onClick = 'checkChange(\'check['.$checkName.']\', \'data[pages]['.$GLOBALS['SOBE']->id.']['.$checkName.']\')';
00655                 return '<input type="checkbox" name="check['.$checkName.']['.$num.']" onclick="'.htmlspecialchars($onClick).'" /><br />';
00656         }
00657 
00664         function printPerms($int)       {
00665                 $str='';
00666                 $str.= (($int&1)?'*':'<span class="perm-denied">x</span>');
00667                 $str.= (($int&16)?'*':'<span class="perm-denied">x</span>');
00668                 $str.= (($int&2)?'*':'<span class="perm-denied">x</span>');
00669                 $str.= (($int&4)?'*':'<span class="perm-denied">x</span>');
00670                 $str.= (($int&8)?'*':'<span class="perm-denied">x</span>');
00671 
00672                 return '<span class="perm-allowed">'.$str.'</span>';
00673         }
00674 
00682         function groupPerms($row,$firstGroup)   {
00683                 if (is_array($row))     {
00684                         $out=intval($row['perms_everybody']);
00685                         if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
00686                                 $out|= intval($row['perms_group']);
00687                         }
00688                         return $out;
00689                 }
00690         }
00691 
00699         function getRecursiveSelect($id,$perms_clause)  {
00700 
00701                         // Initialize tree object:
00702                 $tree = t3lib_div::makeInstance('t3lib_pageTree');
00703                 $tree->init('AND '.$perms_clause);
00704                 $tree->addField('perms_userid',1);
00705                 $tree->makeHTML=0;
00706                 $tree->setRecs = 1;
00707 
00708                         // Make tree:
00709                 $tree->getTree($id,$this->getLevels,'');
00710 
00711                         // If there are a hierarchy of page ids, then...
00712                 if ($GLOBALS['BE_USER']->user['uid'] && count($tree->orig_ids_hierarchy))       {
00713 
00714                                 // Init:
00715                         $label_recur = $GLOBALS['LANG']->getLL('recursive');
00716                         $label_levels = $GLOBALS['LANG']->getLL('levels');
00717                         $label_pA = $GLOBALS['LANG']->getLL('pages_affected');
00718                         $theIdListArr=array();
00719                         $opts='
00720                                                 <option value=""></option>';
00721 
00722                                 // Traverse the number of levels we want to allow recursive setting of permissions for:
00723                         for ($a=$this->getLevels;$a>0;$a--)     {
00724                                 if (is_array($tree->orig_ids_hierarchy[$a]))    {
00725                                         foreach($tree->orig_ids_hierarchy[$a] as $theId)        {
00726                                                 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->user['uid']==$tree->recs[$theId]['perms_userid'])    {
00727                                                         $theIdListArr[]=$theId;
00728                                                 }
00729                                         }
00730                                         $lKey = $this->getLevels-$a+1;
00731                                         $opts.='
00732                                                 <option value="'.htmlspecialchars(implode(',',$theIdListArr)).'">'.
00733                                                         t3lib_div::deHSCentities(htmlspecialchars($label_recur.' '.$lKey.' '.$label_levels)).' ('.count($theIdListArr).' '.$label_pA.')'.
00734                                                         '</option>';
00735                                 }
00736                         }
00737 
00738                                 // Put the selector box together:
00739                         $theRecursiveSelect = '<br />
00740                                         <select name="mirror[pages]['.$id.']">
00741                                                 '.$opts.'
00742                                         </select>
00743 
00744                                 <br /><br />';
00745                 } else {
00746                         $theRecursiveSelect = '';
00747                 }
00748 
00749                         // Return selector box element:
00750                 return $theRecursiveSelect;
00751         }
00752 }
00753 
00754 // Include extension?
00755 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php'])    {
00756         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php']);
00757 }
00758 
00759 
00760 
00761 
00762 
00763 
00764 
00765 
00766 
00767 
00768 
00769 
00770 // Make instance:
00771 $SOBE = t3lib_div::makeInstance('SC_mod_web_perm_index');
00772 $SOBE->init();
00773 $SOBE->main();
00774 $SOBE->printContent();
00775 
00776 if ($TYPO3_CONF_VARS['BE']['compressionLevel']) {
00777         new gzip_encode($TYPO3_CONF_VARS['BE']['compressionLevel']);
00778 }
00779 ?>

This documentation has been generated automatically from TYPO3 source code using Doxygen and is provided as is by Cast Iron Coding as a courtesy to other TYPO3 developers and users. Please consider Cast Iron Coding — a full-service web development agency in Portland, Oregon specializing in TYPO3 extension development — for all of your TYPO3 development and consulting needs!