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 ***************************************************************/ 00089 unset($MCONF); 00090 require ('conf.php'); 00091 require ($BACK_PATH.'init.php'); 00092 require ($BACK_PATH.'template.php'); 00093 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php'); 00094 require_once (PATH_t3lib.'class.t3lib_browsetree.php'); 00095 require_once (PATH_t3lib.'class.t3lib_foldertree.php'); 00096 require_once (PATH_t3lib.'class.t3lib_tstemplate.php'); 00097 require_once (PATH_t3lib.'class.t3lib_loadmodules.php'); 00098 require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php'); 00099 require_once (PATH_typo3.'class.alt_menu_functions.inc'); 00100 00101 $BE_USER->modAccess($MCONF,1); 00102 00103 00104 00105 00106 00107 00115 class localPageTree extends t3lib_browseTree { 00116 var $expandFirst=0; 00117 var $expandAll=0; 00118 00126 function localPageTree($BE_USER,$WEBMOUNTS='') { 00127 $this->init(); 00128 00129 $this->BE_USER = $BE_USER; 00130 $this->MOUNTS = $WEBMOUNTS; 00131 $this->clause = $this->ext_permsC(); // Notice, this clause does NOT filter out un-readable pages. This is the POINT since this class is ONLY used for the main overview where ALL is shown! Otherwise "AND '.$this->BE_USER->getPagePermsClause(1).'" should be added. 00132 $this->orderByFields = 'sorting'; 00133 } 00134 00140 function ext_permsC() { 00141 return ''; 00142 } 00143 00151 function wrapTitle($str,$row) { 00152 return $str; 00153 } 00154 00163 function PM_ATagWrap($icon,$cmd,$bMark='') { 00164 return ''; 00165 } 00166 00174 function wrapIcon($icon,$row) { 00175 // Add title attribute to input icon tag 00176 $title = '['.$row['uid'].'] '.t3lib_BEfunc::getRecordPath($row['uid'],'',15); 00177 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"'); 00178 00179 return $theIcon; 00180 } 00181 00187 function initializePositionSaving() { 00188 $this->stored=array(); 00189 } 00190 } 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00208 class printAllPageTree extends localPageTree { 00209 var $expandFirst=1; 00210 var $expandAll=1; 00211 00217 function ext_permsC() { 00218 return ' AND '.$this->BE_USER->getPagePermsClause(1); 00219 } 00220 00229 function PM_ATagWrap($icon,$cmd,$bMark='') { 00230 return $icon; 00231 } 00232 00240 function wrapIcon($icon,$row) { 00241 // Add title attribute to input icon tag 00242 $title = '['.$row['uid'].']'; 00243 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"'); 00244 00245 return $theIcon; 00246 } 00247 } 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00265 class printAllPageTree_perms extends printAllPageTree { 00266 00274 function printTree($treeArr='',$printPath=0) { 00275 $titleLen=intval($this->BE_USER->uc['titleLen']); 00276 00277 $be_user_Array = t3lib_BEfunc::getUserNames(); 00278 $be_group_Array = t3lib_BEfunc::getGroupNames(); 00279 $lines=array(); 00280 $lines[]='<tr class="bgColor5"> 00281 <td nowrap="nowrap"><strong>Page title:</strong></td> 00282 '.($printPath?'<td nowrap="nowrap"><strong>Path:</strong></td>':'').' 00283 <td nowrap="nowrap" colspan=2><strong>User:</strong></td> 00284 <td nowrap="nowrap" colspan=2><strong>Group: </strong></td> 00285 <td nowrap="nowrap"><strong>Everybody: </strong></td> 00286 <td nowrap="nowrap"><strong>This user: </strong></td> 00287 <td nowrap="nowrap"><strong>Main group:</strong></td> 00288 </tr>'; 00289 00290 if (!is_array($treeArr)) $treeArr=$this->tree; 00291 reset($treeArr); 00292 while(list($k,$v)=each($treeArr)) { 00293 $col1 = ' bgcolor="'.t3lib_div::modifyHtmlColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"'; 00294 $row = $v['row']; 00295 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$this->BE_USER->uc['titleLen'])); 00296 $lines[]='<tr class="bgColor4"> 00297 <td nowrap="nowrap">'.$v['HTML'].$title.' </td> 00298 '.($printPath?'<td nowrap="nowrap">'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row['pid'],'',15)).' </td>':'').' 00299 <td nowrap="nowrap"'.$col1.'>'.$be_user_Array[$row['perms_userid']]['username'].' </td> 00300 <td nowrap="nowrap"'.$col1.'>'.$this->ext_printPerms($row['perms_user']).' </td> 00301 <td nowrap="nowrap">'.$be_group_Array[$row['perms_groupid']]['title'].' </td> 00302 <td nowrap="nowrap">'.$this->ext_printPerms($row['perms_group']).' </td> 00303 <td nowrap="nowrap" align="center" '.$col1.'>'.$this->ext_printPerms($row['perms_everybody']).' </td> 00304 <td nowrap="nowrap" align="center">'.($row['editlock'] ? '<img src="'.$this->backPath.'gfx/recordlock_warning2.gif" width="22" height="16" title="Edit lock prevents all editing" alt="" />' : $this->ext_printPerms($this->BE_USER->calcPerms($row))).' </td> 00305 <td nowrap="nowrap" align="center">'.$this->ext_printPerms($this->ext_groupPerms($row,$be_group_Array[$this->BE_USER->firstMainGroup])).' </td> 00306 </tr>'; 00307 } 00308 return '<table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table>'; 00309 } 00310 00317 function ext_printPerms($int) { 00318 $str=''; 00319 $str.= (($int&1)?'*':'<font color="red">x</font>'); 00320 $str.= (($int&16)?'*':'<font color="red">x</font>'); 00321 $str.= (($int&2)?'*':'<font color="red">x</font>'); 00322 $str.= (($int&4)?'*':'<font color="red">x</font>'); 00323 $str.= (($int&8)?'*':'<font color="red">x</font>'); 00324 00325 return '<b><font color="green">'.$str.'</font></b>'; 00326 } 00327 00335 function ext_groupPerms($row,$firstGroup) { 00336 if (is_array($row)) { 00337 $out=intval($row['perms_everybody']); 00338 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) { 00339 $out|= intval($row['perms_group']); 00340 } 00341 return $out; 00342 } 00343 } 00344 } 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00363 class localFolderTree extends t3lib_folderTree { 00364 var $expandFirst=0; 00365 var $expandAll=0; 00366 00374 function localFolderTree($BE_USER,$FILEMOUNTS='') { 00375 $this->init(); 00376 00377 $this->BE_USER = $BE_USER; 00378 $this->MOUNTS = $FILEMOUNTS; 00379 $this->clause = ''; // Notice, this clause does NOT filter out un-readable pages. This is the POINT since this class is ONLY used for the main overview where ALL is shown! Otherwise "AND '.$this->BE_USER->getPagePermsClause(1).'" should be added. 00380 } 00381 00389 function wrapTitle($str,$row) { 00390 return $str; 00391 } 00392 00401 function PM_ATagWrap($icon,$cmd,$bMark='') { 00402 return ''; 00403 } 00404 00412 function wrapIcon($icon,$row) { 00413 // Add title attribute to input icon tag 00414 $title = $GLOBALS['SOBE']->localPath($row['path']); 00415 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '')); 00416 00417 return $theIcon; 00418 } 00419 00425 function initializePositionSaving() { 00426 $this->stored=array(); 00427 } 00428 } 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00449 class printAllFolderTree extends localFolderTree { 00450 var $expandFirst=1; 00451 var $expandAll=1; 00452 00461 function PM_ATagWrap($icon,$cmd,$bMark='') { 00462 return $icon; 00463 } 00464 } 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00483 class local_beUserAuth extends t3lib_beUserAuth { 00484 var $ext_pageIdsFromMounts=''; // List of mounted page ids (from browsetree class when selecting mountpoints) 00485 var $ext_non_readAccessPageArray=array(); // Storage for non-readable webmounts, see returnWebmounts() 00486 00495 function returnWebmounts($pClause='') { 00496 00497 // Get array of webmounts: 00498 $webmounts = (string)($this->groupData['webmounts'])!='' ? explode(',',$this->groupData['webmounts']) : Array(); 00499 00500 // Get select clause: 00501 $pClause=$pClause?$pClause:$this->getPagePermsClause(1); 00502 00503 // Traverse mounts, check if they are readable: 00504 foreach($webmounts as $k => $id) { 00505 $rec=t3lib_BEfunc::getRecord('pages',$id,'*',' AND '.$pClause); 00506 if (!is_array($rec)) { 00507 $this->ext_non_readAccessPageArray[$id]=t3lib_BEfunc::getRecord('pages',$id); 00508 unset($webmounts[$k]); 00509 } 00510 } 00511 return $webmounts; 00512 } 00513 00519 function ext_non_readAccessPages() { 00520 $lines=array(); 00521 00522 foreach($this->ext_non_readAccessPageArray as $pA) { 00523 if ($pA) $lines[]=t3lib_BEfunc::getRecordPath($pA['uid'],'',15); 00524 } 00525 if (count($lines)) { 00526 return '<table bgcolor="red" border="0" cellpadding="0" cellspacing="0"> 00527 <tr> 00528 <td align="center"><font color="white"><strong>The user has no read access to these DB-mounts!</strong></font></td> 00529 </tr> 00530 <tr> 00531 <td>'.implode('</td></tr><tr><td>',$lines).'</td> 00532 </tr> 00533 </table>'; 00534 } 00535 } 00536 00542 function user_where_clause() { 00543 return 'AND pid=0 '; 00544 } 00545 00554 function ext_printOverview($uInfo,$compareFlags,$printTrees=0) { 00555 // Prepare for filemount and db-mount 00556 if ($printTrees) { // ... this is if we see the detailed view for a user: 00557 // Page tree object: 00558 $className=t3lib_div::makeInstanceClassName(!$this->isAdmin() ? 'printAllPageTree_perms' : 'printAllPageTree'); 00559 $pagetree = new $className($this,$this->returnWebmounts()); // Here, only readable webmounts are returned (1=1) 00560 $pagetree->addField('perms_user',1); 00561 $pagetree->addField('perms_group',1); 00562 $pagetree->addField('perms_everybody',1); 00563 $pagetree->addField('perms_userid',1); 00564 $pagetree->addField('perms_groupid',1); 00565 $pagetree->addField('editlock',1); 00566 00567 // Folder tree object: 00568 $className=t3lib_div::makeInstanceClassName('printAllFolderTree'); 00569 $foldertree = new $className($this,$this->returnFilemounts()); 00570 } else { 00571 // Page tree object: 00572 $className=t3lib_div::makeInstanceClassName('localPageTree'); 00573 $pagetree = new $className($this,$this->returnWebmounts('1=1')); // Here, ALL webmounts are returned (1=1) 00574 00575 // Folder tree object: 00576 $className=t3lib_div::makeInstanceClassName('localFolderTree'); 00577 $foldertree = new $className($this,$this->returnFilemounts()); 00578 } 00579 00580 // Names for modules: 00581 $modNames = array( 00582 'web' => 'Web', 00583 'web_layout' => 'Page', 00584 'web_modules' => 'Modules', 00585 'web_info' => 'Info', 00586 'web_perms' => 'Access', 00587 'web_func' => 'Func', 00588 'web_list' => 'List', 00589 'web_ts' => 'Template', 00590 'file' => 'File', 00591 'file_list' => 'List', 00592 'file_images' => 'Images', 00593 'doc' => 'Doc.', 00594 'help' => 'Help', 00595 'help_about' => 'About', 00596 'help_quick' => 'User manual', 00597 'help_welcome' => 'Welcome', 00598 'user' => 'User', 00599 'user_setup' => 'Setup', 00600 'user_task' => 'Task center' 00601 ); 00602 00603 // Traverse the enabled analysis topics: 00604 $out=array(); 00605 foreach($uInfo as $k => $v) { 00606 if ($compareFlags[$k]) { 00607 switch($k) { 00608 case 'filemounts': 00609 $out[$k] = $foldertree->getBrowsableTree(); 00610 break; 00611 case 'webmounts': 00612 // Print webmounts: 00613 $pagetree->addSelfId=1; 00614 $out[$k] = $this->ext_non_readAccessPages(); // Add HTML for non-readable webmounts (only shown when viewing details of a user - in overview/comparison ALL mounts are shown) 00615 $out[$k].= $pagetree->getBrowsableTree(); // Add HTML for readable webmounts. 00616 $this->ext_pageIdsFromMounts=implode(',',array_unique($pagetree->ids)); // List of mounted page ids 00617 break; 00618 case 'tempPath': 00619 $out[$k] = $GLOBALS['SOBE']->localPath($v); 00620 break; 00621 case 'pagetypes_select': 00622 $pageTypes = explode(',',$v); 00623 reset($pageTypes); 00624 while(list($kk,$vv)=each($pageTypes)) { 00625 $pageTypes[$kk]=$GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('pages','doktype',$vv)); 00626 } 00627 $out[$k] = implode('<br />',$pageTypes); 00628 break; 00629 case 'tables_select': 00630 case 'tables_modify': 00631 $tables = explode(',',$v); 00632 reset($tables); 00633 while(list($kk,$vv)=each($tables)) { 00634 if ($vv) { 00635 $tables[$kk]='<span class="nobr">'.t3lib_iconWorks::getIconImage($vv,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>'; 00636 } 00637 } 00638 $out[$k] = implode('<br />',$tables); 00639 break; 00640 case 'non_exclude_fields': 00641 $nef = explode(',',$v); 00642 reset($nef); 00643 $table=''; 00644 $pout=array(); 00645 while(list($kk,$vv)=each($nef)) { 00646 if ($vv) { 00647 list($thisTable,$field) = explode(':',$vv); 00648 if ($thisTable!=$table) { 00649 $table=$thisTable; 00650 t3lib_div::loadTCA($table); 00651 $pout[]='<span class="nobr">'.t3lib_iconWorks::getIconImage($table,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']).'</span>'; 00652 } 00653 if ($GLOBALS['TCA'][$table]['columns'][$field]) { 00654 $pout[]='<span class="nobr"> - '.ereg_replace(':$','',$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label'])).'</span>'; 00655 } 00656 } 00657 } 00658 $out[$k] = implode('<br />',$pout); 00659 break; 00660 case 'groupList': 00661 case 'firstMainGroup': 00662 $uGroups = explode(',',$v); 00663 reset($uGroups); 00664 $table=''; 00665 $pout=array(); 00666 while(list($kk,$vv)=each($uGroups)) { 00667 if ($vv) { 00668 $uGRow = t3lib_BEfunc::getRecord('be_groups',$vv); 00669 $pout[]='<tr><td nowrap="nowrap">'.t3lib_iconWorks::getIconImage('be_groups',$uGRow,$GLOBALS['BACK_PATH'],'align="top"').' '.htmlspecialchars($uGRow['title']).' </td><td width=1% nowrap="nowrap">'.$GLOBALS['SOBE']->elementLinks('be_groups',$uGRow).'</td></tr>'; 00670 } 00671 } 00672 $out[$k] = '<table border="0" cellpadding="0" cellspacing="0" width="100%">'.implode('',$pout).'</table>'; 00673 break; 00674 case 'modules': 00675 $mods = explode(',',$v); 00676 reset($mods); 00677 $mainMod=''; 00678 $pout=array(); 00679 while(list($kk,$vv)=each($mods)) { 00680 if ($vv) { 00681 list($thisMod,$subMod) = explode('_',$vv); 00682 if ($thisMod!=$mainMod) { 00683 $mainMod=$thisMod; 00684 $pout[]='<span class="nobr">'.($modNames[$mainMod]?$modNames[$mainMod]:$mainMod).'</span>'; 00685 } 00686 if ($subMod) { 00687 $pout[]='<span class="nobr"> - '.($modNames[$mainMod.'_'.$subMod]?$modNames[$mainMod.'_'.$subMod]:$mainMod.'_'.$subMod).'</span>'; 00688 } 00689 } 00690 } 00691 $out[$k] = implode('<br />',$pout); 00692 break; 00693 case 'userTS': 00694 00695 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext'); // Defined global here! 00696 $tmpl->tt_track = 0; // Do not log time-performance information 00697 00698 $tmpl->fixedLgd=0; 00699 $tmpl->linkObjects=0; 00700 $tmpl->bType=''; 00701 $tmpl->ext_expandAllNotes=1; 00702 $tmpl->ext_noPMicons=1; 00703 $out[$k] = $tmpl->ext_getObjTree($v,'',''); 00704 break; 00705 case 'userTS_hl': 00706 $tsparser = t3lib_div::makeInstance('t3lib_TSparser'); 00707 $tsparser->lineNumberOffset=0; 00708 $out[$k] = $tsparser->doSyntaxHighlight($v,0,1); 00709 break; 00710 case 'explicit_allowdeny': 00711 00712 // Explode and flip values: 00713 $nef = array_flip(explode(',',$v)); 00714 $pout = array(); 00715 00716 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues(); 00717 00718 // Icons: 00719 $icons = array( 00720 'ALLOW' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_ok2.gif','').' class="absmiddle" alt="" />', 00721 'DENY' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_fatalerror.gif','').' class="absmiddle" alt="" />', 00722 ); 00723 00724 // Traverse types: 00725 foreach($theTypes as $tableFieldKey => $theTypeArrays) { 00726 if (is_array($theTypeArrays['items'])) { 00727 $pout[] = '<b>'.$theTypeArrays['tableFieldLabel'].'</b>'; 00728 // Traverse options for this field: 00729 foreach($theTypeArrays['items'] as $itemValue => $itemContent) { 00730 $v = $tableFieldKey.':'.$itemValue.':'.$itemContent[0]; 00731 if (isset($nef[$v])) { 00732 unset($nef[$v]); 00733 $pout[] = $icons[$itemContent[0]].'['.$itemContent[2].'] '.$itemContent[1]; 00734 } else { 00735 $pout[] = '<em style="color: #666666;">'.$icons[($itemContent[0]=='ALLOW' ? 'DENY' : 'ALLOW')].'['.$itemContent[2].'] '.$itemContent[1].'</em>'; 00736 } 00737 } 00738 $pout[] = ''; 00739 } 00740 } 00741 00742 // Add remaining: 00743 if (count($nef)) { 00744 $pout = array_merge($pout, array_keys($nef)); 00745 } 00746 00747 // Implode for display: 00748 $out[$k] = implode('<br />',$pout); 00749 break; 00750 case 'allowed_languages': 00751 00752 // Explode and flip values: 00753 $nef = array_flip(explode(',',$v)); 00754 $pout = array(); 00755 00756 // Get languages: 00757 $items = t3lib_BEfunc::getSystemLanguages(); 00758 00759 // Traverse values: 00760 foreach($items as $iCfg) { 00761 if (isset($nef[$iCfg[1]])) { 00762 unset($nef[$iCfg[1]]); 00763 $icon = '<img src="'.$GLOBALS['BACK_PATH'].$iCfg[2].'" class="absmiddle" style="margin-right: 5px;" alt="" />'; 00764 $pout[] = $icon.$iCfg[0]; 00765 } 00766 } 00767 00768 // Add remaining: 00769 if (count($nef)) { 00770 $pout = array_merge($pout, array_keys($nef)); 00771 } 00772 00773 // Implode for display: 00774 $out[$k] = implode('<br />',$pout); 00775 break; 00776 case 'custom_options': 00777 00778 // Explode and flip values: 00779 $nef = array_flip(explode(',',$v)); 00780 $pout = array(); 00781 00782 // Initialize: 00783 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions']; 00784 if (is_array($customOptions)) { 00785 foreach($customOptions as $coKey => $coValue) { 00786 if (is_array($coValue['items'])) { 00787 // Traverse items: 00788 foreach($coValue['items'] as $itemKey => $itemCfg) { 00789 $v = $coKey.':'.$itemKey; 00790 if (isset($nef[$v])) { 00791 unset($nef[$v]); 00792 $pout[] = $GLOBALS['LANG']->sl($coValue['header']).' / '.$GLOBALS['LANG']->sl($itemCfg[0]); 00793 } 00794 } 00795 } 00796 } 00797 } 00798 00799 // Add remaining: 00800 if (count($nef)) { 00801 $pout = array_merge($pout, array_keys($nef)); 00802 } 00803 00804 // Implode for display: 00805 $out[$k] = implode('<br />',$pout); 00806 break; 00807 } 00808 } 00809 } 00810 return $out; 00811 } 00812 00818 function ext_getReadableButNonmounted() { 00819 00820 // List of page id mounts which ARE mounted (and should therefore not be selected) 00821 if (!$this->ext_pageIdsFromMounts) { 00822 $this->ext_pageIdsFromMounts=0; 00823 } 00824 00825 // User and group names: 00826 $be_user_Array = t3lib_BEfunc::getUserNames(); 00827 $be_group_Array = t3lib_BEfunc::getGroupNames(); 00828 00829 // Create query: 00830 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 00831 'pid,uid,title,doktype,perms_user,perms_group,perms_everybody,perms_userid,perms_groupid'.(t3lib_extMgm::isLoaded('cms')?',media,layout,hidden,starttime,endtime,fe_group,extendToSubpages':''), 00832 'pages', 00833 'uid NOT IN ('.$this->ext_pageIdsFromMounts.') AND '.$this->getPagePermsClause(1).t3lib_BEfunc::deleteClause('pages') 00834 ); 00835 $dat = array(); 00836 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00837 $dat[] = array( 00838 'row'=>$row, 00839 'HTML'=>t3lib_iconWorks::getIconImage('pages',$row,$GLOBALS['BACK_PATH'],'align="top" title="['.$row['uid'].']"') // .htmlspecialchars($row['title']) 00840 ); 00841 } 00842 $className=t3lib_div::makeInstanceClassName('printAllPageTree_perms'); 00843 $pp = new $className($this); 00844 return $pp->printTree($dat,1); 00845 } 00846 00853 function ext_printPerms($int) { 00854 $str=''; 00855 $str.= (($int&1)?'*':'<font color="red">x</font>'); 00856 $str.= (($int&16)?'*':'<font color="red">x</font>'); 00857 $str.= (($int&2)?'*':'<font color="red">x</font>'); 00858 $str.= (($int&4)?'*':'<font color="red">x</font>'); 00859 $str.= (($int&8)?'*':'<font color="red">x</font>'); 00860 00861 return '<b><font color="green">'.$str.'</font></b>'; 00862 } 00863 00871 function ext_groupPerms($row,$firstGroup) { 00872 if (is_array($row)) { 00873 $out=intval($row['perms_everybody']); 00874 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) { 00875 $out|= intval($row['perms_group']); 00876 } 00877 return $out; 00878 } 00879 } 00880 00886 function ext_compileUserInfoForHash() { 00887 $uInfo=array(); 00888 00889 // Filemounts: 00890 $uInfo['filemounts']=$this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts']))); 00891 00892 // DBmounts: 00893 $uInfo['webmounts']=$this->ext_uniqueAndSortList($this->groupData['webmounts']); 00894 00895 // Sharing Upload Folder 00896 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00897 $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); 00898 $uInfo['tempPath'] = $fileProcessor->findTempFolder(); // The closest TEMP-path is found 00899 00900 // First Main Group: 00901 $uInfo['firstMainGroup']=$this->firstMainGroup; 00902 00903 // Group List: 00904 // $uInfo['groupList']=$this->ext_uniqueAndSortList($this->groupList); 00905 $uInfo['groupList']=$this->groupList; // This gives a list that shows in which order the groups are processed. This may result in a list of groups which is similar to that of another user regarding which group but not the order of groups. For now, I believe it's most usefull to let separate orders of groups appear as different group settings for a user. 00906 00907 // Page Types: 00908 $uInfo['pagetypes_select']=$this->ext_uniqueAndSortList($this->groupData['pagetypes_select']); 00909 00910 // Tables select: 00911 $uInfo['tables_select']=$this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']); 00912 00913 // Tables modify: 00914 $uInfo['tables_modify']=$this->ext_uniqueAndSortList($this->groupData['tables_modify']); 00915 00916 // Non-exclude fields: 00917 $uInfo['non_exclude_fields']=$this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']); 00918 00919 // Explicit Allow/Deny: 00920 $uInfo['explicit_allowdeny']=$this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']); 00921 00922 // Limit to languages: 00923 $uInfo['allowed_languages']=$this->ext_uniqueAndSortList($this->groupData['allowed_languages']); 00924 00925 // Custom options: 00926 $uInfo['custom_options']=$this->ext_uniqueAndSortList($this->groupData['custom_options']); 00927 00928 // Modules: 00929 $uInfo['modules']=$this->ext_uniqueAndSortList($this->groupData['modules']); 00930 00931 // User TS: 00932 $this->ext_ksortArrayRecursive($this->userTS); 00933 $uInfo['userTS'] = $this->userTS; 00934 00935 $uInfo['userTS_hl'] = $this->userTS_text; 00936 00937 return $uInfo; 00938 } 00939 00946 function ext_uniqueAndSortList($list) { 00947 $uList=t3lib_div::trimExplode(',',$list,1); 00948 sort($uList); 00949 $uList=array_unique($uList); 00950 $uList=implode(',',$uList); 00951 return $uList; 00952 } 00953 00960 function ext_ksortArrayRecursive(&$arr) { 00961 krsort($arr); 00962 reset($arr); 00963 while(list($k,$v)=each($arr)) { 00964 if (is_array($v)) $this->ext_ksortArrayRecursive($arr[$k]); 00965 } 00966 } 00967 } 00968 00969 00970 00971 00972 00973 00974 00975 00976 00977 00978 00979 00987 class SC_mod_tools_be_user_index { 00988 var $MCONF=array(); 00989 var $MOD_MENU=array(); 00990 var $MOD_SETTINGS=array(); 00991 var $doc; 00992 00993 var $include_once=array(); 00994 var $content; 00995 00999 function init() { 01000 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; 01001 $this->MCONF = $GLOBALS['MCONF']; 01002 01003 $this->menuConfig(); 01004 $this->switchUser(t3lib_div::_GP('SwitchUser')); 01005 01006 01007 // ************************** 01008 // Initializing 01009 // ************************** 01010 $this->doc = t3lib_div::makeInstance('noDoc'); 01011 $this->doc->form='<form action="" method="POST">'; 01012 $this->doc->backPath = $BACK_PATH; 01013 // JavaScript 01014 $this->doc->JScode = $this->doc->wrapScriptTags(' 01015 script_ended = 0; 01016 function jumpToUrl(URL) { // 01017 document.location = URL; 01018 } 01019 '); 01020 } 01021 01027 function menuConfig() { 01028 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; 01029 01030 // MENU-ITEMS: 01031 // If array, then it's a selector box menu 01032 // If empty string it's just a variable, that'll be saved. 01033 // Values NOT in this array will not be saved in the settings-array for the module. 01034 $this->MOD_MENU = array( 01035 'function' => array( 01036 'compare' => 'Compare User Settings' 01037 ) 01038 ); 01039 // CLEANSE SETTINGS 01040 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses'); 01041 } 01042 01048 function main() { 01049 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; 01050 01051 $this->content=''; 01052 $this->content.=$this->doc->startPage('Backend User Administration'); 01053 01054 $menu=t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']); 01055 01056 $this->content.=$this->doc->header('Backend User Administration'); 01057 $this->content.=$this->doc->spacer(5); 01058 $this->content.=$this->doc->section('',$menu).$this->doc->divider(5); 01059 01060 switch($this->MOD_SETTINGS['function']) { 01061 case 'compare': 01062 if (t3lib_div::_GP('ads')) { 01063 $compareFlags = t3lib_div::_GP('compareFlags'); 01064 $BE_USER->pushModuleData('tools_beuser/index.php/compare',$compareFlags); 01065 } else { 01066 $compareFlags = $BE_USER->getModuleData('tools_beuser/index.php/compare','ses'); 01067 } 01068 $this->content.=$this->compareUsers($compareFlags); 01069 break; 01070 } 01071 01072 01073 if ($BE_USER->mayMakeShortcut()) { 01074 $this->content.=$this->doc->spacer(20). 01075 $this->doc->section('',$this->doc->makeShortcutIcon('be_user_uid,compareFlags','function',$this->MCONF['name'])); 01076 } 01077 } 01078 01084 function printContent() { 01085 01086 $this->content.=$this->doc->endPage(); 01087 echo $this->content; 01088 } 01089 01090 01091 01092 01093 01094 01095 01096 /*************************** 01097 * 01098 * OTHER FUNCTIONS: 01099 * 01100 ***************************/ 01101 01106 function compareUsers($compareFlags) { 01107 global $SOBE; 01108 // Menu: 01109 $options = array( 01110 'filemounts' => 'Filemounts', 01111 'webmounts' => 'Webmounts', 01112 'tempPath' => 'Default upload path', 01113 'firstMainGroup' => 'Main user group', 01114 'groupList' => 'Member of groups', 01115 'pagetypes_select' => 'Page types access', 01116 'tables_select' => 'Select tables', 01117 'tables_modify' => 'Modify tables', 01118 'non_exclude_fields' => 'Non-exclude fields', 01119 'explicit_allowdeny' => 'Explicit Allow/Deny', 01120 'allowed_languages' => 'Limit to languages', 01121 'custom_options' => 'Custom options', 01122 'modules' => 'Modules', 01123 'userTS' => 'TSconfig', 01124 'userTS_hl' => 'TSconfig HL', 01125 ); 01126 01127 $be_user_uid = t3lib_div::_GP('be_user_uid'); 01128 if ($be_user_uid) { 01129 // This is used to test with other users. Development ONLY! 01130 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object 01131 $tempBE_USER->userTS_dontGetCached=1; 01132 $tempBE_USER->OS = TYPO3_OS; 01133 $tempBE_USER->setBeUserByUid($be_user_uid); 01134 $tempBE_USER->fetchGroupData(); 01135 01136 $uInfo = $tempBE_USER->ext_compileUserInfoForHash(); 01137 $uInfo_dat = $tempBE_USER->ext_printOverview($uInfo,$options,1); 01138 01139 $lines=array(); 01140 reset($options); 01141 while(list($kk,$vv)=each($options)) { 01142 if ($kk=='modules') { 01143 $loadModules = t3lib_div::makeInstance('t3lib_loadModules'); 01144 $loadModules->load($GLOBALS['TBE_MODULES'],$tempBE_USER); 01145 $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions'); 01146 $uInfo_dat[$kk] = $alt_menuObj->topMenu($loadModules->modules,1,$GLOBALS['BACK_PATH']); 01147 } 01148 $lines[]='<tr class="bgColor4"> 01149 <td nowrap="nowrap" valign="top">'.$vv.': </td> 01150 <td>'.$uInfo_dat[$kk].' </td> 01151 </tr>'; 01152 01153 if ($kk=='webmounts' && !$tempBE_USER->isAdmin()) { 01154 $lines[]='<tr class="bgColor4"> 01155 <td nowrap="nowrap" valign="top">Non-mounted readable pages: </td> 01156 <td>'.$tempBE_USER->ext_getReadableButNonmounted().' </td> 01157 </tr>'; 01158 } 01159 } 01160 01161 $outTable = '<table border="0" cellpadding="1" cellspacing="1"><tr class="bgColor5"><td>'.t3lib_iconWorks::getIconImage('be_users',$tempBE_USER->user,$GLOBALS['BACK_PATH'],'class="absmiddle" title="'.$tempBE_USER->user['uid'].'"').$tempBE_USER->user['username'].'</td>'; 01162 $outTable.= '<td>'.$tempBE_USER->user['realName'].($tempBE_USER->user['email'] ? ', <a href="mailto:'.$tempBE_USER->user['email'].'">'.$tempBE_USER->user['email'].'</a>' : '').'</td>'; 01163 $outTable.= '<td>'.$this->elementLinks('be_users',$tempBE_USER->user).'</td></tr></table>'; 01164 $outTable.= '<strong><a href="index.php">< Back to overview</a></strong><br />'; 01165 01166 $outTable.= '<br /><table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>'; 01167 $content.= $this->doc->section('User info',$outTable,0,1); 01168 } else { 01169 reset($options); 01170 $menu=array(); 01171 while(list($kk,$vv)=each($options)) { 01172 $menu[]='<input type="checkbox" value="1" name="compareFlags['.$kk.']"'.($compareFlags[$kk]?' checked="checked"':'').'>'.htmlspecialchars($vv); 01173 } 01174 $outCode = 'Group by:<br />'.implode('<br />',$menu); 01175 $outCode.='<br /><input type="submit" name="ads" value="Update">'; 01176 $content = $this->doc->section('Group and Compare Users',$outCode,0,1); 01177 01178 01179 // Traverse all users 01180 $users = t3lib_BEfunc::getUserNames(); 01181 $comparation=array(); 01182 // debug($users); 01183 reset($users); 01184 $counter=0; 01185 01186 01187 $offset=0; 01188 $numberAtTime=1000; 01189 $tooManyUsers=''; 01190 01191 while(list(,$r)=each($users)) { 01192 if ($counter>=$offset) { 01193 // This is used to test with other users. Development ONLY! 01194 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object 01195 $tempBE_USER->OS = TYPO3_OS; 01196 $tempBE_USER->setBeUserByUid($r['uid']); 01197 $tempBE_USER->fetchGroupData(); 01198 01199 // Making group data 01200 $md5pre=''; 01201 $menu=array(); 01202 $uInfo = $tempBE_USER->ext_compileUserInfoForHash(); 01203 reset($options); 01204 while(list($kk,$vv)=each($options)) { 01205 if ($compareFlags[$kk]) { 01206 $md5pre.=serialize($uInfo[$kk]).'|'; 01207 } 01208 } 01209 // setting md5: 01210 $md5=md5($md5pre); 01211 if (!isset($comparation[$md5])) { 01212 $comparation[$md5]=$tempBE_USER->ext_printOverview($uInfo,$compareFlags); 01213 $comparation[$md5]['users']=array(); 01214 } 01215 $comparation[$md5]['users'][]=$tempBE_USER->user; //array('uid'=>$r['uid'],'username'=>$r['username'],'realName'=>$tempBE_USER->user['realName'],'email'=>$tempBE_USER->user['email'],'admin'=>$tempBE_USER->user['admin']); 01216 unset($tempBE_USER); 01217 } 01218 $counter++; 01219 if ($counter>=($numberAtTime+$offset)) { 01220 $tooManyUsers='There were more than '.$numberAtTime.' users (total: '.count($users).') and this tool can display only '.$numberAtTime.' at a time!'; 01221 break; 01222 } 01223 } 01224 01225 // Print the groups: 01226 $allGroups=array(); 01227 // Header: 01228 $allCells = array(); 01229 reset($options); 01230 $allCells['USERS'] = '<b>Usernames:</b>'; 01231 while(list($kk,$vv)=each($options)) { 01232 if ($compareFlags[$kk]) { 01233 $allCells[$kk] = '<b>'.$vv.':</b>'; 01234 } 01235 } 01236 $allGroups[]=$allCells; 01237 01238 reset($comparation); 01239 while(list(,$dat)=each($comparation)) { 01240 $allCells = array(); 01241 01242 $uListArr=array(); 01243 reset($dat['users']); 01244 while(list(,$uDat)=each($dat['users'])) { 01245 $uListArr[] = '<tr><td width="130">'.t3lib_iconWorks::getIconImage('be_users',$uDat,$GLOBALS['BACK_PATH'],'align="top" title="'.$uDat['uid'].'"').$this->linkuser($uDat['username'],$uDat).' </td><td nowrap="nowrap">'.$this->elementLinks('be_users',$uDat). 01246 '<a href="'.t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'])).'" target="_top"><img src="'.$GLOBALS['BACK_PATH'].'gfx/su.gif" width="18" height="11" border="0" align="top" title="'.htmlspecialchars('Switch User to: '.$uDat['username']).'" alt="" /></a>'. 01247 '</td></tr>'; 01248 } 01249 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>'; 01250 01251 reset($options); 01252 while(list($kk,$vv)=each($options)) { 01253 if ($compareFlags[$kk]) { 01254 $allCells[$kk] = $dat[$kk]; 01255 } 01256 } 01257 $allGroups[]=$allCells; 01258 } 01259 01260 // Make table 01261 $outTable=''; 01262 reset($allGroups); 01263 $TDparams=' nowrap="nowrap" class="bgColor5" valign="top"'; 01264 while(list(,$allCells)=each($allGroups)) { 01265 $outTable.='<tr><td'.$TDparams.'>'.implode('</td><td'.$TDparams.'>',$allCells).'</td></tr>'; 01266 $TDparams=' nowrap="nowrap" class="bgColor4" valign="top"'; 01267 } 01268 $outTable='<table border="0" cellpadding="2" cellspacing="2">'.$outTable.'</table>'; 01269 $outTable.=fw('<br /><br />(All cached group lists updated.)'); 01270 $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">'.$tooManyUsers.'</span></strong>':''; 01271 $content.= $this->doc->spacer(10); 01272 $content.= $this->doc->section('Result',$outTable,0,1); 01273 } 01274 return $content; 01275 } 01276 01284 function linkUser($str,$rec) { 01285 return '<a href="index.php?be_user_uid='.$rec['uid'].'">'.$str.'</a>'; 01286 } 01287 01295 function elementLinks($table,$row) { 01296 global $TCA; 01297 // Info: 01298 $cells[]='<a href="#" onclick="top.launchView(\''.$table.'\', \''.$row['uid'].'\',\''.$GLOBALS['BACK_PATH'].'\'); return false;"><img src="'.$GLOBALS['BACK_PATH'].'gfx/zoom2.gif" width="12" height="12" border="0" align="top" title="Show information" alt="" /></a>'; 01299 01300 // Edit: 01301 $params='&edit['.$table.']['.$row['uid'].']=edit'; 01302 $cells[]='<a href="#" onclick="'.t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'],'').'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/edit2.gif" width="11" height="12" border="0" align="top" title="Edit" alt="" /></a>'; 01303 01304 // Hide: 01305 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled']; 01306 if ($row[$hiddenField]) { 01307 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0'; 01308 $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/button_unhide.gif" width="11" height="10" border="0" title="Disable" align="top" alt="" /></a>'; 01309 } else { 01310 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1'; 01311 $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/button_hide.gif" width="11" height="10" border="0" title="Disable" align="top" alt="" /></a>'; 01312 } 01313 01314 // Delete 01315 $params='&cmd['.$table.']['.$row['uid'].'][delete]=1'; 01316 $cells[]='<a href="'.$this->doc->issueCommand($params).'" onclick="return confirm(unescape(\''.rawurlencode('Are you sure you want to delete this element?').'\'));"><img src="'.$GLOBALS['BACK_PATH'].'gfx/garbage.gif" width="11" height="12" border="0" align="top" title="Delete(!)" alt="" /></a>'; 01317 01318 return implode('',$cells); 01319 } 01320 01326 function initUsers() { 01327 // Initializing all users in order to generate the usergroup_cached_list 01328 $users = t3lib_BEfunc::getUserNames(); 01329 //debug($users); 01330 reset($users); 01331 while(list(,$r)=each($users)) { 01332 // This is used to test with other users. Development ONLY! 01333 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object 01334 $tempBE_USER->OS = TYPO3_OS; 01335 $tempBE_USER->setBeUserByUid($r['uid']); 01336 $tempBE_USER->fetchGroupData(); 01337 } 01338 } 01339 01346 function localPath($str) { 01347 if (substr($str,0,strlen(PATH_site))==PATH_site) { 01348 return substr($str,strlen(PATH_site)); 01349 } else return $str; 01350 } 01351 01358 function switchUser($switchUser) { 01359 $uRec=t3lib_BEfunc::getRecord('be_users',$switchUser); 01360 if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin()) { 01361 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id="'.$GLOBALS['TYPO3_DB']->quoteStr($GLOBALS['BE_USER']->id, 'be_sessions').'" AND ses_name="be_typo_user" AND ses_userid='.intval($GLOBALS['BE_USER']->user['uid']), array('ses_userid' => $uRec['uid'])); 01362 01363 header('Location: '.t3lib_div::locationHeaderUrl($GLOBALS['BACK_PATH'].'index.php'.($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']?'':'?commandLI=1'))); 01364 exit; 01365 } 01366 } 01367 } 01368 01369 // Include extension? 01370 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']) { 01371 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']); 01372 } 01373 01374 01375 01376 01377 01378 01379 01380 01381 01382 01383 01384 01385 // Make instance: 01386 $SOBE = t3lib_div::makeInstance('SC_mod_tools_be_user_index'); 01387 $SOBE->init(); 01388 $SOBE->main(); 01389 $SOBE->printContent(); 01390 ?>