Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2004 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 document.location = 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 // Ending page: 00283 $this->content.=$this->doc->endPage(); 00284 } 00285 00291 function printContent() { 00292 00293 echo $this->content; 00294 } 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 /***************************** 00306 * 00307 * Listing and Form rendering 00308 * 00309 *****************************/ 00310 00317 function doEdit() { 00318 global $BE_USER,$LANG; 00319 00320 // Get usernames and groupnames 00321 $be_group_Array=t3lib_BEfunc::getListGroupNames('title,uid'); 00322 $groupArray=array_keys($be_group_Array); 00323 00324 $be_user_Array = t3lib_BEfunc::getUserNames(); 00325 if (!$GLOBALS['BE_USER']->isAdmin()) $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,1); 00326 $be_group_Array_o = $be_group_Array = t3lib_BEfunc::getGroupNames(); 00327 if (!$GLOBALS['BE_USER']->isAdmin()) $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o,$groupArray,1); 00328 $firstGroup = $groupArray[0] ? $be_group_Array[$groupArray[0]] : ''; // data of the first group, the user is member of 00329 00330 00331 // Owner selector: 00332 $options=''; 00333 $userset=0; // flag: is set if the page-userid equals one from the user-list 00334 foreach($be_user_Array as $uid => $row) { 00335 if ($uid==$this->pageinfo['perms_userid']) { 00336 $userset = 1; 00337 $selected=' selected="selected"'; 00338 } else {$selected='';} 00339 $options.=' 00340 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['username']).'</option>'; 00341 } 00342 $options=' 00343 <option value="0"></option>'.$options; 00344 $selector=' 00345 <select name="data[pages]['.$this->id.'][perms_userid]"> 00346 '.$options.' 00347 </select>'; 00348 00349 $this->content.=$this->doc->section($LANG->getLL('Owner').':',$selector); 00350 00351 00352 // Group selector: 00353 $options=''; 00354 $userset=0; 00355 foreach($be_group_Array as $uid => $row) { 00356 if ($uid==$this->pageinfo['perms_groupid']) { 00357 $userset = 1; 00358 $selected=' selected="selected"'; 00359 } else {$selected='';} 00360 $options.=' 00361 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['title']).'</option>'; 00362 } 00363 if (!$userset && $this->pageinfo['perms_groupid']) { // If the group was not set AND there is a group for the page 00364 $options=' 00365 <option value="'.$this->pageinfo['perms_groupid'].'" selected="selected">'. 00366 htmlspecialchars($be_group_Array_o[$this->pageinfo['perms_groupid']]['title']). 00367 '</option>'. 00368 $options; 00369 } 00370 $options=' 00371 <option value="0"></option>'.$options; 00372 $selector=' 00373 <select name="data[pages]['.$this->id.'][perms_groupid]"> 00374 '.$options.' 00375 </select>'; 00376 00377 $this->content.=$this->doc->divider(5); 00378 $this->content.=$this->doc->section($LANG->getLL('Group').':',$selector); 00379 00380 // Permissions checkbox matrix: 00381 $code=' 00382 <table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix"> 00383 <tr> 00384 <td></td> 00385 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('1',1)).'</td> 00386 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('16',1)).'</td> 00387 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('2',1)).'</td> 00388 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('4',1)).'</td> 00389 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('8',1)).'</td> 00390 </tr> 00391 <tr> 00392 <td align="right" class="bgColor2">'.$LANG->getLL('Owner',1).'</td> 00393 <td class="bgColor-20">'.$this->printCheckBox('perms_user',1).'</td> 00394 <td class="bgColor-20">'.$this->printCheckBox('perms_user',5).'</td> 00395 <td class="bgColor-20">'.$this->printCheckBox('perms_user',2).'</td> 00396 <td class="bgColor-20">'.$this->printCheckBox('perms_user',3).'</td> 00397 <td class="bgColor-20">'.$this->printCheckBox('perms_user',4).'</td> 00398 </tr> 00399 <tr> 00400 <td align="right" class="bgColor2">'.$LANG->getLL('Group',1).'</td> 00401 <td class="bgColor-20">'.$this->printCheckBox('perms_group',1).'</td> 00402 <td class="bgColor-20">'.$this->printCheckBox('perms_group',5).'</td> 00403 <td class="bgColor-20">'.$this->printCheckBox('perms_group',2).'</td> 00404 <td class="bgColor-20">'.$this->printCheckBox('perms_group',3).'</td> 00405 <td class="bgColor-20">'.$this->printCheckBox('perms_group',4).'</td> 00406 </tr> 00407 <tr> 00408 <td align="right" class="bgColor2">'.$LANG->getLL('Everybody',1).'</td> 00409 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',1).'</td> 00410 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',5).'</td> 00411 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',2).'</td> 00412 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',3).'</td> 00413 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',4).'</td> 00414 </tr> 00415 </table> 00416 <br /> 00417 00418 <input type="hidden" name="data[pages]['.$this->id.'][perms_user]" value="'.$this->pageinfo['perms_user'].'" /> 00419 <input type="hidden" name="data[pages]['.$this->id.'][perms_group]" value="'.$this->pageinfo['perms_group'].'" /> 00420 <input type="hidden" name="data[pages]['.$this->id.'][perms_everybody]" value="'.$this->pageinfo['perms_everybody'].'" /> 00421 '.$this->getRecursiveSelect($this->id,$this->perms_clause).' 00422 <input type="submit" name="submit" value="'.$LANG->getLL('Save',1).'" />'. 00423 '<input type="submit" value="'.$LANG->getLL('Abort',1).'" onclick="'.htmlspecialchars('jumpToUrl(\'index.php?id='.$this->id.'\'); return false;').'" /> 00424 <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).'" /> 00425 '; 00426 00427 // Adding section with the permission setting matrix: 00428 $this->content.=$this->doc->divider(5); 00429 $this->content.=$this->doc->section($LANG->getLL('permissions').':',$code); 00430 00431 // CSH for permissions setting 00432 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'],'<br/><br/>'); 00433 00434 // Adding help text: 00435 if ($BE_USER->uc['helpText']) { 00436 $this->content.=$this->doc->divider(20); 00437 $legendText = '<b>'.$LANG->getLL('1',1).'</b>: '.$LANG->getLL('1_t',1); 00438 $legendText.= '<br /><b>'.$LANG->getLL('16',1).'</b>: '.$LANG->getLL('16_t',1); 00439 $legendText.= '<br /><b>'.$LANG->getLL('2',1).'</b>: '.$LANG->getLL('2_t',1); 00440 $legendText.= '<br /><b>'.$LANG->getLL('4',1).'</b>: '.$LANG->getLL('4_t',1); 00441 $legendText.= '<br /><b>'.$LANG->getLL('8',1).'</b>: '.$LANG->getLL('8_t',1); 00442 00443 $code=$legendText.'<br /><br />'.$LANG->getLL('def',1); 00444 $this->content.=$this->doc->section($LANG->getLL('Legend',1).':',$code); 00445 } 00446 } 00447 00454 function notEdit() { 00455 global $BE_USER,$LANG,$BACK_PATH; 00456 00457 // 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 00458 $groupArray = $BE_USER->userGroupsUID; 00459 $be_user_Array = t3lib_BEfunc::getUserNames(); 00460 if (!$GLOBALS['BE_USER']->isAdmin()) $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,0); 00461 $be_group_Array = t3lib_BEfunc::getGroupNames(); 00462 if (!$GLOBALS['BE_USER']->isAdmin()) $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array,$groupArray,0); 00463 00464 // Length of strings: 00465 $tLen= ($this->MOD_SETTINGS['mode']=='perms' ? 20 : 30); 00466 00467 00468 // Selector for depth: 00469 $code.=$LANG->getLL('Depth').': '; 00470 $code.=t3lib_BEfunc::getFuncMenu($this->id,'SET[depth]',$this->MOD_SETTINGS['depth'],$this->MOD_MENU['depth']); 00471 $this->content.=$this->doc->section('',$code); 00472 $this->content.=$this->doc->spacer(5); 00473 00474 // Initialize tree object: 00475 $tree = t3lib_div::makeInstance('t3lib_pageTree'); 00476 $tree->init('AND '.$this->perms_clause); 00477 00478 $tree->addField('perms_user',1); 00479 $tree->addField('perms_group',1); 00480 $tree->addField('perms_everybody',1); 00481 $tree->addField('perms_userid',1); 00482 $tree->addField('perms_groupid',1); 00483 $tree->addField('hidden'); 00484 $tree->addField('fe_group'); 00485 $tree->addField('starttime'); 00486 $tree->addField('endtime'); 00487 $tree->addField('editlock'); 00488 00489 // Creating top icon; the current page 00490 $HTML=t3lib_iconWorks::getIconImage('pages',$this->pageinfo,$BACK_PATH,'align="top"'); 00491 $tree->tree[]=Array('row'=>$this->pageinfo,'HTML'=>$HTML); 00492 00493 // Create the tree from $this->id: 00494 $tree->getTree($this->id,$this->MOD_SETTINGS['depth'],''); 00495 00496 // Make header of table: 00497 $code=''; 00498 if ($this->MOD_SETTINGS['mode']=='perms') { 00499 $code.=' 00500 <tr> 00501 <td class="bgColor2" colspan="2"> </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('Owner',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('Group',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('Everybody',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('EditLock',1).'</b></td> 00510 </tr> 00511 '; 00512 } else { 00513 $code.=' 00514 <tr> 00515 <td class="bgColor2" colspan="2"> </td> 00516 <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td> 00517 <td class="bgColor2" align="center" nowrap="nowrap"><b>'.$LANG->getLL('User',1).':</b> '.$BE_USER->user['username'].'</td> 00518 '.(!$BE_USER->isAdmin()?'<td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td> 00519 <td class="bgColor2" align="center"><b>'.$LANG->getLL('EditLock',1).'</b></td>':'').' 00520 </tr>'; 00521 } 00522 00523 // Traverse tree: 00524 foreach($tree->tree as $data) { 00525 $cells = array(); 00526 00527 // Background colors: 00528 if ($this->lastEdited==$data['row']['uid']) {$bgCol = ' class="bgColor-20"';} else {$bgCol = '';} 00529 $lE_bgCol = $bgCol; 00530 00531 // User/Group names: 00532 $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>' : ''); 00533 $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>' : ''); 00534 $groupN = t3lib_div::fixed_lgd_cs($groupN,20); 00535 00536 // Seeing if editing of permissions are allowed for that page: 00537 $editPermsAllowed=($data['row']['perms_userid']==$BE_USER->user['uid'] || $BE_USER->isAdmin()); 00538 00539 // First column: 00540 $cells[]=' 00541 <td align="left" nowrap="nowrap"'.$bgCol.'>'.$data['HTML'].htmlspecialchars(t3lib_div::fixed_lgd($data['row']['title'],$tLen)).' </td>'; 00542 00543 // "Edit permissions" -icon 00544 if ($editPermsAllowed && $data['row']['uid']) { 00545 $aHref = 'index.php?mode='.$this->MOD_SETTINGS['mode'].'&depth='.$this->MOD_SETTINGS['depth'].'&id='.$data['row']['uid'].'&return_id='.$this->id.'&edit=1'; 00546 $cells[]=' 00547 <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>'; 00548 } else { 00549 $cells[]=' 00550 <td'.$bgCol.'></td>'; 00551 } 00552 00553 // Rest of columns (depending on mode) 00554 if ($this->MOD_SETTINGS['mode']=='perms') { 00555 $cells[]=' 00556 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td> 00557 <td'.$bgCol.' nowrap="nowrap">'.($data['row']['uid']?$this->printPerms($data['row']['perms_user']).' '.$userN:'').'</td> 00558 00559 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td> 00560 <td'.$bgCol.' nowrap="nowrap">'.($data['row']['uid']?$this->printPerms($data['row']['perms_group']).' '.$groupN:'').'</td> 00561 00562 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td> 00563 <td'.$bgCol.' nowrap="nowrap">'.($data['row']['uid']?' '.$this->printPerms($data['row']['perms_everybody']):'').'</td> 00564 00565 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td> 00566 <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> 00567 '; 00568 } else { 00569 $cells[]=' 00570 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>'; 00571 00572 if ($BE_USER->user['uid']==$data['row']['perms_userid']) {$bgCol = ' class="bgColor-20"';} else {$bgCol = $lE_bgCol;} 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 ?>