Documentation TYPO3 par Ameos

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2007 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 ***************************************************************/
00103 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00104 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
00105 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
00106 require_once (PATH_t3lib.'class.t3lib_tstemplate.php');
00107 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
00108 require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php');
00109 require_once (PATH_typo3.'class.alt_menu_functions.inc');
00110 
00111 $BE_USER->modAccess($MCONF,1);
00112 
00113 
00114 
00115 
00116 
00117 
00125  class localPageTree extends t3lib_browseTree {
00126         var $expandFirst=0;
00127         var $expandAll=0;
00128 
00136         function localPageTree($BE_USER,$WEBMOUNTS='')  {
00137                 $this->init();
00138 
00139                 $this->BE_USER = $BE_USER;
00140                 $this->MOUNTS = $WEBMOUNTS;
00141                 $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.
00142                 $this->orderByFields = 'sorting';
00143         }
00144 
00150         function ext_permsC()   {
00151                 return '';
00152         }
00153 
00161         function wrapTitle($str,$row)   {
00162                 return $str;
00163         }
00164 
00173         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00174                 return '';
00175         }
00176 
00184         function wrapIcon($icon,$row)   {
00185                         // Add title attribute to input icon tag
00186                 $title = '['.$row['uid'].'] '.t3lib_BEfunc::getRecordPath($row['uid'],'',15);
00187                 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"');
00188 
00189                 return $theIcon;
00190         }
00191 
00197         function initializePositionSaving()     {
00198                 $this->stored=array();
00199         }
00200 }
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00218 class printAllPageTree extends localPageTree {
00219         var $expandFirst=1;
00220         var $expandAll=1;
00221 
00227         function ext_permsC()   {
00228                 return ' AND '.$this->BE_USER->getPagePermsClause(1);
00229         }
00230 
00239         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00240                 return $icon;
00241         }
00242 
00250         function wrapIcon($icon,$row)   {
00251                         // Add title attribute to input icon tag
00252                 $title = '['.$row['uid'].']';
00253                 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"');
00254 
00255                 return $theIcon;
00256         }
00257 }
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00275 class printAllPageTree_perms extends printAllPageTree {
00276 
00284         function printTree($treeArr='',$printPath=0)    {
00285                 $titleLen=intval($this->BE_USER->uc['titleLen']);
00286 
00287                 $be_user_Array = t3lib_BEfunc::getUserNames();
00288                 $be_group_Array = t3lib_BEfunc::getGroupNames();
00289                 $lines=array();
00290                 $lines[]='<tr class="bgColor5">
00291                         <td nowrap="nowrap"><strong>Page title:</strong></td>
00292                         '.($printPath?'<td nowrap="nowrap"><strong>Path:</strong></td>':'').'
00293                         <td nowrap="nowrap" colspan=2><strong>User:</strong></td>
00294                         <td nowrap="nowrap" colspan=2><strong>Group: &nbsp;</strong></td>
00295                         <td nowrap="nowrap"><strong>Everybody: &nbsp;</strong></td>
00296                         <td nowrap="nowrap"><strong>This user: &nbsp;</strong></td>
00297                         <td nowrap="nowrap"><strong>Main group:</strong></td>
00298                 </tr>';
00299 
00300                 if (!is_array($treeArr))        $treeArr=$this->tree;
00301                 reset($treeArr);
00302                 while(list($k,$v)=each($treeArr))       {
00303                         $col1 = ' bgcolor="'.t3lib_div::modifyHtmlColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"';
00304                         $row = $v['row'];
00305                         $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$this->BE_USER->uc['titleLen']));
00306                         $lines[]='<tr class="bgColor4">
00307                                 <td nowrap="nowrap">'.$v['HTML'].$title.' &nbsp;</td>
00308                                 '.($printPath?'<td nowrap="nowrap">'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row['pid'],'',15)).' &nbsp;</td>':'').'
00309                                 <td nowrap="nowrap"'.$col1.'>'.$be_user_Array[$row['perms_userid']]['username'].' &nbsp;</td>
00310                                 <td nowrap="nowrap"'.$col1.'>'.$this->ext_printPerms($row['perms_user']).' &nbsp;</td>
00311                                 <td nowrap="nowrap">'.$be_group_Array[$row['perms_groupid']]['title'].' &nbsp;</td>
00312                                 <td nowrap="nowrap">'.$this->ext_printPerms($row['perms_group']).' &nbsp;</td>
00313                                 <td nowrap="nowrap" align="center" '.$col1.'>'.$this->ext_printPerms($row['perms_everybody']).' &nbsp;</td>
00314                                 <td nowrap="nowrap" align="center">'.($row['editlock'] ? '<img '.t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning2.gif').' title="Edit lock prevents all editing" alt="" />' : $this->ext_printPerms($this->BE_USER->calcPerms($row))).' &nbsp;</td>
00315                                 <td nowrap="nowrap" align="center">'.$this->ext_printPerms($this->ext_groupPerms($row,$be_group_Array[$this->BE_USER->firstMainGroup])).' &nbsp;</td>
00316                         </tr>';
00317                 }
00318                 return '<table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table>';
00319         }
00320 
00327         function ext_printPerms($int)   {
00328                 $str='';
00329                 $str.= (($int&1)?'*':'<font color="red">x</font>');
00330                 $str.= (($int&16)?'*':'<font color="red">x</font>');
00331                 $str.= (($int&2)?'*':'<font color="red">x</font>');
00332                 $str.= (($int&4)?'*':'<font color="red">x</font>');
00333                 $str.= (($int&8)?'*':'<font color="red">x</font>');
00334 
00335                 return '<b><font color="green">'.$str.'</font></b>';
00336         }
00337 
00345         function ext_groupPerms($row,$firstGroup)       {
00346                 if (is_array($row))     {
00347                         $out=intval($row['perms_everybody']);
00348                         if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
00349                                 $out|= intval($row['perms_group']);
00350                         }
00351                         return $out;
00352                 }
00353         }
00354 }
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00373  class localFolderTree extends t3lib_folderTree {
00374         var $expandFirst=0;
00375         var $expandAll=0;
00376 
00384         function localFolderTree($BE_USER,$FILEMOUNTS='')       {
00385                 $this->init();
00386 
00387                 $this->BE_USER = $BE_USER;
00388                 $this->MOUNTS = $FILEMOUNTS;
00389                 $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.
00390         }
00391 
00399         function wrapTitle($str,$row)   {
00400                 return $str;
00401         }
00402 
00411         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00412                 return '';
00413         }
00414 
00422         function wrapIcon($icon,$row)   {
00423                         // Add title attribute to input icon tag
00424                 $title = $GLOBALS['SOBE']->localPath($row['path']);
00425                 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : ''));
00426 
00427                 return $theIcon;
00428         }
00429 
00435         function initializePositionSaving()     {
00436                 $this->stored=array();
00437         }
00438 }
00439 
00440 
00441 
00442 
00443 
00444 
00445 
00446 
00447 
00448 
00449 
00450 
00451 
00459 class printAllFolderTree extends localFolderTree {
00460         var $expandFirst=1;
00461         var $expandAll=1;
00462 
00471         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00472                 return $icon;
00473         }
00474 }
00475 
00476 
00477 
00478 
00479 
00480 
00481 
00482 
00483 
00484 
00485 
00493 class local_beUserAuth extends t3lib_beUserAuth {
00494         var $ext_pageIdsFromMounts='';                                  // List of mounted page ids (from browsetree class when selecting mountpoints)
00495         var $ext_non_readAccessPageArray=array();               // Storage for non-readable webmounts, see returnWebmounts()
00496 
00505         function returnWebmounts($pClause='')   {
00506 
00507                         // Get array of webmounts:
00508                 $webmounts = (string)($this->groupData['webmounts'])!='' ? explode(',',$this->groupData['webmounts']) : Array();
00509 
00510                         // Get select clause:
00511                 $pClause=$pClause?$pClause:$this->getPagePermsClause(1);
00512 
00513                         // Traverse mounts, check if they are readable:
00514                 foreach($webmounts as $k => $id)        {
00515                         $rec=t3lib_BEfunc::getRecord('pages',$id,'*',' AND '.$pClause);
00516                         if (!is_array($rec))    {
00517                                 $this->ext_non_readAccessPageArray[$id]=t3lib_BEfunc::getRecord('pages',$id);
00518                                 unset($webmounts[$k]);
00519                         }
00520                 }
00521                 return $webmounts;
00522         }
00523 
00529         function ext_non_readAccessPages()      {
00530                 $lines=array();
00531 
00532                 foreach($this->ext_non_readAccessPageArray as $pA)      {
00533                         if ($pA)        $lines[]=t3lib_BEfunc::getRecordPath($pA['uid'],'',15);
00534                 }
00535                 if (count($lines))      {
00536                         return '<table bgcolor="red" border="0" cellpadding="0" cellspacing="0">
00537                                 <tr>
00538                                         <td align="center"><font color="white"><strong>The user has no read access to these DB-mounts!</strong></font></td>
00539                                 </tr>
00540                                 <tr>
00541                                         <td>'.implode('</td></tr><tr><td>',$lines).'</td>
00542                                 </tr>
00543                         </table>';
00544                 }
00545         }
00546 
00552         function user_where_clause()    {
00553                 return  'AND pid=0 ';
00554         }
00555 
00564         function ext_printOverview($uInfo,$compareFlags,$printTrees=0)  {
00565                         // Prepare for filemount and db-mount
00566                 if ($printTrees)        {       // ... this is if we see the detailed view for a user:
00567                                 // Page tree object:
00568                         $className=t3lib_div::makeInstanceClassName(!$this->isAdmin() ? 'printAllPageTree_perms' : 'printAllPageTree');
00569                         $pagetree = new $className($this,$this->returnWebmounts());     // Here, only readable webmounts are returned (1=1)
00570                         $pagetree->addField('perms_user',1);
00571                         $pagetree->addField('perms_group',1);
00572                         $pagetree->addField('perms_everybody',1);
00573                         $pagetree->addField('perms_userid',1);
00574                         $pagetree->addField('perms_groupid',1);
00575                         $pagetree->addField('editlock',1);
00576 
00577                                 // Folder tree object:
00578                         $className=t3lib_div::makeInstanceClassName('printAllFolderTree');
00579                         $foldertree = new $className($this,$this->returnFilemounts());
00580                 } else {
00581                                 // Page tree object:
00582                         $className=t3lib_div::makeInstanceClassName('localPageTree');
00583                         $pagetree = new $className($this,$this->returnWebmounts('1=1'));        // Here, ALL webmounts are returned (1=1)
00584 
00585                                 // Folder tree object:
00586                         $className=t3lib_div::makeInstanceClassName('localFolderTree');
00587                         $foldertree = new $className($this,$this->returnFilemounts());
00588                 }
00589 
00590                         // Names for modules:
00591                 $modNames = array(
00592                         'web' => 'Web',
00593                         'web_layout' => 'Page',
00594                         'web_modules' => 'Modules',
00595                         'web_info' => 'Info',
00596                         'web_perms' => 'Access',
00597                         'web_func' => 'Func',
00598                         'web_list' => 'List',
00599                         'web_ts' => 'Template',
00600                         'file' => 'File',
00601                         'file_list' => 'List',
00602                         'file_images' => 'Images',
00603                         'doc' => 'Doc.',
00604                         'help' => 'Help',
00605                         'help_about' => 'About',
00606                         'help_quick' => 'User manual',
00607                         'help_welcome' => 'Welcome',
00608                         'user' => 'User',
00609                         'user_setup' => 'Setup',
00610                         'user_task' => 'Task center'
00611                 );
00612 
00613                         // Traverse the enabled analysis topics:
00614                 $out=array();
00615                 foreach($uInfo as $k => $v)     {
00616                         if ($compareFlags[$k])  {
00617                                 switch($k)      {
00618                                         case 'filemounts':
00619                                                 $out[$k] = $foldertree->getBrowsableTree();
00620                                         break;
00621                                         case 'webmounts':
00622                                                         // Print webmounts:
00623                                                 $pagetree->addSelfId=1;
00624                                                 $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)
00625                                                 $out[$k].= $pagetree->getBrowsableTree();               // Add HTML for readable webmounts.
00626                                                 $this->ext_pageIdsFromMounts=implode(',',array_unique($pagetree->ids));         // List of mounted page ids
00627                                         break;
00628                                         case 'tempPath':
00629                                                 $out[$k] = $GLOBALS['SOBE']->localPath($v);
00630                                         break;
00631                                         case 'pagetypes_select':
00632                                                 $pageTypes = explode(',',$v);
00633                                                 reset($pageTypes);
00634                                                 while(list($kk,$vv)=each($pageTypes))   {
00635                                                         $pageTypes[$kk]=$GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('pages','doktype',$vv));
00636                                                 }
00637                                                 $out[$k] = implode('<br />',$pageTypes);
00638                                         break;
00639                                         case 'tables_select':
00640                                         case 'tables_modify':
00641                                                 $tables = explode(',',$v);
00642                                                 reset($tables);
00643                                                 while(list($kk,$vv)=each($tables))      {
00644                                                         if ($vv)        {
00645                                                                 $tables[$kk]='<span class="nobr">'.t3lib_iconWorks::getIconImage($vv,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>';
00646                                                         }
00647                                                 }
00648                                                 $out[$k] = implode('<br />',$tables);
00649                                         break;
00650                                         case 'non_exclude_fields':
00651                                                 $nef = explode(',',$v);
00652                                                 reset($nef);
00653                                                 $table='';
00654                                                 $pout=array();
00655                                                 while(list($kk,$vv)=each($nef)) {
00656                                                         if ($vv)        {
00657                                                                 list($thisTable,$field) = explode(':',$vv);
00658                                                                 if ($thisTable!=$table) {
00659                                                                         $table=$thisTable;
00660                                                                         t3lib_div::loadTCA($table);
00661                                                                         $pout[]='<span class="nobr">'.t3lib_iconWorks::getIconImage($table,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']).'</span>';
00662                                                                 }
00663                                                                 if ($GLOBALS['TCA'][$table]['columns'][$field]) {
00664                                                                         $pout[]='<span class="nobr"> - '.ereg_replace(':$','',$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label'])).'</span>';
00665                                                                 }
00666                                                         }
00667                                                 }
00668                                                 $out[$k] = implode('<br />',$pout);
00669                                         break;
00670                                         case 'groupList':
00671                                         case 'firstMainGroup':
00672                                                 $uGroups = explode(',',$v);
00673                                                 reset($uGroups);
00674                                                 $table='';
00675                                                 $pout=array();
00676                                                 while(list($kk,$vv)=each($uGroups))     {
00677                                                         if ($vv)        {
00678                                                                 $uGRow = t3lib_BEfunc::getRecord('be_groups',$vv);
00679                                                                 $pout[]='<tr><td nowrap="nowrap">'.t3lib_iconWorks::getIconImage('be_groups',$uGRow,$GLOBALS['BACK_PATH'],'align="top"').'&nbsp;'.htmlspecialchars($uGRow['title']).'&nbsp;&nbsp;</td><td width=1% nowrap="nowrap">'.$GLOBALS['SOBE']->elementLinks('be_groups',$uGRow).'</td></tr>';
00680                                                         }
00681                                                 }
00682                                                 $out[$k] = '<table border="0" cellpadding="0" cellspacing="0" width="100%">'.implode('',$pout).'</table>';
00683                                         break;
00684                                         case 'modules':
00685                                                 $mods = explode(',',$v);
00686                                                 reset($mods);
00687                                                 $mainMod='';
00688                                                 $pout=array();
00689                                                 while(list($kk,$vv)=each($mods))        {
00690                                                         if ($vv)        {
00691                                                                 list($thisMod,$subMod) = explode('_',$vv);
00692                                                                 if ($thisMod!=$mainMod) {
00693                                                                         $mainMod=$thisMod;
00694                                                                         $pout[]='<span class="nobr">'.($modNames[$mainMod]?$modNames[$mainMod]:$mainMod).'</span>';
00695                                                                 }
00696                                                                 if ($subMod)    {
00697                                                                         $pout[]='<span class="nobr"> - '.($modNames[$mainMod.'_'.$subMod]?$modNames[$mainMod.'_'.$subMod]:$mainMod.'_'.$subMod).'</span>';
00698                                                                 }
00699                                                         }
00700                                                 }
00701                                                 $out[$k] = implode('<br />',$pout);
00702                                         break;
00703                                         case 'userTS':
00704 
00705                                                 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext');  // Defined global here!
00706                                                 $tmpl->tt_track = 0;    // Do not log time-performance information
00707 
00708                                                 $tmpl->fixedLgd=0;
00709                                                 $tmpl->linkObjects=0;
00710                                                 $tmpl->bType='';
00711                                                 $tmpl->ext_expandAllNotes=1;
00712                                                 $tmpl->ext_noPMicons=1;
00713                                                 $out[$k] = $tmpl->ext_getObjTree($v,'','','','','1');
00714                                         break;
00715                                         case 'userTS_hl':
00716                                                 $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
00717                                                 $tsparser->lineNumberOffset=0;
00718                                                 $out[$k] = $tsparser->doSyntaxHighlight($v,0,1);
00719                                         break;
00720                                         case 'explicit_allowdeny':
00721 
00722                                                         // Explode and flip values:
00723                                                 $nef = array_flip(explode(',',$v));
00724                                                 $pout = array();
00725 
00726                                                 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
00727 
00728                                                                 // Icons:
00729                                                 $icons = array(
00730                                                         'ALLOW' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_ok2.gif','').' class="absmiddle" alt="" />',
00731                                                         'DENY' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_fatalerror.gif','').' class="absmiddle" alt="" />',
00732                                                 );
00733 
00734                                                         // Traverse types:
00735                                                 foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
00736                                                         if (is_array($theTypeArrays['items']))  {
00737                                                                 $pout[] = '<b>'.$theTypeArrays['tableFieldLabel'].'</b>';
00738                                                                         // Traverse options for this field:
00739                                                                 foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
00740                                                                         $v = $tableFieldKey.':'.$itemValue.':'.$itemContent[0];
00741                                                                         if (isset($nef[$v]))    {
00742                                                                                 unset($nef[$v]);
00743                                                                                 $pout[] = $icons[$itemContent[0]].'['.$itemContent[2].'] '.$itemContent[1];
00744                                                                         } else {
00745                                                                                 $pout[] = '<em style="color: #666666;">'.$icons[($itemContent[0]=='ALLOW' ? 'DENY' : 'ALLOW')].'['.$itemContent[2].'] '.$itemContent[1].'</em>';
00746                                                                         }
00747                                                                 }
00748                                                                 $pout[] = '';
00749                                                         }
00750                                                 }
00751 
00752                                                         // Add remaining:
00753                                                 if (count($nef))        {
00754                                                         $pout = array_merge($pout, array_keys($nef));
00755                                                 }
00756 
00757                                                         // Implode for display:
00758                                                 $out[$k] = implode('<br />',$pout);
00759                                         break;
00760                                         case 'allowed_languages':
00761 
00762                                                         // Explode and flip values:
00763                                                 $nef = array_flip(explode(',',$v));
00764                                                 $pout = array();
00765 
00766                                                         // Get languages:
00767                                                 $items = t3lib_BEfunc::getSystemLanguages();
00768 
00769                                                         // Traverse values:
00770                                                 foreach($items as $iCfg)        {
00771                                                         if (isset($nef[$iCfg[1]]))      {
00772                                                                 unset($nef[$iCfg[1]]);
00773                                                                 if (strlen($iCfg[2]))   {
00774                                                                         $icon = '<img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$iCfg[2]).' class="absmiddle" style="margin-right: 5px;" alt="" />';
00775                                                                 } else {
00776                                                                         $icon = '';
00777                                                                 }
00778                                                                 $pout[] = $icon.$iCfg[0];
00779                                                         }
00780                                                 }
00781 
00782                                                         // Add remaining:
00783                                                 if (count($nef))        {
00784                                                         $pout = array_merge($pout, array_keys($nef));
00785                                                 }
00786 
00787                                                         // Implode for display:
00788                                                 $out[$k] = implode('<br />',$pout);
00789                                         break;
00790                                         case 'workspace_perms':
00791                                                 $out[$k] = implode('<br/>',explode(', ',t3lib_BEfunc::getProcessedValue('be_users','workspace_perms',$v)));
00792                                         break;
00793                                         case 'workspace_membership':
00794                                                 $out[$k] = implode('<br/>',$this->ext_workspaceMembership());
00795                                         break;
00796                                         case 'custom_options':
00797 
00798                                                         // Explode and flip values:
00799                                                 $nef = array_flip(explode(',',$v));
00800                                                 $pout = array();
00801 
00802                                                         // Initialize:
00803                                                 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
00804                                                 if (is_array($customOptions))   {
00805                                                         foreach($customOptions as $coKey => $coValue) {
00806                                                                 if (is_array($coValue['items']))        {
00807                                                                                 // Traverse items:
00808                                                                         foreach($coValue['items'] as $itemKey => $itemCfg)      {
00809                                                                                 $v = $coKey.':'.$itemKey;
00810                                                                                 if (isset($nef[$v]))    {
00811                                                                                         unset($nef[$v]);
00812                                                                                         $pout[] = $GLOBALS['LANG']->sl($coValue['header']).' / '.$GLOBALS['LANG']->sl($itemCfg[0]);
00813                                                                                 }
00814                                                                         }
00815                                                                 }
00816                                                         }
00817                                                 }
00818 
00819                                                         // Add remaining:
00820                                                 if (count($nef))        {
00821                                                         $pout = array_merge($pout, array_keys($nef));
00822                                                 }
00823 
00824                                                         // Implode for display:
00825                                                 $out[$k] = implode('<br />',$pout);
00826                                         break;
00827                                 }
00828                         }
00829                 }
00830                 return $out;
00831         }
00832 
00838         function ext_getReadableButNonmounted() {
00839 
00840                         // List of page id mounts which ARE mounted (and should therefore not be selected)
00841                 if (!$this->ext_pageIdsFromMounts)      {
00842                         $this->ext_pageIdsFromMounts=0;
00843                 }
00844 
00845                         // User and group names:
00846                 $be_user_Array = t3lib_BEfunc::getUserNames();
00847                 $be_group_Array = t3lib_BEfunc::getGroupNames();
00848 
00849                         // Create query:
00850                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00851                                                 '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':''),
00852                                                 'pages',
00853                                                 'uid NOT IN ('.$this->ext_pageIdsFromMounts.') AND '.$this->getPagePermsClause(1).t3lib_BEfunc::deleteClause('pages')
00854                                         );
00855                 $dat = array();
00856                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00857                         $dat[] = array(
00858                                 'row'=>$row,
00859                                 'HTML'=>t3lib_iconWorks::getIconImage('pages',$row,$GLOBALS['BACK_PATH'],'align="top" title="['.$row['uid'].']"')       // .htmlspecialchars($row['title'])
00860                         );
00861                 }
00862                 $className=t3lib_div::makeInstanceClassName('printAllPageTree_perms');
00863                 $pp = new $className($this);
00864                 return $pp->printTree($dat,1);
00865         }
00866 
00873         function ext_printPerms($int)   {
00874                 $str='';
00875                 $str.= (($int&1)?'*':'<font color="red">x</font>');
00876                 $str.= (($int&16)?'*':'<font color="red">x</font>');
00877                 $str.= (($int&2)?'*':'<font color="red">x</font>');
00878                 $str.= (($int&4)?'*':'<font color="red">x</font>');
00879                 $str.= (($int&8)?'*':'<font color="red">x</font>');
00880 
00881                 return '<b><font color="green">'.$str.'</font></b>';
00882         }
00883 
00891         function ext_groupPerms($row,$firstGroup)       {
00892                 if (is_array($row))     {
00893                         $out=intval($row['perms_everybody']);
00894                         if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
00895                                 $out|= intval($row['perms_group']);
00896                         }
00897                         return $out;
00898                 }
00899         }
00900 
00907         function ext_compileUserInfoForHash($filter=NULL)       {
00908                 $uInfo=array();
00909                 $renderAll = !is_array($filter);
00910 
00911                         // Filemounts:
00912                 if ($renderAll || $filter['filemounts'])        {
00913                         $uInfo['filemounts'] = $this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts'])));
00914                 }
00915 
00916                         // DBmounts:
00917                 if ($renderAll || $filter['webmounts']) {
00918                         $uInfo['webmounts'] = $this->ext_uniqueAndSortList($this->groupData['webmounts']);
00919                 }
00920 
00921                         // Sharing Upload Folder
00922                 if ($renderAll || $filter['tempPath'])  {
00923                         $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00924                         $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
00925                         $uInfo['tempPath'] = $fileProcessor->findTempFolder();  // The closest TEMP-path is found
00926                 }
00927 
00928                         // First Main Group:
00929                 if ($renderAll || $filter['firstMainGroup'])    {
00930                         $uInfo['firstMainGroup'] = $this->firstMainGroup;
00931                 }
00932 
00933                         // Group List:
00934                 if ($renderAll || $filter['groupList']) {
00935                         $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.
00936                 }
00937 
00938                         // Page Types:
00939                 if ($renderAll || $filter['pagetypes_select'])  {
00940                         $uInfo['pagetypes_select'] = $this->ext_uniqueAndSortList($this->groupData['pagetypes_select']);
00941                 }
00942 
00943                         // Tables select:
00944                 if ($renderAll || $filter['tables_select'])     {
00945                         $uInfo['tables_select'] = $this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']);
00946                 }
00947 
00948                         // Tables modify:
00949                 if ($renderAll || $filter['tables_modify'])     {
00950                         $uInfo['tables_modify'] = $this->ext_uniqueAndSortList($this->groupData['tables_modify']);
00951                 }
00952 
00953                         // Non-exclude fields:
00954                 if ($renderAll || $filter['non_exclude_fields'])        {
00955                         $uInfo['non_exclude_fields'] = $this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']);
00956                 }
00957 
00958                         // Explicit Allow/Deny:
00959                 if ($renderAll || $filter['explicit_allowdeny'])        {
00960                         $uInfo['explicit_allowdeny'] = $this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']);
00961                 }
00962 
00963                         // Limit to languages:
00964                 if ($renderAll || $filter['allowed_languages']) {
00965                         $uInfo['allowed_languages'] = $this->ext_uniqueAndSortList($this->groupData['allowed_languages']);
00966                 }
00967 
00968                         // Workspace permissions
00969                 if ($renderAll || $filter['workspace_perms'])   {
00970                         $uInfo['workspace_perms'] = $this->ext_uniqueAndSortList($this->groupData['workspace_perms']);
00971                 }
00972 
00973                         // Workspace membership
00974                 if ($renderAll || $filter['workspace_membership'])      {
00975                         $uInfo['workspace_membership'] = $this->ext_workspaceMembership();
00976                 }
00977 
00978                         // Custom options:
00979                 if ($renderAll || $filter['custom_options'])    {
00980                         $uInfo['custom_options'] = $this->ext_uniqueAndSortList($this->groupData['custom_options']);
00981                 }
00982 
00983                         // Modules:
00984                 if ($renderAll || $filter['modules'])   {
00985                         $uInfo['modules'] = $this->ext_uniqueAndSortList($this->groupData['modules']);
00986                 }
00987 
00988                         // User TS:
00989                 $this->ext_ksortArrayRecursive($this->userTS);
00990                 if ($renderAll || $filter['userTS'])    {
00991                         $uInfo['userTS'] = $this->userTS;
00992                 }
00993 
00994                 if ($renderAll || $filter['userTS_hl']) {
00995                         $uInfo['userTS_hl'] = $this->userTS_text;
00996                 }
00997 
00998                 return $uInfo;
00999         }
01000 
01007         function ext_uniqueAndSortList($list)   {
01008                 $uList=t3lib_div::trimExplode(',',$list,1);
01009                 sort($uList);
01010                 $uList=array_unique($uList);
01011                 $uList=implode(',',$uList);
01012                 return $uList;
01013         }
01014 
01021         function ext_ksortArrayRecursive(&$arr) {
01022                 krsort($arr);
01023                 reset($arr);
01024                 while(list($k,$v)=each($arr))   {
01025                         if (is_array($v))       $this->ext_ksortArrayRecursive($arr[$k]);
01026                 }
01027         }
01028 
01034         function ext_workspaceMembership()      {
01035                         // Create accessible workspace arrays:
01036                 $options = array();
01037                 if ($this->checkWorkspace(array('uid' => 0)))   {
01038                         $options[0] = '0: [LIVE]';
01039                 }
01040                 if ($this->checkWorkspace(array('uid' => -1)))  {
01041                         $options[-1] = '-1: [Default Draft]';
01042                 }
01043 
01044                         // Add custom workspaces (selecting all, filtering by BE_USER check):
01045                 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers,db_mountpoints','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
01046                 if (count($workspaces)) {
01047                         foreach ($workspaces as $rec)   {
01048                                 if ($this->checkWorkspace($rec))        {
01049                                         $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
01050 
01051                                                 // Check if all mount points are accessible, otherwise show error:
01052                                         if (trim($rec['db_mountpoints'])!=='')  {
01053                                                 $mountPoints = t3lib_div::intExplode(',',$this->workspaceRec['db_mountpoints'],1);
01054                                                 foreach($mountPoints as $mpId)  {
01055                                                         if (!$this->isInWebMount($mpId,'1=1'))  {
01056                                                                 $options[$rec['uid']].= '<br> \- WARNING: Workspace Webmount page id "'.$mpId.'" not accessible!';
01057                                                         }
01058                                                 }
01059                                         }
01060                                 }
01061                         }
01062                 }
01063 
01064                 return $options;
01065         }
01066 }
01067 
01068 
01069 
01070 
01071 
01072 
01073 
01074 
01075 
01076 
01077 
01078 
01086 class SC_mod_tools_be_user_index {
01087         var $MCONF=array();
01088         var $MOD_MENU=array();
01089         var $MOD_SETTINGS=array();
01090         var $doc;
01091 
01092         var $include_once=array();
01093         var $content;
01094 
01098         function init() {
01099                 $this->MCONF = $GLOBALS['MCONF'];
01100 
01101                 $this->menuConfig();
01102                 $this->switchUser(t3lib_div::_GP('SwitchUser'));
01103 
01104 
01105                 // **************************
01106                 // Initializing
01107                 // **************************
01108                 $this->doc = t3lib_div::makeInstance('noDoc');
01109                 $this->doc->form='<form action="" method="POST">';
01110                 $this->doc->backPath = $GLOBALS['BACK_PATH'];
01111                                 // JavaScript
01112                 $this->doc->JScode = $this->doc->wrapScriptTags('
01113                         script_ended = 0;
01114                         function jumpToUrl(URL) {       //
01115                                 window.location.href = URL;
01116                         }
01117                 ' . $this->doc->redirectUrls());
01118         }
01119 
01125         function menuConfig()   {
01126                 // MENU-ITEMS:
01127                         // If array, then it's a selector box menu
01128                         // If empty string it's just a variable, that'll be saved.
01129                         // Values NOT in this array will not be saved in the settings-array for the module.
01130                 $this->MOD_MENU = array(
01131                         'function' => array(
01132                                 'compare' => 'Compare User Settings',
01133                                 'whoisonline' => 'List Users Online'
01134                         )
01135                 );
01136                         // CLEAN SETTINGS
01137                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
01138         }
01139 
01145         function main() {
01146                 $this->content='';
01147                 $this->content.=$this->doc->startPage('Backend User Administration');
01148 
01149                 $menu=t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
01150 
01151                 $this->content.=$this->doc->header('Backend User Administration');
01152                 $this->content.=$this->doc->spacer(5);
01153                 $this->content.=$this->doc->section('',$menu).$this->doc->divider(5);
01154 
01155                 switch($this->MOD_SETTINGS['function']) {
01156                         case 'compare':
01157                                 if (t3lib_div::_GP('ads'))      {
01158                                         $compareFlags = t3lib_div::_GP('compareFlags');
01159                                         $GLOBALS['BE_USER']->pushModuleData('tools_beuser/index.php/compare',$compareFlags);
01160                                 } else {
01161                                         $compareFlags = $GLOBALS['BE_USER']->getModuleData('tools_beuser/index.php/compare','ses');
01162                                 }
01163                                 $this->content.=$this->compareUsers($compareFlags);
01164                         break;
01165                         case 'whoisonline':
01166                                 $this->content.=$this->whoIsOnline();
01167                         break;
01168                 }
01169 
01170 
01171                 if ($GLOBALS['BE_USER']->mayMakeShortcut())     {
01172                         $this->content.=$this->doc->spacer(20).
01173                                                 $this->doc->section('',$this->doc->makeShortcutIcon('be_user_uid,compareFlags','function',$this->MCONF['name']));
01174                 }
01175         }
01176 
01182         function printContent() {
01183 
01184                 $this->content.=$this->doc->endPage();
01185                 echo $this->content;
01186         }
01187 
01188 
01189 
01190 
01191 
01192 
01193 
01194         /***************************
01195          *
01196          * OTHER FUNCTIONS:
01197          *
01198          ***************************/
01199 
01204         function compareUsers($compareFlags)    {
01205                         // Menu:
01206                 $options = array(
01207                         'filemounts' => 'Filemounts',
01208                         'webmounts' => 'Webmounts',
01209                         'tempPath' => 'Default upload path',
01210                         'firstMainGroup' => 'Main user group',
01211                         'groupList' => 'Member of groups',
01212                         'pagetypes_select' => 'Page types access',
01213                         'tables_select' => 'Select tables',
01214                         'tables_modify' => 'Modify tables',
01215                         'non_exclude_fields' => 'Non-exclude fields',
01216                         'explicit_allowdeny' => 'Explicit Allow/Deny',
01217                         'allowed_languages' => 'Limit to languages',
01218                         'workspace_perms' => 'Workspace permissions',
01219                         'workspace_membership' => 'Workspace membership',
01220                         'custom_options' => 'Custom options',
01221                         'modules' => 'Modules',
01222                         'userTS' => 'TSconfig',
01223                         'userTS_hl' => 'TSconfig HL',
01224                 );
01225 
01226                 $be_user_uid = t3lib_div::_GP('be_user_uid');
01227                 if ($be_user_uid)       {
01228                                 // This is used to test with other users. Development ONLY!
01229                         $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth');     // New backend user object
01230                         $tempBE_USER->userTS_dontGetCached=1;
01231                         $tempBE_USER->OS = TYPO3_OS;
01232                         $tempBE_USER->setBeUserByUid($be_user_uid);
01233                         $tempBE_USER->fetchGroupData();
01234 
01235                         $uInfo = $tempBE_USER->ext_compileUserInfoForHash();
01236                         $uInfo_dat = $tempBE_USER->ext_printOverview($uInfo,$options,1);
01237 
01238                         $lines=array();
01239                         reset($options);
01240                         while(list($kk,$vv)=each($options))     {
01241                                 if ($kk=='modules')     {
01242                                         $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
01243                                         $loadModules->load($GLOBALS['TBE_MODULES'],$tempBE_USER);
01244                                         $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
01245                                         $uInfo_dat[$kk] = $alt_menuObj->topMenu($loadModules->modules,1,$GLOBALS['BACK_PATH']);
01246                                 }
01247                                 $lines[]='<tr class="bgColor4">
01248                                         <td nowrap="nowrap" valign="top">'.$vv.':&nbsp;&nbsp;</td>
01249                                         <td>'.$uInfo_dat[$kk].'&nbsp;</td>
01250                                 </tr>';
01251 
01252                                 if ($kk=='webmounts' && !$tempBE_USER->isAdmin())       {
01253                                         $lines[]='<tr class="bgColor4">
01254                                                 <td nowrap="nowrap" valign="top">Non-mounted readable pages:&nbsp;&nbsp;</td>
01255                                                 <td>'.$tempBE_USER->ext_getReadableButNonmounted().'&nbsp;</td>
01256                                         </tr>';
01257                                 }
01258                         }
01259 
01260                         $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>';
01261                         $outTable.= '<td>'.$tempBE_USER->user['realName'].($tempBE_USER->user['email'] ? ', <a href="mailto:'.$tempBE_USER->user['email'].'">'.$tempBE_USER->user['email'].'</a>' : '').'</td>';
01262                         $outTable.= '<td>'.$this->elementLinks('be_users',$tempBE_USER->user).'</td></tr></table>';
01263                         $outTable.= '<strong><a href="'.htmlspecialchars($this->MCONF['_']).'">&lt; Back to overview</a></strong><br />';
01264 
01265                         $outTable.= '<br /><table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
01266                         $content.= $this->doc->section('User info',$outTable,0,1);
01267                 } else {
01268                         reset($options);
01269                         $menu=array();
01270                         while(list($kk,$vv)=each($options))     {
01271                                 $menu[]='<input type="checkbox" value="1" name="compareFlags['.$kk.']" id="checkCompare_'.$kk.'"'.($compareFlags[$kk]?' checked="checked"':'').'> <label for="checkCompare_'.$kk.'">'.htmlspecialchars($vv).'</label>';
01272                         }
01273                         $outCode = 'Group by:<br />'.implode('<br />',$menu);
01274                         $outCode.='<br /><input type="submit" name="ads" value="Update">';
01275                         $content = $this->doc->section('Group and Compare Users',$outCode,0,1);
01276 
01277 
01278                                 // Traverse all users
01279                         $users = t3lib_BEfunc::getUserNames();
01280                         $comparation=array();
01281                         reset($users);
01282                         $counter=0;
01283 
01284 
01285                         $offset=0;
01286                         $numberAtTime=1000;
01287                         $tooManyUsers='';
01288 
01289                         while(list(,$r)=each($users))   {
01290                                 if ($counter>=$offset)  {
01291                                                 // This is used to test with other users. Development ONLY!
01292                                         $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth');     // New backend user object
01293                                         $tempBE_USER->OS = TYPO3_OS;
01294                                         $tempBE_USER->setBeUserByUid($r['uid']);
01295                                         $tempBE_USER->fetchGroupData();
01296 
01297                                                 // Making group data
01298                                         $md5pre='';
01299                                         $menu=array();
01300                                         $uInfo = $tempBE_USER->ext_compileUserInfoForHash((array)$compareFlags);
01301                                         reset($options);
01302                                         while(list($kk,$vv)=each($options))     {
01303                                                 if ($compareFlags[$kk]) {
01304                                                         $md5pre.=serialize($uInfo[$kk]).'|';
01305                                                 }
01306                                         }
01307                                                 // setting md5:
01308                                         $md5=md5($md5pre);
01309                                         if (!isset($comparation[$md5])) {
01310                                                 $comparation[$md5]=$tempBE_USER->ext_printOverview($uInfo,$compareFlags);
01311                                                 $comparation[$md5]['users']=array();
01312                                         }
01313                                         $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']);
01314                                         unset($tempBE_USER);
01315                                 }
01316                                 $counter++;
01317                                 if ($counter>=($numberAtTime+$offset)) {
01318                                         $tooManyUsers='There were more than '.$numberAtTime.' users (total: '.count($users).') and this tool can display only '.$numberAtTime.' at a time!';
01319                                         break;
01320                                 }
01321                         }
01322 
01323                                 // Print the groups:
01324                         $allGroups=array();
01325                                 // Header:
01326                         $allCells = array();
01327                         reset($options);
01328 
01329                         $link_createNewUser='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[be_users][0]=new',$this->doc->backPath,-1)).'">'.
01330                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_el.gif').' title="'.$GLOBALS['LANG']->getLL('new',1).'" alt="" />'.
01331                                 '</a>';
01332 
01333                         $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><td><b>Usernames:</b></td><td width="12">'.$link_createNewUser.'</td></tr></table>';
01334 
01335                         while(list($kk,$vv)=each($options))     {
01336                                 if ($compareFlags[$kk]) {
01337                                         $allCells[$kk] = '<b>'.$vv.':</b>';
01338                                 }
01339                         }
01340                         $allGroups[]=$allCells;
01341 
01342                         reset($comparation);
01343                         while(list(,$dat)=each($comparation))   {
01344                                 $allCells = array();
01345 
01346                                 $curUid = $GLOBALS['BE_USER']->user['uid'];
01347                                 $uListArr=array();
01348                                 reset($dat['users']);
01349                                 while(list(,$uDat)=each($dat['users'])) {
01350                                         $uItem = '<tr><td width="130">'.t3lib_iconWorks::getIconImage('be_users',$uDat,$GLOBALS['BACK_PATH'],'align="top" title="'.$uDat['uid'].'"').$this->linkUser($uDat['username'],$uDat).'&nbsp;&nbsp;</td><td nowrap="nowrap">'.$this->elementLinks('be_users',$uDat);
01351                                         if ($curUid != $uDat['uid'] && !$uDat['disable'] && ($uDat['starttime'] == 0 || $uDat['starttime'] < time()) && ($uDat['endtime'] == 0 || $uDat['endtime'] > time()))   {
01352                                                 $uItem .= '<a href="'.t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'])).'" target="_top"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/su.gif').' border="0" align="top" title="'.htmlspecialchars('Switch user to: '.$uDat['username']).' [change-to mode]" alt="" /></a>'.
01353                                                         '<a href="'.t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'], 'switchBackUser' => 1)).'" target="_top"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/su_back.gif').' border="0" align="top" title="'.htmlspecialchars('Switch user to: '.$uDat['username']).' [switch-back mode]" alt="" /></a>';
01354                                         }
01355                                         $uItem .= '</td></tr>';
01356                                         $uListArr[] = $uItem;
01357                                 }
01358                                 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>';
01359 
01360                                 reset($options);
01361                                 while(list($kk,$vv)=each($options))     {
01362                                         if ($compareFlags[$kk]) {
01363                                                 $allCells[$kk] = $dat[$kk];
01364                                         }
01365                                 }
01366                                 $allGroups[]=$allCells;
01367                         }
01368 
01369                                 // Make table
01370                         $outTable='';
01371                         reset($allGroups);
01372                         $TDparams=' nowrap="nowrap" class="bgColor5" valign="top"';
01373                         while(list(,$allCells)=each($allGroups))        {
01374                                 $outTable.='<tr><td'.$TDparams.'>'.implode('</td><td'.$TDparams.'>',$allCells).'</td></tr>';
01375                                 $TDparams=' nowrap="nowrap" class="bgColor4" valign="top"';
01376                         }
01377                         $outTable='<table border="0" cellpadding="2" cellspacing="2">'.$outTable.'</table>';
01378                         $outTable.=fw('<br /><br />(All cached group lists updated.)');
01379                         $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">'.$tooManyUsers.'</span></strong>':'';
01380                         $content.= $this->doc->spacer(10);
01381                         $content.= $this->doc->section('Result',$outTable,0,1);
01382                 }
01383                 return $content;
01384         }
01385 
01393         function linkUser($str,$rec)    {
01394                 return '<a href="'.htmlspecialchars($this->MCONF['_']).'&be_user_uid='.$rec['uid'].'">'.$str.'</a>';
01395         }
01396 
01404         function elementLinks($table,$row)      {
01405                         // Info:
01406                 $cells[]='<a href="#" onclick="top.launchView(\''.$table.'\', \''.$row['uid'].'\',\''.$GLOBALS['BACK_PATH'].'\'); return false;"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/zoom2.gif').' border="0" align="top" title="Show information" alt="" /></a>';
01407 
01408                         // Edit:
01409                 $params='&edit['.$table.']['.$row['uid'].']=edit';
01410                 $cells[]='<a href="#" onclick="'.t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'],'').'"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif').' border="0" align="top" title="Edit" alt="" /></a>';
01411 
01412                         // Hide:
01413                 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
01414                 if ($row[$hiddenField]) {
01415                         $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
01416                         $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/button_unhide.gif').' border="0" title="Enable" align="top" alt="" /></a>';
01417                 } else {
01418                         $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
01419                         $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/button_hide.gif').' border="0" title="Disable" align="top" alt="" /></a>';
01420                 }
01421 
01422                         // Delete
01423                 $params='&cmd['.$table.']['.$row['uid'].'][delete]=1';
01424                 $cells[]='<a href="'.$this->doc->issueCommand($params).'" onclick="return confirm(unescape(\''.rawurlencode('Are you sure you want to delete this element?').'\'));"><img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/garbage.gif').' border="0" align="top" title="Delete(!)" alt="" /></a>';
01425 
01426                 return implode('',$cells);
01427         }
01428 
01434         function initUsers()    {
01435                         // Initializing all users in order to generate the usergroup_cached_list
01436                 $users = t3lib_BEfunc::getUserNames();
01437                 reset($users);
01438                 while(list(,$r)=each($users))   {
01439                                 // This is used to test with other users. Development ONLY!
01440                         $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth');     // New backend user object
01441                         $tempBE_USER->OS = TYPO3_OS;
01442                         $tempBE_USER->setBeUserByUid($r['uid']);
01443                         $tempBE_USER->fetchGroupData();
01444                 }
01445         }
01446 
01453         function localPath($str)        {
01454                 if (substr($str,0,strlen(PATH_site))==PATH_site)        {
01455                         return substr($str,strlen(PATH_site));
01456                 } else return $str;
01457         }
01458 
01465         function switchUser($switchUser)        {
01466                 $uRec=t3lib_BEfunc::getRecord('be_users',$switchUser);
01467                 if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin())  {
01468                         $updateData['ses_userid'] = $uRec['uid'];
01469                                 // user switchback
01470                         if (t3lib_div::_GP('switchBackUser'))   {
01471                                 $updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']);
01472                         }
01473                         $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);
01474 
01475                         header('Location: '.t3lib_div::locationHeaderUrl($GLOBALS['BACK_PATH'].'index.php'.($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']?'':'?commandLI=1')));
01476                         exit;
01477                 }
01478         }
01479 
01480         /***************************
01481          *
01482          * "WHO IS ONLINE" FUNCTIONS:
01483          *
01484          ***************************/
01485 
01489         function whoIsOnline()  {
01490                 $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';
01491                 $from_table = '(be_sessions, be_users u) LEFT OUTER JOIN be_users bu ON (ses_backuserid=bu.uid)';
01492                 $where_clause = 'ses_userid=u.uid';
01493                 $orderBy = 'u.username';
01494 
01495                 if (t3lib_div::testInt($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']))    {
01496                         $where_clause .= ' AND '.$GLOBALS['EXEC_TIME'].'<(ses_tstamp+'.$GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'].')';
01497                 } else {
01498                         $timeout = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
01499                         if ($timeout > 0)       {
01500                                 $where_clause .= ' AND '.$GLOBALS['EXEC_TIME'].'<(ses_tstamp+'.$timeout.')';
01501                         }
01502                 }
01503                         // Fetch active sessions of other users from storage:
01504                 $sessions = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select_fields,$from_table,$where_clause,'',$orderBy);
01505                         // Process and visualized each active session as a table row:
01506                 if (is_array($sessions)) {
01507                         foreach ($sessions as $session) {
01508                                 $hostName = ($session['ses_iplock'] != '[DISABLED]' ? gethostbyaddr($session['ses_iplock']) : '[DISABLED]');
01509                                 $outTable .= '
01510                                         <tr class="bgColor4" height="17" valign="top">' .
01511                                                 '<td nowrap="nowrap">' .
01512                                                         date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $session['ses_tstamp']) .
01513                                                 '</td>' .
01514                                                 '<td nowrap="nowrap">' .
01515                                                         '<span title="'.$hostName.'">'.$session['ses_iplock'].'</span>' .
01516                                                 '</td>' .
01517                                                 '<td width="130">' .
01518                                                         t3lib_iconWorks::getIconImage('be_users',$session,$GLOBALS['BACK_PATH'],'align="top" title="'.$session['uid'].'"').htmlspecialchars($session['username']).'&nbsp;' .
01519                                                 '</td>' .
01520                                                 '<td nowrap="nowrap">'.htmlspecialchars($session['realName']).'&nbsp;&nbsp;</td>' .
01521                                                 '<td nowrap="nowrap">'.$this->elementLinks('be_users',$session).'</td>' .
01522                                                 '<td nowrap="nowrap" valign="top">'.($session['bu_username'] ? '&nbsp;SU from: ' : '').htmlspecialchars($session['bu_username']).'&nbsp;</td>' .
01523                                                 '<td nowrap="nowrap" valign="top">&nbsp;'.htmlspecialchars($session['bu_realName']).'</td>' .
01524                                         '</tr>';
01525                         }
01526                 }
01527                         // Wrap <table> tag around the rows:
01528                 $outTable = '
01529                 <table border="0" cellpadding="2" cellspacing="2">
01530                         <tr class="bgColor5">
01531                                 <td valign="top"><b>Timestamp:</b></td>
01532                                 <td valign="top"><b>Host:</b></td>
01533                                 <td valign="top" colspan="5"><b>Username:</b></td>
01534                         </tr>'.$outTable.'
01535                 </table>';
01536 
01537                 $content.= $this->doc->section('Who Is Online',$outTable,0,1);
01538                 return $content;
01539         }
01540 
01541 }
01542 
01543 // Include extension?
01544 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php'])        {
01545         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']);
01546 }
01547 
01548 
01549 
01550 
01551 
01552 
01553 
01554 
01555 
01556 
01557 
01558 
01559 // Make instance:
01560 $SOBE = t3lib_div::makeInstance('SC_mod_tools_be_user_index');
01561 $SOBE->init();
01562 $SOBE->main();
01563 $SOBE->printContent();
01564 
01565 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6