Documentation TYPO3 par Ameos

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


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6