|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Backend User Administration Module 00029 * 00030 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00031 */ 00032 /** 00033 * [CLASS/FUNCTION INDEX of SCRIPT] 00034 * 00035 * 00036 * 00037 * 129: class localPageTree extends t3lib_browseTree 00038 * 140: function localPageTree($BE_USER,$WEBMOUNTS='') 00039 * 154: function ext_permsC() 00040 * 165: function wrapTitle($str,$row) 00041 * 177: function PM_ATagWrap($icon,$cmd,$bMark='') 00042 * 188: function wrapIcon($icon,$row) 00043 * 201: function initializePositionSaving() 00044 * 00045 * 00046 * 222: class printAllPageTree extends localPageTree 00047 * 231: function ext_permsC() 00048 * 243: function PM_ATagWrap($icon,$cmd,$bMark='') 00049 * 254: function wrapIcon($icon,$row) 00050 * 00051 * 00052 * 279: class printAllPageTree_perms extends printAllPageTree 00053 * 288: function printTree($treeArr='',$printPath=0) 00054 * 331: function ext_printPerms($int) 00055 * 349: function ext_groupPerms($row,$firstGroup) 00056 * 00057 * 00058 * 377: class localFolderTree extends t3lib_folderTree 00059 * 388: function localFolderTree($BE_USER,$FILEMOUNTS='') 00060 * 403: function wrapTitle($str,$row) 00061 * 415: function PM_ATagWrap($icon,$cmd,$bMark='') 00062 * 426: function wrapIcon($icon,$row) 00063 * 439: function initializePositionSaving() 00064 * 00065 * 00066 * 463: class printAllFolderTree extends localFolderTree 00067 * 475: function PM_ATagWrap($icon,$cmd,$bMark='') 00068 * 00069 * 00070 * 497: class local_beUserAuth extends t3lib_beUserAuth 00071 * 509: function returnWebmounts($pClause='') 00072 * 533: function ext_non_readAccessPages() 00073 * 556: function user_where_clause() 00074 * 568: function ext_printOverview($uInfo,$compareFlags,$printTrees=0) 00075 * 838: function ext_getReadableButNonmounted() 00076 * 873: function ext_printPerms($int) 00077 * 891: function ext_groupPerms($row,$firstGroup) 00078 * 907: function ext_compileUserInfoForHash($filter=NULL) 00079 * 1007: function ext_uniqueAndSortList($list) 00080 * 1021: function ext_ksortArrayRecursive(&$arr) 00081 * 1034: function ext_workspaceMembership() 00082 * 00083 * 00084 * 1088: class SC_mod_tools_be_user_index 00085 * 1100: function init() 00086 * 1128: function menuConfig() 00087 * 1149: function main() 00088 * 1185: function printContent() 00089 * 00090 * SECTION: OTHER FUNCTIONS: 00091 * 1207: function compareUsers($compareFlags) 00092 * 1394: function linkUser($str,$rec) 00093 * 1405: function elementLinks($table,$row) 00094 * 1436: function initUsers() 00095 * 1456: function localPath($str) 00096 * 1468: function switchUser($switchUser) 00097 * 00098 * TOTAL FUNCTIONS: 39 00099 * (This index is automatically created/updated by the extension "extdeveval") 00100 * 00101 */ 00102 00103 require_once (PATH_typo3.'class.alt_menu_functions.inc'); 00104 00105 $GLOBALS['LANG']->includeLLFile('EXT:beuser/mod/locallang.xml'); 00106 00107 $BE_USER->modAccess($MCONF,1); 00108 00109 00110 00111 00112 00113 00114 /** 00115 * Base Extension class for printing a page tree (non-browsable though) 00116 * 00117 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00118 * @package TYPO3 00119 * @subpackage tx_beuser 00120 */ 00121 class localPageTree extends t3lib_browseTree { 00122 var $expandFirst=0; 00123 var $expandAll=0; 00124 00125 /** 00126 * Local backend user (not the GLOBALS[] backend user!!) 00127 * 00128 * @var t3lib_beUserAuth 00129 */ 00130 var $BE_USER; 00131 00132 /** 00133 * Constructor for the local page tree. 00134 * 00135 * @param object Local backend user (not the GLOBALS[] backend user!!) 00136 * @param array Webmounts for the backend user. 00137 * @return void 00138 */ 00139 function localPageTree($BE_USER,$WEBMOUNTS='') { 00140 $this->init(); 00141 00142 $this->BE_USER = $BE_USER; 00143 $this->MOUNTS = $WEBMOUNTS; 00144 $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. 00145 $this->orderByFields = 'sorting'; 00146 } 00147 00148 /** 00149 * Return select permissions. 00150 * 00151 * @return string WHERE query part. 00152 */ 00153 function ext_permsC() { 00154 return ''; 00155 } 00156 00157 /** 00158 * Wraps the title. 00159 * 00160 * @param string [See parent] 00161 * @param array [See parent] 00162 * @return string 00163 */ 00164 function wrapTitle($str,$row) { 00165 return $str; 00166 } 00167 00168 /** 00169 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon! 00170 * 00171 * @param string [See parent] 00172 * @param string [See parent] 00173 * @param string [See parent] 00174 * @return string 00175 */ 00176 function PM_ATagWrap($icon,$cmd,$bMark='') { 00177 return ''; 00178 } 00179 00180 /** 00181 * Wrapping the icon of the element/page. Normally a click menu is wrapped around the icon, but in this case only a title parameter is set. 00182 * 00183 * @param string Icon image tag. 00184 * @param array Row. 00185 * @return string Icon with title attribute added. 00186 */ 00187 function wrapIcon($icon,$row) { 00188 // Add title attribute to input icon tag 00189 $title = '['.$row['uid'].'] '.t3lib_BEfunc::getRecordPath($row['uid'],'',15); 00190 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"'); 00191 00192 return $theIcon; 00193 } 00194 00195 /** 00196 * This will make sure that no position data is acquired from the BE_USER uc variable. 00197 * 00198 * @return void 00199 */ 00200 function initializePositionSaving() { 00201 $this->stored=array(); 00202 } 00203 } 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 /** 00215 * Extension class for printing a page tree: All pages of a mount point. 00216 * 00217 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00218 * @package TYPO3 00219 * @subpackage tx_beuser 00220 */ 00221 class printAllPageTree extends localPageTree { 00222 var $expandFirst=1; 00223 var $expandAll=1; 00224 00225 /** 00226 * Return select permissions. 00227 * 00228 * @return string WHERE query part. 00229 */ 00230 function ext_permsC() { 00231 return ' AND '.$this->BE_USER->getPagePermsClause(1); 00232 } 00233 00234 /** 00235 * Returns the plus/minus icon. 00236 * 00237 * @param string [See parent] 00238 * @param string [See parent] 00239 * @param string [See parent] 00240 * @return string 00241 */ 00242 function PM_ATagWrap($icon,$cmd,$bMark='') { 00243 return $icon; 00244 } 00245 00246 /** 00247 * Wrapping the icon of the element/page. Normally a click menu is wrapped around the icon, but in this case only a title parameter is set. 00248 * 00249 * @param string Icon image tag. 00250 * @param array Row. 00251 * @return string Icon with title attribute added. 00252 */ 00253 function wrapIcon($icon,$row) { 00254 // Add title attribute to input icon tag 00255 $title = '['.$row['uid'].']'; 00256 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"'); 00257 00258 return $theIcon; 00259 } 00260 } 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 /** 00272 * Extension class for printing a page tree: Printing all pages, with permissions. 00273 * 00274 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00275 * @package TYPO3 00276 * @subpackage tx_beuser 00277 */ 00278 class printAllPageTree_perms extends printAllPageTree { 00279 00280 /** 00281 * Print the tree of pages. 00282 * 00283 * @param array The tree items 00284 * @param boolean If set, the path of the pages in the tree is printed (only done for pages outside of mounts). 00285 * @return string HTML content. 00286 */ 00287 function printTree($treeArr='',$printPath=0) { 00288 $titleLen=intval($this->BE_USER->uc['titleLen']); 00289 00290 $be_user_Array = t3lib_BEfunc::getUserNames(); 00291 $be_group_Array = t3lib_BEfunc::getGroupNames(); 00292 $lines=array(); 00293 $lines[]='<tr class="bgColor5"> 00294 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('pageTitle', true) . '</strong></td> 00295 ' . ($printPath?'<td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('path', true) . '</strong></td>':'') . ' 00296 <td nowrap="nowrap" colspan="2"><strong>' . $GLOBALS['LANG']->getLL('user', true) . '</strong></td> 00297 <td nowrap="nowrap" colspan="2"><strong>' . $GLOBALS['LANG']->getLL('group', true) . ' </strong></td> 00298 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('everybody', true) . ' </strong></td> 00299 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('thisUser', true) . ' </strong></td> 00300 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('mainGroup', true) . '</strong></td> 00301 </tr>'; 00302 00303 if (!is_array($treeArr)) { 00304 $treeArr = $this->tree; 00305 } 00306 foreach ($treeArr as $v) { 00307 $col1 = ' bgcolor="'.t3lib_div::modifyHtmlColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"'; 00308 $row = $v['row']; 00309 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$this->BE_USER->uc['titleLen'])); 00310 $lines[]='<tr class="bgColor4"> 00311 <td nowrap="nowrap">'.$v['HTML'].$title.' </td> 00312 '.($printPath?'<td nowrap="nowrap">'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row['pid'],'',15)).' </td>':'').' 00313 <td nowrap="nowrap"'.$col1.'>'.$be_user_Array[$row['perms_userid']]['username'].' </td> 00314 <td nowrap="nowrap"'.$col1.'>'.$this->ext_printPerms($row['perms_user']).' </td> 00315 <td nowrap="nowrap">'.$be_group_Array[$row['perms_groupid']]['title'].' </td> 00316 <td nowrap="nowrap">'.$this->ext_printPerms($row['perms_group']).' </td> 00317 <td nowrap="nowrap" align="center" '.$col1.'>'.$this->ext_printPerms($row['perms_everybody']).' </td> 00318 <td nowrap="nowrap" align="center">' . ($row['editlock'] ? t3lib_iconWorks::getSpriteIcon('status-warning-in-use', array('title' => $GLOBALS['LANG']->getLL('editLock', true))) : $this->ext_printPerms($this->BE_USER->calcPerms($row))) . ' </td> 00319 <td nowrap="nowrap" align="center">'.$this->ext_printPerms($this->ext_groupPerms($row,$be_group_Array[$this->BE_USER->firstMainGroup])).' </td> 00320 </tr>'; 00321 } 00322 return '<table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table>'; 00323 } 00324 00325 /** 00326 * Print a set of permissions 00327 * 00328 * @param integer The permissions integer. 00329 * @return string HTML formatted. 00330 */ 00331 function ext_printPerms($int) { 00332 $str=''; 00333 $str.= (($int&1)?'*':'<font color="red">x</font>'); 00334 $str.= (($int&16)?'*':'<font color="red">x</font>'); 00335 $str.= (($int&2)?'*':'<font color="red">x</font>'); 00336 $str.= (($int&4)?'*':'<font color="red">x</font>'); 00337 $str.= (($int&8)?'*':'<font color="red">x</font>'); 00338 00339 return '<strong style="color:green;">'.$str.'</strong>'; 00340 } 00341 00342 /** 00343 * returns the permissions for a group based of the perms_groupid of $row. If the $row[perms_groupid] equals the $firstGroup[uid] then the function returns perms_everybody OR'ed with perms_group, else just perms_everybody 00344 * 00345 * @param array Page record. 00346 * @param array First-group record. 00347 * @return integer Permissions. 00348 */ 00349 function ext_groupPerms($row,$firstGroup) { 00350 if (is_array($row)) { 00351 $out=intval($row['perms_everybody']); 00352 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) { 00353 $out|= intval($row['perms_group']); 00354 } 00355 return $out; 00356 } 00357 } 00358 } 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 /** 00371 * Base Extension class for printing a folder tree (non-browsable though) 00372 * 00373 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00374 * @package TYPO3 00375 * @subpackage tx_beuser 00376 */ 00377 class localFolderTree extends t3lib_folderTree { 00378 var $expandFirst=0; 00379 var $expandAll=0; 00380 00381 /** 00382 * Local backend user (not the GLOBALS[] backend user!!) 00383 * 00384 * @var t3lib_beUserAuth 00385 */ 00386 var $BE_USER; 00387 00388 /** 00389 * Constructor for the local folder tree. 00390 * 00391 * @param object Local backend user (not the GLOBALS[] backend user!!) 00392 * @param array Filemounts for the backend user. 00393 * @return void 00394 */ 00395 function localFolderTree($BE_USER,$FILEMOUNTS='') { 00396 $this->init(); 00397 00398 $this->BE_USER = $BE_USER; 00399 $this->MOUNTS = $FILEMOUNTS; 00400 $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. 00401 } 00402 00403 /** 00404 * Wraps the title. 00405 * 00406 * @param string [See parent] 00407 * @param array [See parent] 00408 * @return string 00409 */ 00410 function wrapTitle($str,$row) { 00411 return $str; 00412 } 00413 00414 /** 00415 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon! 00416 * 00417 * @param string [See parent] 00418 * @param string [See parent] 00419 * @param string [See parent] 00420 * @return string 00421 */ 00422 function PM_ATagWrap($icon,$cmd,$bMark='') { 00423 return ''; 00424 } 00425 00426 /** 00427 * Wrapping the icon of the element/page. Normally a click menu is wrapped around the icon, but in this case only a title parameter is set. 00428 * 00429 * @param string Icon image tag. 00430 * @param array Row. 00431 * @return string Icon with title attribute added. 00432 */ 00433 function wrapIcon($icon,$row) { 00434 // Add title attribute to input icon tag 00435 $title = $GLOBALS['SOBE']->localPath($row['path']); 00436 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '')); 00437 00438 return $theIcon; 00439 } 00440 00441 /** 00442 * This will make sure that no position data is acquired from the BE_USER uc variable. 00443 * 00444 * @return void 00445 */ 00446 function initializePositionSaving() { 00447 $this->stored=array(); 00448 } 00449 } 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 /** 00464 * Extension class for printing a folder tree: All folders 00465 * 00466 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00467 * @package TYPO3 00468 * @subpackage tx_beuser 00469 */ 00470 class printAllFolderTree extends localFolderTree { 00471 var $expandFirst=1; 00472 var $expandAll=1; 00473 00474 /** 00475 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon! 00476 * 00477 * @param string [See parent] 00478 * @param string [See parent] 00479 * @param string [See parent] 00480 * @return string 00481 */ 00482 function PM_ATagWrap($icon,$cmd,$bMark='') { 00483 return $icon; 00484 } 00485 } 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 /** 00498 * Extension class of beuserauth class. 00499 * 00500 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00501 * @package TYPO3 00502 * @subpackage tx_beuser 00503 */ 00504 class local_beUserAuth extends t3lib_beUserAuth { 00505 var $ext_pageIdsFromMounts=''; // List of mounted page ids (from browsetree class when selecting mountpoints) 00506 var $ext_non_readAccessPageArray=array(); // Storage for non-readable webmounts, see returnWebmounts() 00507 00508 /** 00509 * Returns an array of the webmounts for the user, with non-readable webmounts filtered out. 00510 * If there are non-readable webmounts they are registered in $this->ext_non_readAccessPageArray 00511 * (Extending function in parent class) 00512 * 00513 * @param string alternative select clause (default is getPagePermsClause(1)). For instance to make sure that ALL webmounts are selected regardless of whether the user has read access or not, you can set this to "1=1". 00514 * @return array Webmounts id's 00515 */ 00516 function returnWebmounts($pClause='') { 00517 00518 // Get array of webmounts: 00519 $webmounts = (string)($this->groupData['webmounts'])!='' ? explode(',',$this->groupData['webmounts']) : Array(); 00520 00521 // Get select clause: 00522 $pClause=$pClause?$pClause:$this->getPagePermsClause(1); 00523 00524 // Traverse mounts, check if they are readable: 00525 foreach ($webmounts as $k => $id) { 00526 $rec=t3lib_BEfunc::getRecord('pages',$id,'*',' AND '.$pClause); 00527 if (!is_array($rec)) { 00528 $this->ext_non_readAccessPageArray[$id]=t3lib_BEfunc::getRecord('pages',$id); 00529 unset($webmounts[$k]); 00530 } 00531 } 00532 return $webmounts; 00533 } 00534 00535 /** 00536 * Based on the content of ->ext_non_readAccessPageArray (see returnWebmounts()) it generates visually formatted information about these non-readable mounts. 00537 * 00538 * @return string HTML content showing which DB-mounts were not accessible for the user 00539 */ 00540 function ext_non_readAccessPages() { 00541 $lines=array(); 00542 00543 foreach ($this->ext_non_readAccessPageArray as $pA) { 00544 if ($pA) { 00545 $lines[] = t3lib_BEfunc::getRecordPath($pA['uid'],'',15); 00546 } 00547 } 00548 if (count($lines)) { 00549 return '<table bgcolor="red" border="0" cellpadding="0" cellspacing="0"> 00550 <tr> 00551 <td align="center"><font color="white"><strong>' . $GLOBALS['LANG']->getLL('noReadAccess', true) . '</strong></font></td> 00552 </tr> 00553 <tr> 00554 <td>'.implode('</td></tr><tr><td>',$lines).'</td> 00555 </tr> 00556 </table>'; 00557 } 00558 } 00559 00560 /** 00561 * This returns the where-clause needed to select the user with respect flags like deleted, hidden, starttime, endtime 00562 * 00563 * @return string 00564 */ 00565 function user_where_clause() { 00566 return 'AND pid=0 '; 00567 } 00568 00569 /** 00570 * Creates the overview information based on which analysis topics were selected. 00571 * 00572 * @param array Array of analysis topics 00573 * @param array Array of the selected analysis topics (from session variable somewhere) 00574 * @param boolean If set, the full trees of pages/folders are printed. 00575 * @return array Array with accumulated HTML content. 00576 */ 00577 function ext_printOverview($uInfo,$compareFlags,$printTrees=0) { 00578 // Prepare for filemount and db-mount 00579 if ($printTrees) { // ... this is if we see the detailed view for a user: 00580 // Page tree object: 00581 $pagetree = t3lib_div::makeInstance(!$this->isAdmin() ? 'printAllPageTree_perms' : 'printAllPageTree', $this, $this->returnWebmounts()); // Here, only readable webmounts are returned (1=1) 00582 $pagetree->addField('perms_user',1); 00583 $pagetree->addField('perms_group',1); 00584 $pagetree->addField('perms_everybody',1); 00585 $pagetree->addField('perms_userid',1); 00586 $pagetree->addField('perms_groupid',1); 00587 $pagetree->addField('editlock',1); 00588 00589 // Folder tree object: 00590 $foldertree = t3lib_div::makeInstance('printAllFolderTree', $this, $this->returnFilemounts()); 00591 } else { 00592 // Page tree object: 00593 $pagetree = t3lib_div::makeInstance('localPageTree', $this, $this->returnWebmounts('1=1')); // Here, ALL webmounts are returned (1=1) 00594 00595 // Folder tree object: 00596 $foldertree = t3lib_div::makeInstance('localFolderTree', $this, $this->returnFilemounts()); 00597 } 00598 00599 // Names for modules: 00600 $modNames = array( 00601 'web' => 'Web', 00602 'web_layout' => 'Page', 00603 'web_modules' => 'Modules', 00604 'web_info' => 'Info', 00605 'web_perms' => 'Access', 00606 'web_func' => 'Func', 00607 'web_list' => 'List', 00608 'web_ts' => 'Template', 00609 'file' => 'File', 00610 'file_list' => 'List', 00611 'file_images' => 'Images', 00612 'doc' => 'Doc.', 00613 'help' => 'Help', 00614 'help_about' => 'About', 00615 'help_quick' => 'User manual', 00616 'help_welcome' => 'Welcome', 00617 'user' => 'User', 00618 'user_setup' => 'Setup', 00619 'user_task' => 'Task center' 00620 ); 00621 00622 // Traverse the enabled analysis topics: 00623 $out=array(); 00624 foreach ($uInfo as $k => $v) { 00625 if ($compareFlags[$k]) { 00626 switch($k) { 00627 case 'filemounts': 00628 $out[$k] = $foldertree->getBrowsableTree(); 00629 break; 00630 case 'webmounts': 00631 // Print webmounts: 00632 $pagetree->addSelfId=1; 00633 $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) 00634 $out[$k].= $pagetree->getBrowsableTree(); // Add HTML for readable webmounts. 00635 $this->ext_pageIdsFromMounts=implode(',',array_unique($pagetree->ids)); // List of mounted page ids 00636 break; 00637 case 'tempPath': 00638 $out[$k] = $GLOBALS['SOBE']->localPath($v); 00639 break; 00640 case 'pagetypes_select': 00641 $pageTypes = explode(',',$v); 00642 foreach ($pageTypes as &$vv) { 00643 $vv = $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('pages','doktype',$vv)); 00644 } 00645 $out[$k] = implode('<br />',$pageTypes); 00646 break; 00647 case 'tables_select': 00648 case 'tables_modify': 00649 $tables = explode(',',$v); 00650 foreach ($tables as &$vv) { 00651 if ($vv) { 00652 $vv = '<span class="nobr">'.t3lib_iconWorks::getSpriteIconForRecord($vv,array()).$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>'; 00653 } 00654 } 00655 $out[$k] = implode('<br />',$tables); 00656 break; 00657 case 'non_exclude_fields': 00658 $nef = explode(',',$v); 00659 $table=''; 00660 $pout=array(); 00661 foreach ($nef as $vv) { 00662 if ($vv) { 00663 list($thisTable,$field) = explode(':',$vv); 00664 if ($thisTable!=$table) { 00665 $table=$thisTable; 00666 t3lib_div::loadTCA($table); 00667 $pout[]='<span class="nobr">'.t3lib_iconWorks::getSpriteIconForRecord($table,array()).$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']).'</span>'; 00668 } 00669 if ($GLOBALS['TCA'][$table]['columns'][$field]) { 00670 $pout[]='<span class="nobr"> - '.rtrim($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label']), ':').'</span>'; 00671 } 00672 } 00673 } 00674 $out[$k] = implode('<br />',$pout); 00675 break; 00676 case 'groupList': 00677 case 'firstMainGroup': 00678 $uGroups = explode(',',$v); 00679 $table=''; 00680 $pout=array(); 00681 foreach ($uGroups as $vv) { 00682 if ($vv) { 00683 $uGRow = t3lib_BEfunc::getRecord('be_groups',$vv); 00684 $pout[]='<tr><td nowrap="nowrap">'.t3lib_iconWorks::getSpriteIconForRecord('be_groups',$uGRow).' '.htmlspecialchars($uGRow['title']).' </td><td width=1% nowrap="nowrap">'.$GLOBALS['SOBE']->elementLinks('be_groups',$uGRow).'</td></tr>'; 00685 } 00686 } 00687 $out[$k] = '<table border="0" cellpadding="0" cellspacing="0" width="100%">'.implode('',$pout).'</table>'; 00688 break; 00689 case 'modules': 00690 $mods = explode(',',$v); 00691 $mainMod=''; 00692 $pout=array(); 00693 foreach ($mods as $vv) { 00694 if ($vv) { 00695 list($thisMod,$subMod) = explode('_',$vv); 00696 if ($thisMod!=$mainMod) { 00697 $mainMod=$thisMod; 00698 $pout[]='<span class="nobr">'.($modNames[$mainMod]?$modNames[$mainMod]:$mainMod).'</span>'; 00699 } 00700 if ($subMod) { 00701 $pout[]='<span class="nobr"> - '.($modNames[$mainMod.'_'.$subMod]?$modNames[$mainMod.'_'.$subMod]:$mainMod.'_'.$subMod).'</span>'; 00702 } 00703 } 00704 } 00705 $out[$k] = implode('<br />',$pout); 00706 break; 00707 case 'userTS': 00708 00709 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext'); // Defined global here! 00710 $tmpl->tt_track = 0; // Do not log time-performance information 00711 00712 $tmpl->fixedLgd=0; 00713 $tmpl->linkObjects=0; 00714 $tmpl->bType=''; 00715 $tmpl->ext_expandAllNotes=1; 00716 $tmpl->ext_noPMicons=1; 00717 $out[$k] = $tmpl->ext_getObjTree($v,'','','','','1'); 00718 break; 00719 case 'userTS_hl': 00720 $tsparser = t3lib_div::makeInstance('t3lib_TSparser'); 00721 $tsparser->lineNumberOffset=0; 00722 $out[$k] = $tsparser->doSyntaxHighlight($v,0,1); 00723 break; 00724 case 'explicit_allowdeny': 00725 00726 // Explode and flip values: 00727 $nef = array_flip(explode(',',$v)); 00728 $pout = array(); 00729 00730 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues(); 00731 00732 // Icons: 00733 $icons = array( 00734 'ALLOW' => t3lib_iconWorks::getSpriteIcon('status-dialog-ok'), 00735 'DENY' => t3lib_iconWorks::getSpriteIcon('status-dialog-error'), 00736 ); 00737 00738 // Traverse types: 00739 foreach ($theTypes as $tableFieldKey => $theTypeArrays) { 00740 if (is_array($theTypeArrays['items'])) { 00741 $pout[] = '<strong>'.$theTypeArrays['tableFieldLabel'].'</strong>'; 00742 // Traverse options for this field: 00743 foreach ($theTypeArrays['items'] as $itemValue => $itemContent) { 00744 $v = $tableFieldKey.':'.$itemValue.':'.$itemContent[0]; 00745 if (isset($nef[$v])) { 00746 unset($nef[$v]); 00747 $pout[] = $icons[$itemContent[0]].'['.$itemContent[2].'] '.$itemContent[1]; 00748 } else { 00749 $pout[] = '<em style="color: #666666;">'.$icons[($itemContent[0]=='ALLOW' ? 'DENY' : 'ALLOW')].'['.$itemContent[2].'] '.$itemContent[1].'</em>'; 00750 } 00751 } 00752 $pout[] = ''; 00753 } 00754 } 00755 00756 // Add remaining: 00757 if (count($nef)) { 00758 $pout = array_merge($pout, array_keys($nef)); 00759 } 00760 00761 // Implode for display: 00762 $out[$k] = implode('<br />',$pout); 00763 break; 00764 case 'allowed_languages': 00765 00766 // Explode and flip values: 00767 $nef = array_flip(explode(',',$v)); 00768 $pout = array(); 00769 00770 // Get languages: 00771 $items = t3lib_BEfunc::getSystemLanguages(); 00772 00773 // Traverse values: 00774 foreach ($items as $iCfg) { 00775 if (isset($nef[$iCfg[1]])) { 00776 unset($nef[$iCfg[1]]); 00777 if (strpos($iCfg[2], '.gif') === FALSE) { 00778 $icon = t3lib_iconWorks::getSpriteIcon($iCfg[2]) . ' '; 00779 } elseif (strlen($iCfg[2])) { 00780 $icon = '<img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$iCfg[2]).' class="absmiddle" style="margin-right: 5px;" alt="" />'; 00781 } else { 00782 $icon = ''; 00783 } 00784 $pout[] = $icon.$iCfg[0]; 00785 } 00786 } 00787 00788 // Add remaining: 00789 if (count($nef)) { 00790 $pout = array_merge($pout, array_keys($nef)); 00791 } 00792 00793 // Implode for display: 00794 $out[$k] = implode('<br />',$pout); 00795 break; 00796 case 'workspace_perms': 00797 $out[$k] = implode('<br/>',explode(', ',t3lib_BEfunc::getProcessedValue('be_users','workspace_perms',$v))); 00798 break; 00799 case 'workspace_membership': 00800 $out[$k] = implode('<br/>',$this->ext_workspaceMembership()); 00801 break; 00802 case 'custom_options': 00803 00804 // Explode and flip values: 00805 $nef = array_flip(explode(',',$v)); 00806 $pout = array(); 00807 00808 // Initialize: 00809 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions']; 00810 if (is_array($customOptions)) { 00811 foreach ($customOptions as $coKey => $coValue) { 00812 if (is_array($coValue['items'])) { 00813 // Traverse items: 00814 foreach ($coValue['items'] as $itemKey => $itemCfg) { 00815 $v = $coKey.':'.$itemKey; 00816 if (isset($nef[$v])) { 00817 unset($nef[$v]); 00818 $pout[] = $GLOBALS['LANG']->sl($coValue['header']).' / '.$GLOBALS['LANG']->sl($itemCfg[0]); 00819 } 00820 } 00821 } 00822 } 00823 } 00824 00825 // Add remaining: 00826 if (count($nef)) { 00827 $pout = array_merge($pout, array_keys($nef)); 00828 } 00829 00830 // Implode for display: 00831 $out[$k] = implode('<br />',$pout); 00832 break; 00833 } 00834 } 00835 } 00836 return $out; 00837 } 00838 00839 /** 00840 * Get HTML code for the pages which were mounted, but NOT readable! 00841 * 00842 * @return string HTML code. 00843 */ 00844 function ext_getReadableButNonmounted() { 00845 00846 // List of page id mounts which ARE mounted (and should therefore not be selected) 00847 if (!$this->ext_pageIdsFromMounts) { 00848 $this->ext_pageIdsFromMounts=0; 00849 } 00850 00851 // User and group names: 00852 $be_user_Array = t3lib_BEfunc::getUserNames(); 00853 $be_group_Array = t3lib_BEfunc::getGroupNames(); 00854 00855 // Create query: 00856 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 00857 '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':''), 00858 'pages', 00859 'uid NOT IN ('.$this->ext_pageIdsFromMounts.') AND '.$this->getPagePermsClause(1).t3lib_BEfunc::deleteClause('pages') 00860 ); 00861 $dat = array(); 00862 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00863 $dat[] = array( 00864 'row'=>$row, 00865 'HTML'=>t3lib_iconWorks::getSpriteIconForRecord('pages',$row,array('title'=>'['.$row['uid'].']')) 00866 ); 00867 } 00868 $pp = t3lib_div::makeInstance('printAllPageTree_perms', $this); 00869 return $pp->printTree($dat,1); 00870 } 00871 00872 /** 00873 * Print a set of permissions 00874 * 00875 * @param integer The permissions integer. 00876 * @return string HTML formatted. 00877 */ 00878 function ext_printPerms($int) { 00879 $str=''; 00880 $str.= (($int&1)?'*':'<font color="red">x</font>'); 00881 $str.= (($int&16)?'*':'<font color="red">x</font>'); 00882 $str.= (($int&2)?'*':'<font color="red">x</font>'); 00883 $str.= (($int&4)?'*':'<font color="red">x</font>'); 00884 $str.= (($int&8)?'*':'<font color="red">x</font>'); 00885 00886 return '<strong style="color:green;">'.$str.'</strong>'; 00887 } 00888 00889 /** 00890 * returns the permissions for a group based of the perms_groupid of $row. If the $row[perms_groupid] equals the $firstGroup[uid] then the function returns perms_everybody OR'ed with perms_group, else just perms_everybody 00891 * 00892 * @param array Page record. 00893 * @param array First-group record. 00894 * @return integer Permissions. 00895 */ 00896 function ext_groupPerms($row,$firstGroup) { 00897 if (is_array($row)) { 00898 $out=intval($row['perms_everybody']); 00899 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) { 00900 $out|= intval($row['perms_group']); 00901 } 00902 return $out; 00903 } 00904 } 00905 00906 /** 00907 * Creates uInfo array for the user. 00908 * 00909 * @param array Might contain array where keys/values indicate whether to render a certain value 00910 * @return array Array with the information of the user for each analysis topic. 00911 */ 00912 function ext_compileUserInfoForHash($filter=NULL) { 00913 $uInfo=array(); 00914 $renderAll = !is_array($filter); 00915 00916 // Filemounts: 00917 if ($renderAll || $filter['filemounts']) { 00918 $uInfo['filemounts'] = $this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts']))); 00919 } 00920 00921 // DBmounts: 00922 if ($renderAll || $filter['webmounts']) { 00923 $uInfo['webmounts'] = $this->ext_uniqueAndSortList($this->groupData['webmounts']); 00924 } 00925 00926 // Sharing Upload Folder 00927 if ($renderAll || $filter['tempPath']) { 00928 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00929 $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); 00930 $uInfo['tempPath'] = $fileProcessor->findTempFolder(); // The closest TEMP-path is found 00931 } 00932 00933 // First Main Group: 00934 if ($renderAll || $filter['firstMainGroup']) { 00935 $uInfo['firstMainGroup'] = $this->firstMainGroup; 00936 } 00937 00938 // Group List: 00939 if ($renderAll || $filter['groupList']) { 00940 $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. 00941 } 00942 00943 // Page Types: 00944 if ($renderAll || $filter['pagetypes_select']) { 00945 $uInfo['pagetypes_select'] = $this->ext_uniqueAndSortList($this->groupData['pagetypes_select']); 00946 } 00947 00948 // Tables select: 00949 if ($renderAll || $filter['tables_select']) { 00950 $uInfo['tables_select'] = $this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']); 00951 } 00952 00953 // Tables modify: 00954 if ($renderAll || $filter['tables_modify']) { 00955 $uInfo['tables_modify'] = $this->ext_uniqueAndSortList($this->groupData['tables_modify']); 00956 } 00957 00958 // Non-exclude fields: 00959 if ($renderAll || $filter['non_exclude_fields']) { 00960 $uInfo['non_exclude_fields'] = $this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']); 00961 } 00962 00963 // Explicit Allow/Deny: 00964 if ($renderAll || $filter['explicit_allowdeny']) { 00965 $uInfo['explicit_allowdeny'] = $this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']); 00966 } 00967 00968 // Limit to languages: 00969 if ($renderAll || $filter['allowed_languages']) { 00970 $uInfo['allowed_languages'] = $this->ext_uniqueAndSortList($this->groupData['allowed_languages']); 00971 } 00972 00973 // Workspace permissions 00974 if ($renderAll || $filter['workspace_perms']) { 00975 $uInfo['workspace_perms'] = $this->ext_uniqueAndSortList($this->groupData['workspace_perms']); 00976 } 00977 00978 // Workspace membership 00979 if ($renderAll || $filter['workspace_membership']) { 00980 $uInfo['workspace_membership'] = $this->ext_workspaceMembership(); 00981 } 00982 00983 // Custom options: 00984 if ($renderAll || $filter['custom_options']) { 00985 $uInfo['custom_options'] = $this->ext_uniqueAndSortList($this->groupData['custom_options']); 00986 } 00987 00988 // Modules: 00989 if ($renderAll || $filter['modules']) { 00990 $uInfo['modules'] = $this->ext_uniqueAndSortList($this->groupData['modules']); 00991 } 00992 00993 // User TS: 00994 $this->ext_ksortArrayRecursive($this->userTS); 00995 if ($renderAll || $filter['userTS']) { 00996 $uInfo['userTS'] = $this->userTS; 00997 } 00998 00999 if ($renderAll || $filter['userTS_hl']) { 01000 $uInfo['userTS_hl'] = $this->userTS_text; 01001 } 01002 01003 return $uInfo; 01004 } 01005 01006 /** 01007 * Sorts a commalist of values and removes duplicates. 01008 * 01009 * @param string Commalist. 01010 * @return string Sorted, unique commalist. 01011 */ 01012 function ext_uniqueAndSortList($list) { 01013 $uList=t3lib_div::trimExplode(',',$list,1); 01014 sort($uList); 01015 $uList=array_unique($uList); 01016 $uList=implode(',',$uList); 01017 return $uList; 01018 } 01019 01020 /** 01021 * Key sort input array recursively. 01022 * 01023 * @param array Multidimensional array (value by reference!) 01024 * @return void 01025 */ 01026 function ext_ksortArrayRecursive(&$arr) { 01027 krsort($arr); 01028 foreach ($arr as &$v) { 01029 if (is_array($v)) { 01030 $this->ext_ksortArrayRecursive($v); 01031 } 01032 } 01033 } 01034 01035 /** 01036 * Returns all workspaces that are accessible for the BE_USER 01037 * 01038 * @return array with key / value pairs of available workspaces (filtered by BE_USER check) 01039 */ 01040 function ext_workspaceMembership() { 01041 // Create accessible workspace arrays: 01042 $options = array(); 01043 if ($this->checkWorkspace(array('uid' => 0))) { 01044 $options[0] = '0: ' . $GLOBALS['LANG']->getLL('live', true); 01045 } 01046 if ($this->checkWorkspace(array('uid' => -1))) { 01047 $options[-1] = '-1: ' . $GLOBALS['LANG']->getLL('defaultDraft', true); 01048 } 01049 01050 // Add custom workspaces (selecting all, filtering by BE_USER check): 01051 if (t3lib_extMgm::isLoaded('workspaces')) { 01052 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers,db_mountpoints','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title'); 01053 if (count($workspaces)) { 01054 foreach ($workspaces as $rec) { 01055 if ($this->checkWorkspace($rec)) { 01056 $options[$rec['uid']] = $rec['uid'].': '.$rec['title']; 01057 01058 // Check if all mount points are accessible, otherwise show error: 01059 if (trim($rec['db_mountpoints'])!=='') { 01060 $mountPoints = t3lib_div::intExplode(',',$this->workspaceRec['db_mountpoints'],1); 01061 foreach ($mountPoints as $mpId) { 01062 if (!$this->isInWebMount($mpId,'1=1')) { 01063 $options[$rec['uid']].= '<br> \- ' . $GLOBALS['LANG']->getLL('notAccessible', true) . ' ' . $mpId; 01064 } 01065 } 01066 } 01067 } 01068 } 01069 } 01070 } 01071 01072 return $options; 01073 } 01074 } 01075 01076 01077 01078 01079 01080 01081 01082 01083 01084 01085 01086 01087 /** 01088 * Main script class 01089 * 01090 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 01091 * @package TYPO3 01092 * @subpackage tx_beuser 01093 */ 01094 class SC_mod_tools_be_user_index { 01095 var $MCONF=array(); 01096 var $MOD_MENU=array(); 01097 var $MOD_SETTINGS=array(); 01098 01099 /** 01100 * document emplate object 01101 * 01102 * @var noDoc 01103 */ 01104 var $doc; 01105 01106 var $include_once=array(); 01107 var $content; 01108 01109 01110 /** 01111 * Basic initialization of the class 01112 * 01113 * @return void 01114 */ 01115 function init() { 01116 $this->MCONF = $GLOBALS['MCONF']; 01117 01118 $this->menuConfig(); 01119 $this->switchUser(t3lib_div::_GP('SwitchUser')); 01120 01121 01122 // ************************** 01123 // Initializing 01124 // ************************** 01125 $this->doc = t3lib_div::makeInstance('template'); 01126 $this->doc->backPath = $GLOBALS['BACK_PATH']; 01127 $this->doc->setModuleTemplate('templates/beuser.html'); 01128 $this->doc->form = '<form action="" method="post">'; 01129 01130 // JavaScript 01131 $this->doc->JScode = $this->doc->wrapScriptTags(' 01132 script_ended = 0; 01133 function jumpToUrl(URL) { // 01134 window.location.href = URL; 01135 } 01136 ' . $this->doc->redirectUrls()); 01137 } 01138 01139 /** 01140 * Initialization of the module menu configuration 01141 * 01142 * @return void 01143 */ 01144 function menuConfig() { 01145 // MENU-ITEMS: 01146 // If array, then it's a selector box menu 01147 // If empty string it's just a variable, that'll be saved. 01148 // Values NOT in this array will not be saved in the settings-array for the module. 01149 $this->MOD_MENU = array( 01150 'function' => array( 01151 'compare' => $GLOBALS['LANG']->getLL('compareUserSettings', true), 01152 'whoisonline' => $GLOBALS['LANG']->getLL('listUsersOnline', true) 01153 ) 01154 ); 01155 // CLEAN SETTINGS 01156 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses'); 01157 } 01158 01159 /** 01160 * This functions builds the content of the page 01161 * 01162 * @return void 01163 */ 01164 function main() { 01165 $this->content=''; 01166 01167 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('backendUserAdministration', true)); 01168 $this->content.=$this->doc->spacer(5); 01169 01170 switch($this->MOD_SETTINGS['function']) { 01171 case 'compare': 01172 if (t3lib_div::_GP('ads')) { 01173 $compareFlags = t3lib_div::_GP('compareFlags'); 01174 $GLOBALS['BE_USER']->pushModuleData('tools_beuser/index.php/compare',$compareFlags); 01175 } else { 01176 $compareFlags = $GLOBALS['BE_USER']->getModuleData('tools_beuser/index.php/compare','ses'); 01177 } 01178 $this->content.=$this->compareUsers($compareFlags); 01179 break; 01180 case 'whoisonline': 01181 $this->content.=$this->whoIsOnline(); 01182 break; 01183 } 01184 // Setting up the buttons and markers for docheader 01185 $docHeaderButtons = $this->getButtons(); 01186 //$markers['CSH'] = $docHeaderButtons['csh']; 01187 $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']); 01188 $markers['CONTENT'] = $this->content; 01189 01190 // Build the <body> for the module 01191 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); 01192 // Renders the module page 01193 $this->content = $this->doc->render( 01194 'Backend User Administration', 01195 $this->content 01196 ); 01197 } 01198 01199 /** 01200 * Prints the content of the page 01201 * 01202 * @return void 01203 */ 01204 function printContent() { 01205 echo $this->content; 01206 } 01207 01208 /** 01209 * Create the panel of buttons for submitting the form or otherwise perform operations. 01210 * 01211 * @return array all available buttons as an assoc. array 01212 */ 01213 protected function getButtons() { 01214 01215 $buttons = array( 01216 'csh' => '', 01217 'shortcut' => '', 01218 'save' => '' 01219 ); 01220 // CSH 01221 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']); 01222 01223 // Shortcut 01224 if ($GLOBALS['BE_USER']->mayMakeShortcut()) { 01225 $buttons['shortcut'] = $this->doc->makeShortcutIcon('be_user_uid,compareFlags','function', $this->MCONF['name']); 01226 } 01227 01228 return $buttons; 01229 } 01230 01231 01232 01233 01234 01235 /*************************** 01236 * 01237 * OTHER FUNCTIONS: 01238 * 01239 ***************************/ 01240 01241 /** 01242 * Compares the users with the given flags 01243 * 01244 * @param array options that should be taking into account to compare the users 01245 * @return string the content 01246 */ 01247 function compareUsers($compareFlags) { 01248 // Menu: 01249 $options = array( 01250 'filemounts' => $GLOBALS['LANG']->getLL('filemounts', true), 01251 'webmounts' => $GLOBALS['LANG']->getLL('webmounts', true), 01252 'tempPath' => $GLOBALS['LANG']->getLL('defaultUploadPath', true), 01253 'firstMainGroup' => $GLOBALS['LANG']->getLL('mainUserGroup', true), 01254 'groupList' => $GLOBALS['LANG']->getLL('memberOfGroups', true), 01255 'pagetypes_select' => $GLOBALS['LANG']->getLL('pageTypesAccess', true), 01256 'tables_select' => $GLOBALS['LANG']->getLL('selectTables', true), 01257 'tables_modify' => $GLOBALS['LANG']->getLL('modifyTables', true), 01258 'non_exclude_fields' => $GLOBALS['LANG']->getLL('nonExcludeFields', true), 01259 'explicit_allowdeny' => $GLOBALS['LANG']->getLL('explicitAllowDeny', true), 01260 'allowed_languages' => $GLOBALS['LANG']->getLL('limitToLanguages', true), 01261 'workspace_perms' => $GLOBALS['LANG']->getLL('workspacePermissions', true), 01262 'workspace_membership' => $GLOBALS['LANG']->getLL('workspaceMembership', true), 01263 'custom_options' => $GLOBALS['LANG']->getLL('customOptions', true), 01264 'modules' => $GLOBALS['LANG']->getLL('modules', true), 01265 'userTS' => $GLOBALS['LANG']->getLL('tsconfig', true), 01266 'userTS_hl' => $GLOBALS['LANG']->getLL('tsconfigHL', true), 01267 ); 01268 01269 $be_user_uid = t3lib_div::_GP('be_user_uid'); 01270 if ($be_user_uid) { 01271 // This is used to test with other users. Development ONLY! 01272 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object 01273 $tempBE_USER->userTS_dontGetCached=1; 01274 $tempBE_USER->OS = TYPO3_OS; 01275 $tempBE_USER->setBeUserByUid($be_user_uid); 01276 $tempBE_USER->fetchGroupData(); 01277 01278 $uInfo = $tempBE_USER->ext_compileUserInfoForHash(); 01279 $uInfo_dat = $tempBE_USER->ext_printOverview($uInfo,$options,1); 01280 01281 $lines=array(); 01282 foreach ($options as $kk => $vv) { 01283 if ($kk=='modules') { 01284 $loadModules = t3lib_div::makeInstance('t3lib_loadModules'); 01285 $loadModules->load($GLOBALS['TBE_MODULES'],$tempBE_USER); 01286 $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions'); 01287 $uInfo_dat[$kk] = $alt_menuObj->topMenu($loadModules->modules,1,$GLOBALS['BACK_PATH']); 01288 } 01289 $lines[]='<tr class="bgColor4"> 01290 <td nowrap="nowrap" valign="top">'.$vv.': </td> 01291 <td>'.$uInfo_dat[$kk].' </td> 01292 </tr>'; 01293 01294 if ($kk=='webmounts' && !$tempBE_USER->isAdmin()) { 01295 $lines[]='<tr class="bgColor4"> 01296 <td nowrap="nowrap" valign="top">' . $GLOBALS['LANG']->getLL('nonMountedReadablePages', true) . ' </td> 01297 <td>'.$tempBE_USER->ext_getReadableButNonmounted().' </td> 01298 </tr>'; 01299 } 01300 } 01301 01302 $email = htmlspecialchars($tempBE_USER->user['email']); 01303 $realname = htmlspecialchars($tempBE_USER->user['realName']); 01304 $outTable = '<table border="0" cellpadding="1" cellspacing="1"><tr class="bgColor5"><td>'.t3lib_iconWorks::getSpriteIconForRecord('be_users',$tempBE_USER->user,array('title'=>$tempBE_USER->user['uid'])).htmlspecialchars($tempBE_USER->user['username']).'</td>'; 01305 $outTable.= '<td>'.($realname?$realname.', ':'').($email ? '<a href="mailto:'.$email.'">'.$email.'</a>' : '').'</td>'; 01306 $outTable.= '<td>'.$this->elementLinks('be_users',$tempBE_USER->user).'</td></tr></table>'; 01307 $outTable.= '<strong><a href="'.htmlspecialchars($this->MCONF['_']).'">' . $GLOBALS['LANG']->getLL('backToOverview', true) . '</a></strong><br />'; 01308 01309 $outTable.= '<br /><table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>'; 01310 $content.= $this->doc->section($GLOBALS['LANG']->getLL('userInfo', true),$outTable,0,1); 01311 } else { 01312 $menu = array(0 => array()); 01313 $rowCounter = 0; 01314 $columnCounter = 0; 01315 $itemsPerColumn = ceil(count($options) / 3); 01316 foreach ($options as $kk => $vv) { 01317 if ($rowCounter == $itemsPerColumn) { 01318 $rowCounter = 0; 01319 $columnCounter++; 01320 $menu[$columnCounter] = array(); 01321 } 01322 $rowCounter++; 01323 $menu[$columnCounter][]='<input type="checkbox" class="checkbox" value="1" name="compareFlags['.$kk.']" id="checkCompare_'.$kk.'"'.($compareFlags[$kk]?' checked="checked"':'').'> <label for="checkCompare_'.$kk.'">'.htmlspecialchars($vv).'</label>'; 01324 } 01325 $outCode = '<p>' . $GLOBALS['LANG']->getLL('groupBy', true) . '</p>'; 01326 $outCode .= '<table border="0" cellpadding="3" cellspacing="1" class="compare-checklist valign-top"><tr>'; 01327 foreach ($menu as $column) { 01328 $outCode .= '<td>' . implode('<br />', $column) . '</td>'; 01329 } 01330 $outCode .= '</tr></table>'; 01331 $outCode.='<br /><input type="submit" name="ads" value="' . $GLOBALS['LANG']->getLL('update', true) . '">'; 01332 $content = $this->doc->section($GLOBALS['LANG']->getLL('groupAndCompareUsers', true),$outCode,0,1); 01333 01334 01335 // Traverse all users 01336 $users = t3lib_BEfunc::getUserNames(); 01337 $comparation=array(); 01338 $counter=0; 01339 01340 01341 $offset=0; 01342 $numberAtTime=1000; 01343 $tooManyUsers=''; 01344 01345 foreach ($users as $r) { 01346 if ($counter>=$offset) { 01347 // This is used to test with other users. Development ONLY! 01348 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object 01349 /* @var $tempBE_USER local_beUserAuth */ 01350 $tempBE_USER->OS = TYPO3_OS; 01351 $tempBE_USER->setBeUserByUid($r['uid']); 01352 $tempBE_USER->fetchGroupData(); 01353 01354 // Making group data 01355 $md5pre=''; 01356 $menu=array(); 01357 $uInfo = $tempBE_USER->ext_compileUserInfoForHash((array)$compareFlags); 01358 foreach ($options as $kk => $vv) { 01359 if ($compareFlags[$kk]) { 01360 $md5pre.=serialize($uInfo[$kk]).'|'; 01361 } 01362 } 01363 // setting md5: 01364 $md5=md5($md5pre); 01365 if (!isset($comparation[$md5])) { 01366 $comparation[$md5]=$tempBE_USER->ext_printOverview($uInfo,$compareFlags); 01367 $comparation[$md5]['users']=array(); 01368 } 01369 $comparation[$md5]['users'][]=$tempBE_USER->user; 01370 unset($tempBE_USER); 01371 } 01372 $counter++; 01373 if ($counter>=($numberAtTime+$offset)) { 01374 $tooManyUsers=$GLOBALS['LANG']->getLL('tooManyUsers', true) . ' ' . count($users) . '. ' . $GLOBALS['LANG']->getLL('canOnlyDisplay', true) . ' ' . $numberAtTime . '.'; 01375 break; 01376 } 01377 } 01378 01379 // Print the groups: 01380 $allGroups=array(); 01381 // Header: 01382 $allCells = array(); 01383 01384 $link_createNewUser='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[be_users][0]=new',$this->doc->backPath,-1)).'" title="' . $GLOBALS['LANG']->getLL('newUser', true) . '">'. 01385 t3lib_iconWorks::getSpriteIcon('actions-document-new') . 01386 '</a>'; 01387 01388 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><strong>' . $GLOBALS['LANG']->getLL('usernames', TRUE) . '</strong></td><td width="12">' . $link_createNewUser . '</td></tr></table>'; 01389 01390 foreach ($options as $kk => $vv) { 01391 if ($compareFlags[$kk]) { 01392 $allCells[$kk] = '<strong>'.$vv.':</strong>'; 01393 } 01394 } 01395 $allGroups[]=$allCells; 01396 01397 foreach ($comparation as $dat) { 01398 $allCells = array(); 01399 01400 $curUid = $GLOBALS['BE_USER']->user['uid']; 01401 $uListArr=array(); 01402 01403 foreach ($dat['users'] as $uDat) { 01404 $uItem = '<tr><td width="130">' . t3lib_iconWorks::getSpriteIconForRecord('be_users',$uDat,array('title'=> $uDat['uid'] )) . $this->linkUser($uDat['username'],$uDat) . ' </td><td nowrap="nowrap">' . $this->elementLinks('be_users',$uDat); 01405 if ($curUid != $uDat['uid'] && !$uDat['disable'] && ($uDat['starttime'] == 0 || 01406 $uDat['starttime'] < $GLOBALS['EXEC_TIME']) && ($uDat['endtime'] == 0 || 01407 $uDat['endtime'] > $GLOBALS['EXEC_TIME'])) { 01408 $uItem .= '<a href="' . t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'])) . '" target="_top" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('switchUserTo', true) . ' ' . $uDat['username']) . ' ' . $GLOBALS['LANG']->getLL('changeToMode', TRUE) . '">' . 01409 t3lib_iconWorks::getSpriteIcon('actions-system-backend-user-switch') . 01410 '</a>'. 01411 '<a href="' . t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'], 'switchBackUser' => 1)) . '" target="_top" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('switchUserTo', true) . ' ' . $uDat['username']) . ' ' . $GLOBALS['LANG']->getLL('switchBackMode', TRUE) . '">' . 01412 t3lib_iconWorks::getSpriteIcon('actions-system-backend-user-emulate') . 01413 '</a>'; 01414 } 01415 $uItem .= '</td></tr>'; 01416 $uListArr[] = $uItem; 01417 } 01418 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>'; 01419 01420 foreach ($options as $kk => $vv) { 01421 if ($compareFlags[$kk]) { 01422 $allCells[$kk] = $dat[$kk]; 01423 } 01424 } 01425 $allGroups[]=$allCells; 01426 } 01427 01428 // Make table 01429 $outTable=''; 01430 $TDparams=' nowrap="nowrap" class="bgColor5" valign="top"'; 01431 $i = 0; 01432 foreach ($allGroups as $allCells) { 01433 $outTable.='<tr><td'.$TDparams.'>'.implode('</td><td'.$TDparams.'>',$allCells).'</td></tr>'; 01434 $TDparams=' nowrap="nowrap" class="'.($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6').'" valign="top"'; 01435 } 01436 $outTable='<table border="0" cellpadding="2" cellspacing="2">' . $outTable . '</table>'; 01437 $outTable .= '<br /><br />' . $GLOBALS['LANG']->getLL('cachedGrouplistsUpdated', true); 01438 $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">' . $tooManyUsers . '</span></strong>':''; 01439 $content.= $this->doc->spacer(10); 01440 $content.= $this->doc->section($GLOBALS['LANG']->getLL('result', true),$outTable,0,1); 01441 } 01442 return $content; 01443 } 01444 01445 01446 /** 01447 * Creates a HTML anchor to the user record 01448 * 01449 * @param string the string used to identify the user (inside the <a>...</a>) 01450 * @param array the BE user record to link 01451 * @return string the HTML anchor 01452 */ 01453 function linkUser($str,$rec) { 01454 return '<a href="'.htmlspecialchars($this->MCONF['_']).'&be_user_uid='.$rec['uid'].'">' . htmlspecialchars($str) . '</a>'; 01455 } 01456 01457 01458 /** 01459 * Builds a list of all links for a specific element (here: BE user) and returns it for print. 01460 * 01461 * @param string the db table that should be used 01462 * @param array the BE user record to use 01463 * @return string a HTML formatted list of the link 01464 */ 01465 function elementLinks($table,$row) { 01466 // Info: 01467 $cells[]='<a href="#" onclick="top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\',\'' . $GLOBALS['BACK_PATH'] . '\'); return false;" title="' . $GLOBALS['LANG']->getLL('showInformation', TRUE) . '">' . 01468 t3lib_iconWorks::getSpriteIcon('actions-document-info') . 01469 '</a>'; 01470 01471 // Edit: 01472 $params='&edit[' . $table . '][' . $row['uid'] . ']=edit'; 01473 $cells[]='<a href="#" onclick="' . t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'],'') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit', TRUE) . '">' . 01474 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 01475 '</a>'; 01476 01477 // Hide: 01478 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']; 01479 if ($row[$hiddenField]) { 01480 $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=0'; 01481 $cells[]='<a href="' . $this->doc->issueCommand($params) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:enable', TRUE) . '">' . 01482 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') . 01483 '</a>'; 01484 } else { 01485 $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=1'; 01486 $cells[]='<a href="' . $this->doc->issueCommand($params) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disable', true) . '">' . 01487 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') . 01488 '</a>'; 01489 } 01490 01491 // Delete 01492 $params='&cmd[' . $table . '][' . $row['uid'] . '][delete]=1'; 01493 $cells[]='<a href="' . $this->doc->issueCommand($params) . '" onclick="return confirm(unescape(\'' . $GLOBALS['LANG']->getLL('sureToDelete', TRUE) . '\'));" title="' . $GLOBALS['LANG']->getLL('delete', TRUE) . '">' . 01494 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') . 01495 '</a>'; 01496 01497 return implode('',$cells); 01498 } 01499 01500 01501 /** 01502 * Inits all BE-users available, for development ONLY! 01503 * 01504 * @return void 01505 */ 01506 function initUsers() { 01507 // Initializing all users in order to generate the usergroup_cached_list 01508 $users = t3lib_BEfunc::getUserNames(); 01509 01510 // This is used to test with other users. Development ONLY! 01511 foreach ($users as $r) { 01512 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object 01513 /* @var $tempBE_USER local_beUserAuth */ 01514 $tempBE_USER->OS = TYPO3_OS; 01515 $tempBE_USER->setBeUserByUid($r['uid']); 01516 $tempBE_USER->fetchGroupData(); 01517 } 01518 } 01519 01520 /** 01521 * Returns the local path for this string (removes the PATH_site if it is included) 01522 * 01523 * @param string the path that will be checked 01524 * @return string the local path 01525 */ 01526 function localPath($str) { 01527 if (substr($str,0,strlen(PATH_site))==PATH_site) { 01528 return substr($str,strlen(PATH_site)); 01529 } else { 01530 return $str; 01531 } 01532 } 01533 01534 /** 01535 * Switches to a given user (SU-mode) and then redirects to the start page of the backend to refresh the navigation etc. 01536 * 01537 * @param array BE-user record that will be switched to 01538 * @return void 01539 */ 01540 function switchUser($switchUser) { 01541 $uRec=t3lib_BEfunc::getRecord('be_users',$switchUser); 01542 if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin()) { 01543 $updateData['ses_userid'] = $uRec['uid']; 01544 // user switchback 01545 if (t3lib_div::_GP('switchBackUser')) { 01546 $updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']); 01547 } 01548 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions').' AND ses_name=\'be_typo_user\' AND ses_userid='.intval($GLOBALS['BE_USER']->user['uid']),$updateData); 01549 01550 $redirectUrl = $GLOBALS['BACK_PATH'] . 'index.php' . ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] ? '' : '?commandLI=1'); 01551 t3lib_utility_Http::redirect($redirectUrl); 01552 } 01553 } 01554 01555 /*************************** 01556 * 01557 * "WHO IS ONLINE" FUNCTIONS: 01558 * 01559 ***************************/ 01560 01561 /** 01562 * @author Martin Kutschker 01563 */ 01564 function whoIsOnline() { 01565 $select_fields = 'ses_id, ses_tstamp, ses_iplock, u.uid,u.username, u.admin, u.realName, u.disable, u.starttime, u.endtime, u.deleted, bu.uid AS bu_uid,bu.username AS bu_username, bu.realName AS bu_realName'; 01566 $from_table = 'be_sessions INNER JOIN be_users u ON ses_userid=u.uid LEFT OUTER JOIN be_users bu ON ses_backuserid=bu.uid'; 01567 $where_clause = ''; 01568 $orderBy = 'u.username'; 01569 01570 if (t3lib_div::testInt($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'])) { 01571 $where_clause .= 'ses_tstamp+' . $GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'] . ' > ' . $GLOBALS['EXEC_TIME']; 01572 } else { 01573 $timeout = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']); 01574 if ($timeout > 0) { 01575 $where_clause .= 'ses_tstamp+' . $timeout . ' > ' . $GLOBALS['EXEC_TIME']; 01576 } 01577 } 01578 // Fetch active sessions of other users from storage: 01579 $sessions = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select_fields,$from_table,$where_clause,'',$orderBy); 01580 // Process and visualized each active session as a table row: 01581 if (is_array($sessions)) { 01582 foreach ($sessions as $session) { 01583 $ip = $session['ses_iplock']; 01584 $hostName = ''; 01585 if ($session['ses_iplock'] == '[DISABLED]' || $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 0) { 01586 $ip = '-'; 01587 } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 4) { 01588 $hostName = ' title="' . @gethostbyaddr($session['ses_iplock']) . '"'; 01589 } else { 01590 $ip .= str_repeat('.*', 4-$GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP']); 01591 } 01592 $outTable .= ' 01593 <tr class="bgColor4" height="17" valign="top">' . 01594 '<td nowrap="nowrap">' . 01595 date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $session['ses_tstamp']) . 01596 '</td>' . 01597 '<td nowrap="nowrap">' . 01598 '<span'.$hostName.'>'.$ip.'</span>' . 01599 '</td>' . 01600 '<td width="130">' . 01601 t3lib_iconWorks::getSpriteIconForRecord('be_users',$session,array('title'=>$session['uid'])).htmlspecialchars($session['username']).' ' . 01602 '</td>' . 01603 '<td nowrap="nowrap">'.htmlspecialchars($session['realName']).' </td>' . 01604 '<td nowrap="nowrap">'.$this->elementLinks('be_users',$session).'</td>' . 01605 '<td nowrap="nowrap" valign="top">'.($session['bu_username'] ? ' SU from: ' : '').htmlspecialchars($session['bu_username']).' </td>' . 01606 '<td nowrap="nowrap" valign="top"> '.htmlspecialchars($session['bu_realName']).'</td>' . 01607 '</tr>'; 01608 } 01609 } 01610 // Wrap <table> tag around the rows: 01611 $outTable = ' 01612 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist"> 01613 <tr class="t3-row-header"> 01614 <td>' . $GLOBALS['LANG']->getLL('timestamp', true) . '</td> 01615 <td>' . $GLOBALS['LANG']->getLL('host', true) . '</td> 01616 <td colspan="5">' . $GLOBALS['LANG']->getLL('username', true) . '</td> 01617 </tr>' . $outTable . ' 01618 </table>'; 01619 01620 $content.= $this->doc->section($GLOBALS['LANG']->getLL('whoIsOnline', true),$outTable,0,1); 01621 return $content; 01622 } 01623 01624 } 01625 01626 01627 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php'])) { 01628 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']); 01629 } 01630 01631 01632 // Make instance: 01633 $SOBE = t3lib_div::makeInstance('SC_mod_tools_be_user_index'); 01634 $SOBE->init(); 01635 $SOBE->main(); 01636 $SOBE->printContent(); 01637 01638 ?>
1.8.0