Fixed bug #11189: Validation issue: value of attribute "method" cannot be "POST"...
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / mod / index.php
index f7b28fb..b5c6209 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  *
  *
  *
- *  114: class localPageTree extends t3lib_browseTree
- *  124:     function localPageTree($BE_USER,$WEBMOUNTS='',$FILEMOUNTS='')
- *  137:     function wrapTitle($str)
- *  149:     function PM_ATagWrap($icon,$cmd,$bMark='')
- *  158:     function permsC()
- *  169:     function wrapIcon($str,$val)
+ *  129: class localPageTree extends t3lib_browseTree
+ *  140:     function localPageTree($BE_USER,$WEBMOUNTS='')
+ *  154:     function ext_permsC()
+ *  165:     function wrapTitle($str,$row)
+ *  177:     function PM_ATagWrap($icon,$cmd,$bMark='')
+ *  188:     function wrapIcon($icon,$row)
+ *  201:     function initializePositionSaving()
  *
  *
- *  195: class printAllPageTree extends localPageTree
- *  202:     function permsC()
- *  214:     function PM_ATagWrap($icon,$cmd,$bMark='')
- *  225:     function wrapIcon($str,$val)
+ *  222: class printAllPageTree extends localPageTree
+ *  231:     function ext_permsC()
+ *  243:     function PM_ATagWrap($icon,$cmd,$bMark='')
+ *  254:     function wrapIcon($icon,$row)
  *
  *
- *  252: class printAllPageTree_perms extends printAllPageTree
- *  259:     function printTree($treeArr='',$printPath=0)
- *  302:     function ext_printPerms($int)
- *  321:     function ext_groupPerms($row,$firstGroup)
+ *  279: class printAllPageTree_perms extends printAllPageTree
+ *  288:     function printTree($treeArr='',$printPath=0)
+ *  331:     function ext_printPerms($int)
+ *  349:     function ext_groupPerms($row,$firstGroup)
  *
  *
- *  350: class local_beUserAuth extends t3lib_beUserAuth
- *  358:     function returnWebmounts($pClause='')
- *  378:     function ext_non_readAccessPages()
- *  394:     function user_where_clause()
- *  407:     function ext_printOverview($uInfo,$compareFlags,$printTrees=0)
- *  572:     function ext_getReadableButNonmounted()
- *  604:     function ext_printPerms($int)
- *  623:     function ext_groupPerms($row,$firstGroup)
- *  639:     function ext_compileUserInfoForHash()
- *  689:     function ext_uniqueAndSortList($list)
- *  703:     function ext_ksortArrayRecursive(&$arr)
+ *  377: class localFolderTree extends t3lib_folderTree
+ *  388:     function localFolderTree($BE_USER,$FILEMOUNTS='')
+ *  403:     function wrapTitle($str,$row)
+ *  415:     function PM_ATagWrap($icon,$cmd,$bMark='')
+ *  426:     function wrapIcon($icon,$row)
+ *  439:     function initializePositionSaving()
  *
  *
- *  730: class SC_mod_tools_be_user_index
- *  742:     function init()
- *  772:     function menuConfig()
- *  793:     function main()
- *  829:     function printContent()
+ *  463: class printAllFolderTree extends localFolderTree
+ *  475:     function PM_ATagWrap($icon,$cmd,$bMark='')
+ *
+ *
+ *  497: class local_beUserAuth extends t3lib_beUserAuth
+ *  509:     function returnWebmounts($pClause='')
+ *  533:     function ext_non_readAccessPages()
+ *  556:     function user_where_clause()
+ *  568:     function ext_printOverview($uInfo,$compareFlags,$printTrees=0)
+ *  838:     function ext_getReadableButNonmounted()
+ *  873:     function ext_printPerms($int)
+ *  891:     function ext_groupPerms($row,$firstGroup)
+ *  907:     function ext_compileUserInfoForHash($filter=NULL)
+ * 1007:     function ext_uniqueAndSortList($list)
+ * 1021:     function ext_ksortArrayRecursive(&$arr)
+ * 1034:     function ext_workspaceMembership()
+ *
+ *
+ * 1088: class SC_mod_tools_be_user_index
+ * 1100:     function init()
+ * 1128:     function menuConfig()
+ * 1149:     function main()
+ * 1185:     function printContent()
  *
  *              SECTION: OTHER FUNCTIONS:
- *  852:     function compareUsers($compareFlags)
- * 1030:     function linkUser($str,$rec)
- * 1041:     function elementLinks($table,$row)
- * 1072:     function initUsers()
- * 1092:     function localPath($str)
- * 1104:     function switchUser($switchUser)
+ * 1207:     function compareUsers($compareFlags)
+ * 1394:     function linkUser($str,$rec)
+ * 1405:     function elementLinks($table,$row)
+ * 1436:     function initUsers()
+ * 1456:     function localPath($str)
+ * 1468:     function switchUser($switchUser)
  *
- * TOTAL FUNCTIONS: 31
- * (This index is automatically created/updated by the extension 'extdeveval')
+ * TOTAL FUNCTIONS: 39
+ * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
-unset($MCONF);
-require ('conf.php');
-require ($BACK_PATH.'init.php');
-require ($BACK_PATH.'template.php');
-require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
-require_once (PATH_t3lib.'class.t3lib_browsetree.php');
-require_once (PATH_t3lib.'class.t3lib_foldertree.php');
-require_once (PATH_t3lib.'class.t3lib_tstemplate.php');
-require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
-require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php');
 require_once (PATH_typo3.'class.alt_menu_functions.inc');
 
+$GLOBALS['LANG']->includeLLFile('EXT:beuser/mod/locallang.xml');
+
 $BE_USER->modAccess($MCONF,1);
 
 
@@ -117,6 +123,13 @@ $BE_USER->modAccess($MCONF,1);
        var $expandAll=0;
 
        /**
+        * Local backend user (not the GLOBALS[] backend user!!)
+        *
+        * @var t3lib_beUserAuth
+        */
+       var $BE_USER;
+
+       /**
         * Constructor for the local page tree.
         *
         * @param       object          Local backend user (not the GLOBALS[] backend user!!)
@@ -278,18 +291,19 @@ class printAllPageTree_perms extends printAllPageTree {
                $be_group_Array = t3lib_BEfunc::getGroupNames();
                $lines=array();
                $lines[]='<tr class="bgColor5">
-                       <td nowrap="nowrap"><strong>Page title:</strong></td>
-                       '.($printPath?'<td nowrap="nowrap"><strong>Path:</strong></td>':'').'
-                       <td nowrap="nowrap" colspan=2><strong>User:</strong></td>
-                       <td nowrap="nowrap" colspan=2><strong>Group: &nbsp;</strong></td>
-                       <td nowrap="nowrap"><strong>Everybody: &nbsp;</strong></td>
-                       <td nowrap="nowrap"><strong>This user: &nbsp;</strong></td>
-                       <td nowrap="nowrap"><strong>Main group:</strong></td>
+                       <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('pageTitle', true) . '</strong></td>
+                       ' . ($printPath?'<td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('path', true) . '</strong></td>':'') . '
+                       <td nowrap="nowrap" colspan="2"><strong>' . $GLOBALS['LANG']->getLL('user', true) . '</strong></td>
+                       <td nowrap="nowrap" colspan="2"><strong>' . $GLOBALS['LANG']->getLL('group', true) . ' &nbsp;</strong></td>
+                       <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('everybody', true) . ' &nbsp;</strong></td>
+                       <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('thisUser', true) . ' &nbsp;</strong></td>
+                       <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('mainGroup', true) . '</strong></td>
                </tr>';
 
-               if (!is_array($treeArr))        $treeArr=$this->tree;
-               reset($treeArr);
-               while(list($k,$v)=each($treeArr))       {
+               if (!is_array($treeArr)) {
+                       $treeArr = $this->tree;
+               }
+               foreach ($treeArr as $v) {
                        $col1 = ' bgcolor="'.t3lib_div::modifyHtmlColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"';
                        $row = $v['row'];
                        $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$this->BE_USER->uc['titleLen']));
@@ -301,7 +315,7 @@ class printAllPageTree_perms extends printAllPageTree {
                                <td nowrap="nowrap">'.$be_group_Array[$row['perms_groupid']]['title'].' &nbsp;</td>
                                <td nowrap="nowrap">'.$this->ext_printPerms($row['perms_group']).' &nbsp;</td>
                                <td nowrap="nowrap" align="center" '.$col1.'>'.$this->ext_printPerms($row['perms_everybody']).' &nbsp;</td>
-                               <td nowrap="nowrap" align="center">'.($row['editlock'] ? '<img src="'.$this->backPath.'gfx/recordlock_warning2.gif" width="22" height="16" title="Edit lock prevents all editing" alt="" />' : $this->ext_printPerms($this->BE_USER->calcPerms($row))).' &nbsp;</td>
+                               <td nowrap="nowrap" align="center">' . ($row['editlock'] ? '<img ' . t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning2.gif') . ' title="' . $GLOBALS['LANG']->getLL('editLock', true) . '" alt="" />' : $this->ext_printPerms($this->BE_USER->calcPerms($row))) . ' &nbsp;</td>
                                <td nowrap="nowrap" align="center">'.$this->ext_printPerms($this->ext_groupPerms($row,$be_group_Array[$this->BE_USER->firstMainGroup])).' &nbsp;</td>
                        </tr>';
                }
@@ -365,6 +379,13 @@ class printAllPageTree_perms extends printAllPageTree {
        var $expandAll=0;
 
        /**
+        * Local backend user (not the GLOBALS[] backend user!!)
+        *
+        * @var t3lib_beUserAuth
+        */
+       var $BE_USER;
+
+       /**
         * Constructor for the local folder tree.
         *
         * @param       object          Local backend user (not the GLOBALS[] backend user!!)
@@ -501,7 +522,7 @@ class local_beUserAuth extends t3lib_beUserAuth {
                $pClause=$pClause?$pClause:$this->getPagePermsClause(1);
 
                        // Traverse mounts, check if they are readable:
-               foreach($webmounts as $k => $id)        {
+               foreach ($webmounts as $k => $id)       {
                        $rec=t3lib_BEfunc::getRecord('pages',$id,'*',' AND '.$pClause);
                        if (!is_array($rec))    {
                                $this->ext_non_readAccessPageArray[$id]=t3lib_BEfunc::getRecord('pages',$id);
@@ -519,13 +540,15 @@ class local_beUserAuth extends t3lib_beUserAuth {
        function ext_non_readAccessPages()      {
                $lines=array();
 
-               foreach($this->ext_non_readAccessPageArray as $pA)      {
-                       if ($pA)        $lines[]=t3lib_BEfunc::getRecordPath($pA['uid'],'',15);
+               foreach ($this->ext_non_readAccessPageArray as $pA) {
+                       if ($pA) {
+                               $lines[] = t3lib_BEfunc::getRecordPath($pA['uid'],'',15);
+                       }
                }
-               if (count($lines))      {
+               if (count($lines)) {
                        return '<table bgcolor="red" border="0" cellpadding="0" cellspacing="0">
                                <tr>
-                                       <td align="center"><font color="white"><strong>The user has no read access to these DB-mounts!</strong></font></td>
+                                       <td align="center"><font color="white"><strong>' . $GLOBALS['LANG']->getLL('noReadAccess', true) . '</strong></font></td>
                                </tr>
                                <tr>
                                        <td>'.implode('</td></tr><tr><td>',$lines).'</td>
@@ -555,8 +578,7 @@ class local_beUserAuth extends t3lib_beUserAuth {
                        // Prepare for filemount and db-mount
                if ($printTrees)        {       // ... this is if we see the detailed view for a user:
                                // Page tree object:
-                       $className=t3lib_div::makeInstanceClassName(!$this->isAdmin() ? 'printAllPageTree_perms' : 'printAllPageTree');
-                       $pagetree = new $className($this,$this->returnWebmounts());     // Here, only readable webmounts are returned (1=1)
+                       $pagetree = t3lib_div::makeInstance(!$this->isAdmin() ? 'printAllPageTree_perms' : 'printAllPageTree', $this, $this->returnWebmounts());        // Here, only readable webmounts are returned (1=1)
                        $pagetree->addField('perms_user',1);
                        $pagetree->addField('perms_group',1);
                        $pagetree->addField('perms_everybody',1);
@@ -565,16 +587,13 @@ class local_beUserAuth extends t3lib_beUserAuth {
                        $pagetree->addField('editlock',1);
 
                                // Folder tree object:
-                       $className=t3lib_div::makeInstanceClassName('printAllFolderTree');
-                       $foldertree = new $className($this,$this->returnFilemounts());
+                       $foldertree = t3lib_div::makeInstance('printAllFolderTree', $this, $this->returnFilemounts());
                } else {
                                // Page tree object:
-                       $className=t3lib_div::makeInstanceClassName('localPageTree');
-                       $pagetree = new $className($this,$this->returnWebmounts('1=1'));        // Here, ALL webmounts are returned (1=1)
+                       $pagetree = t3lib_div::makeInstance('localPageTree', $this, $this->returnWebmounts('1=1'));     // Here, ALL webmounts are returned (1=1)
 
                                // Folder tree object:
-                       $className=t3lib_div::makeInstanceClassName('localFolderTree');
-                       $foldertree = new $className($this,$this->returnFilemounts());
+                       $foldertree = t3lib_div::makeInstance('localFolderTree', $this, $this->returnFilemounts());
                }
 
                        // Names for modules:
@@ -602,7 +621,7 @@ class local_beUserAuth extends t3lib_beUserAuth {
 
                        // Traverse the enabled analysis topics:
                $out=array();
-               foreach($uInfo as $k => $v)     {
+               foreach ($uInfo as $k => $v)    {
                        if ($compareFlags[$k])  {
                                switch($k)      {
                                        case 'filemounts':
@@ -620,30 +639,27 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                        break;
                                        case 'pagetypes_select':
                                                $pageTypes = explode(',',$v);
-                                               reset($pageTypes);
-                                               while(list($kk,$vv)=each($pageTypes))   {
-                                                       $pageTypes[$kk]=$GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('pages','doktype',$vv));
+                                               foreach ($pageTypes as &$vv) {
+                                                       $vv = $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('pages','doktype',$vv));
                                                }
                                                $out[$k] = implode('<br />',$pageTypes);
                                        break;
                                        case 'tables_select':
                                        case 'tables_modify':
                                                $tables = explode(',',$v);
-                                               reset($tables);
-                                               while(list($kk,$vv)=each($tables))      {
-                                                       if ($vv)        {
-                                                               $tables[$kk]='<span class="nobr">'.t3lib_iconWorks::getIconImage($vv,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>';
+                                               foreach ($tables as &$vv) {
+                                                       if ($vv) {
+                                                               $vv = '<span class="nobr">'.t3lib_iconWorks::getIconImage($vv,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>';
                                                        }
                                                }
                                                $out[$k] = implode('<br />',$tables);
                                        break;
                                        case 'non_exclude_fields':
                                                $nef = explode(',',$v);
-                                               reset($nef);
                                                $table='';
                                                $pout=array();
-                                               while(list($kk,$vv)=each($nef)) {
-                                                       if ($vv)        {
+                                               foreach ($nef as $vv) {
+                                                       if ($vv) {
                                                                list($thisTable,$field) = explode(':',$vv);
                                                                if ($thisTable!=$table) {
                                                                        $table=$thisTable;
@@ -651,7 +667,7 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                                                        $pout[]='<span class="nobr">'.t3lib_iconWorks::getIconImage($table,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']).'</span>';
                                                                }
                                                                if ($GLOBALS['TCA'][$table]['columns'][$field]) {
-                                                                       $pout[]='<span class="nobr"> - '.ereg_replace(':$','',$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label'])).'</span>';
+                                                                       $pout[]='<span class="nobr"> - '.rtrim($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label']), ':').'</span>';
                                                                }
                                                        }
                                                }
@@ -660,11 +676,10 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                        case 'groupList':
                                        case 'firstMainGroup':
                                                $uGroups = explode(',',$v);
-                                               reset($uGroups);
                                                $table='';
                                                $pout=array();
-                                               while(list($kk,$vv)=each($uGroups))     {
-                                                       if ($vv)        {
+                                               foreach ($uGroups as $vv) {
+                                                       if ($vv) {
                                                                $uGRow = t3lib_BEfunc::getRecord('be_groups',$vv);
                                                                $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>';
                                                        }
@@ -673,11 +688,10 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                        break;
                                        case 'modules':
                                                $mods = explode(',',$v);
-                                               reset($mods);
                                                $mainMod='';
                                                $pout=array();
-                                               while(list($kk,$vv)=each($mods))        {
-                                                       if ($vv)        {
+                                               foreach ($mods as $vv) {
+                                                       if ($vv) {
                                                                list($thisMod,$subMod) = explode('_',$vv);
                                                                if ($thisMod!=$mainMod) {
                                                                        $mainMod=$thisMod;
@@ -700,7 +714,7 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                                $tmpl->bType='';
                                                $tmpl->ext_expandAllNotes=1;
                                                $tmpl->ext_noPMicons=1;
-                                               $out[$k] = $tmpl->ext_getObjTree($v,'','');
+                                               $out[$k] = $tmpl->ext_getObjTree($v,'','','','','1');
                                        break;
                                        case 'userTS_hl':
                                                $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
@@ -722,11 +736,11 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                                );
 
                                                        // Traverse types:
-                                               foreach($theTypes as $tableFieldKey => $theTypeArrays)  {
+                                               foreach ($theTypes as $tableFieldKey => $theTypeArrays) {
                                                        if (is_array($theTypeArrays['items']))  {
                                                                $pout[] = '<b>'.$theTypeArrays['tableFieldLabel'].'</b>';
                                                                        // Traverse options for this field:
-                                                               foreach($theTypeArrays['items'] as $itemValue => $itemContent)  {
+                                                               foreach ($theTypeArrays['items'] as $itemValue => $itemContent) {
                                                                        $v = $tableFieldKey.':'.$itemValue.':'.$itemContent[0];
                                                                        if (isset($nef[$v]))    {
                                                                                unset($nef[$v]);
@@ -757,10 +771,14 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                                $items = t3lib_BEfunc::getSystemLanguages();
 
                                                        // Traverse values:
-                                               foreach($items as $iCfg)        {
+                                               foreach ($items as $iCfg)       {
                                                        if (isset($nef[$iCfg[1]]))      {
                                                                unset($nef[$iCfg[1]]);
-                                                               $icon = '<img src="'.$GLOBALS['BACK_PATH'].$iCfg[2].'" class="absmiddle" style="margin-right: 5px;" alt="" />';
+                                                               if (strlen($iCfg[2]))   {
+                                                                       $icon = '<img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$iCfg[2]).' class="absmiddle" style="margin-right: 5px;" alt="" />';
+                                                               } else {
+                                                                       $icon = '';
+                                                               }
                                                                $pout[] = $icon.$iCfg[0];
                                                        }
                                                }
@@ -773,6 +791,12 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                                        // Implode for display:
                                                $out[$k] = implode('<br />',$pout);
                                        break;
+                                       case 'workspace_perms':
+                                               $out[$k] = implode('<br/>',explode(', ',t3lib_BEfunc::getProcessedValue('be_users','workspace_perms',$v)));
+                                       break;
+                                       case 'workspace_membership':
+                                               $out[$k] = implode('<br/>',$this->ext_workspaceMembership());
+                                       break;
                                        case 'custom_options':
 
                                                        // Explode and flip values:
@@ -782,10 +806,10 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                                        // Initialize:
                                                $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
                                                if (is_array($customOptions))   {
-                                                       foreach($customOptions as $coKey => $coValue) {
+                                                       foreach ($customOptions as $coKey => $coValue) {
                                                                if (is_array($coValue['items']))        {
                                                                                // Traverse items:
-                                                                       foreach($coValue['items'] as $itemKey => $itemCfg)      {
+                                                                       foreach ($coValue['items'] as $itemKey => $itemCfg)     {
                                                                                $v = $coKey.':'.$itemKey;
                                                                                if (isset($nef[$v]))    {
                                                                                        unset($nef[$v]);
@@ -839,8 +863,7 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                'HTML'=>t3lib_iconWorks::getIconImage('pages',$row,$GLOBALS['BACK_PATH'],'align="top" title="['.$row['uid'].']"')       // .htmlspecialchars($row['title'])
                        );
                }
-               $className=t3lib_div::makeInstanceClassName('printAllPageTree_perms');
-               $pp = new $className($this);
+               $pp = t3lib_div::makeInstance('printAllPageTree_perms', $this);
                return $pp->printTree($dat,1);
        }
 
@@ -881,58 +904,99 @@ class local_beUserAuth extends t3lib_beUserAuth {
        /**
         * Creates uInfo array for the user.
         *
+        * @param       array           Might contain array where keys/values indicate whether to render a certain value
         * @return      array           Array with the information of the user for each analysis topic.
         */
-       function ext_compileUserInfoForHash()   {
+       function ext_compileUserInfoForHash($filter=NULL)       {
                $uInfo=array();
+               $renderAll = !is_array($filter);
 
                        // Filemounts:
-               $uInfo['filemounts']=$this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts'])));
+               if ($renderAll || $filter['filemounts'])        {
+                       $uInfo['filemounts'] = $this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts'])));
+               }
 
                        // DBmounts:
-               $uInfo['webmounts']=$this->ext_uniqueAndSortList($this->groupData['webmounts']);
+               if ($renderAll || $filter['webmounts']) {
+                       $uInfo['webmounts'] = $this->ext_uniqueAndSortList($this->groupData['webmounts']);
+               }
 
                        // Sharing Upload Folder
-               $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
-               $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
-               $uInfo['tempPath'] = $fileProcessor->findTempFolder();  // The closest TEMP-path is found
+               if ($renderAll || $filter['tempPath'])  {
+                       $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
+                       $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
+                       $uInfo['tempPath'] = $fileProcessor->findTempFolder();  // The closest TEMP-path is found
+               }
 
                        // First Main Group:
-               $uInfo['firstMainGroup']=$this->firstMainGroup;
+               if ($renderAll || $filter['firstMainGroup'])    {
+                       $uInfo['firstMainGroup'] = $this->firstMainGroup;
+               }
 
                        // Group List:
-//             $uInfo['groupList']=$this->ext_uniqueAndSortList($this->groupList);
-               $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.
+               if ($renderAll || $filter['groupList']) {
+                       $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.
+               }
 
                        // Page Types:
-               $uInfo['pagetypes_select']=$this->ext_uniqueAndSortList($this->groupData['pagetypes_select']);
+               if ($renderAll || $filter['pagetypes_select'])  {
+                       $uInfo['pagetypes_select'] = $this->ext_uniqueAndSortList($this->groupData['pagetypes_select']);
+               }
 
                        // Tables select:
-               $uInfo['tables_select']=$this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']);
+               if ($renderAll || $filter['tables_select'])     {
+                       $uInfo['tables_select'] = $this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']);
+               }
 
                        // Tables modify:
-               $uInfo['tables_modify']=$this->ext_uniqueAndSortList($this->groupData['tables_modify']);
+               if ($renderAll || $filter['tables_modify'])     {
+                       $uInfo['tables_modify'] = $this->ext_uniqueAndSortList($this->groupData['tables_modify']);
+               }
 
                        // Non-exclude fields:
-               $uInfo['non_exclude_fields']=$this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']);
+               if ($renderAll || $filter['non_exclude_fields'])        {
+                       $uInfo['non_exclude_fields'] = $this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']);
+               }
 
                        // Explicit Allow/Deny:
-               $uInfo['explicit_allowdeny']=$this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']);
+               if ($renderAll || $filter['explicit_allowdeny'])        {
+                       $uInfo['explicit_allowdeny'] = $this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']);
+               }
 
                        // Limit to languages:
-               $uInfo['allowed_languages']=$this->ext_uniqueAndSortList($this->groupData['allowed_languages']);
+               if ($renderAll || $filter['allowed_languages']) {
+                       $uInfo['allowed_languages'] = $this->ext_uniqueAndSortList($this->groupData['allowed_languages']);
+               }
+
+                       // Workspace permissions
+               if ($renderAll || $filter['workspace_perms'])   {
+                       $uInfo['workspace_perms'] = $this->ext_uniqueAndSortList($this->groupData['workspace_perms']);
+               }
+
+                       // Workspace membership
+               if ($renderAll || $filter['workspace_membership'])      {
+                       $uInfo['workspace_membership'] = $this->ext_workspaceMembership();
+               }
 
                        // Custom options:
-               $uInfo['custom_options']=$this->ext_uniqueAndSortList($this->groupData['custom_options']);
+               if ($renderAll || $filter['custom_options'])    {
+                       $uInfo['custom_options'] = $this->ext_uniqueAndSortList($this->groupData['custom_options']);
+               }
 
                        // Modules:
-               $uInfo['modules']=$this->ext_uniqueAndSortList($this->groupData['modules']);
+               if ($renderAll || $filter['modules'])   {
+                       $uInfo['modules'] = $this->ext_uniqueAndSortList($this->groupData['modules']);
+               }
 
                        // User TS:
                $this->ext_ksortArrayRecursive($this->userTS);
-               $uInfo['userTS'] = $this->userTS;
+               if ($renderAll || $filter['userTS'])    {
+                       $uInfo['userTS'] = $this->userTS;
+               }
 
-               $uInfo['userTS_hl'] = $this->userTS_text;
+               if ($renderAll || $filter['userTS_hl']) {
+                       $uInfo['userTS_hl'] = $this->userTS_text;
+               }
 
                return $uInfo;
        }
@@ -959,10 +1023,49 @@ class local_beUserAuth extends t3lib_beUserAuth {
         */
        function ext_ksortArrayRecursive(&$arr) {
                krsort($arr);
-               reset($arr);
-               while(list($k,$v)=each($arr))   {
-                       if (is_array($v))       $this->ext_ksortArrayRecursive($arr[$k]);
+               foreach ($arr as &$v) {
+                       if (is_array($v)) {
+                               $this->ext_ksortArrayRecursive($v);
+                       }
+               }
+       }
+
+       /**
+        * Returns all workspaces that are accessible for the BE_USER
+        *
+        * @return      array   with key / value pairs of available workspaces (filtered by BE_USER check)
+        */
+       function ext_workspaceMembership()      {
+                       // Create accessible workspace arrays:
+               $options = array();
+               if ($this->checkWorkspace(array('uid' => 0)))   {
+                       $options[0] = '0: ' . $GLOBALS['LANG']->getLL('live', true);
+               }
+               if ($this->checkWorkspace(array('uid' => -1)))  {
+                       $options[-1] = '-1: ' . $GLOBALS['LANG']->getLL('defaultDraft', true);
+               }
+
+                       // Add custom workspaces (selecting all, filtering by BE_USER check):
+               $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers,db_mountpoints','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
+               if (count($workspaces)) {
+                       foreach ($workspaces as $rec)   {
+                               if ($this->checkWorkspace($rec))        {
+                                       $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
+
+                                               // Check if all mount points are accessible, otherwise show error:
+                                       if (trim($rec['db_mountpoints'])!=='')  {
+                                               $mountPoints = t3lib_div::intExplode(',',$this->workspaceRec['db_mountpoints'],1);
+                                               foreach ($mountPoints as $mpId) {
+                                                       if (!$this->isInWebMount($mpId,'1=1'))  {
+                                                               $options[$rec['uid']].= '<br> \- ' . $GLOBALS['LANG']->getLL('notAccessible', true) . ' ' . $mpId;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
                }
+
+               return $options;
        }
 }
 
@@ -988,16 +1091,24 @@ class SC_mod_tools_be_user_index {
        var $MCONF=array();
        var $MOD_MENU=array();
        var $MOD_SETTINGS=array();
+
+       /**
+        * document emplate object
+        *
+        * @var noDoc
+        */
        var $doc;
 
        var $include_once=array();
        var $content;
 
+
        /**
-        * @return      [type]          ...
+        * Basic initialization of the class
+        *
+        * @return      void
         */
        function init() {
-               global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
                $this->MCONF = $GLOBALS['MCONF'];
 
                $this->menuConfig();
@@ -1007,87 +1118,109 @@ class SC_mod_tools_be_user_index {
                // **************************
                // Initializing
                // **************************
-               $this->doc = t3lib_div::makeInstance('noDoc');
-               $this->doc->form='<form action="" method="POST">';
-               $this->doc->backPath = $BACK_PATH;
+               $this->doc = t3lib_div::makeInstance('template');
+               $this->doc->backPath = $GLOBALS['BACK_PATH'];
+               $this->doc->setModuleTemplate('templates/beuser.html');
+               $this->doc->form = '<form action="" method="post">';
+
                                // JavaScript
                $this->doc->JScode = $this->doc->wrapScriptTags('
                        script_ended = 0;
                        function jumpToUrl(URL) {       //
-                               document.location = URL;
+                               window.location.href = URL;
                        }
-               ');
+               ' . $this->doc->redirectUrls());
        }
 
        /**
-        * [Describe function...]
+        * Initialization of the module menu configuration
         *
-        * @return      [type]          ...
+        * @return      void
         */
        function menuConfig()   {
-               global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
-
                // MENU-ITEMS:
                        // If array, then it's a selector box menu
                        // If empty string it's just a variable, that'll be saved.
                        // Values NOT in this array will not be saved in the settings-array for the module.
                $this->MOD_MENU = array(
                        'function' => array(
-                               'compare' => 'Compare User Settings'
+                               'compare' => $GLOBALS['LANG']->getLL('compareUserSettings', true),
+                               'whoisonline' => $GLOBALS['LANG']->getLL('listUsersOnline', true)
                        )
                );
-                       // CLEANSE SETTINGS
+                       // CLEAN SETTINGS
                $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
        }
 
        /**
-        * [Describe function...]
+        * This functions builds the content of the page
         *
-        * @return      [type]          ...
+        * @return      void
         */
        function main() {
-               global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
-
                $this->content='';
-               $this->content.=$this->doc->startPage('Backend User Administration');
-
-               $menu=t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
 
-               $this->content.=$this->doc->header('Backend User Administration');
+               $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('backendUserAdministration', true));
                $this->content.=$this->doc->spacer(5);
-               $this->content.=$this->doc->section('',$menu).$this->doc->divider(5);
 
                switch($this->MOD_SETTINGS['function']) {
                        case 'compare':
                                if (t3lib_div::_GP('ads'))      {
                                        $compareFlags = t3lib_div::_GP('compareFlags');
-                                       $BE_USER->pushModuleData('tools_beuser/index.php/compare',$compareFlags);
+                                       $GLOBALS['BE_USER']->pushModuleData('tools_beuser/index.php/compare',$compareFlags);
                                } else {
-                                       $compareFlags = $BE_USER->getModuleData('tools_beuser/index.php/compare','ses');
+                                       $compareFlags = $GLOBALS['BE_USER']->getModuleData('tools_beuser/index.php/compare','ses');
                                }
                                $this->content.=$this->compareUsers($compareFlags);
                        break;
+                       case 'whoisonline':
+                               $this->content.=$this->whoIsOnline();
+                       break;
                }
-
-
-               if ($BE_USER->mayMakeShortcut())        {
-                       $this->content.=$this->doc->spacer(20).
-                                               $this->doc->section('',$this->doc->makeShortcutIcon('be_user_uid,compareFlags','function',$this->MCONF['name']));
-               }
+                       // Setting up the buttons and markers for docheader
+               $docHeaderButtons = $this->getButtons();
+               //$markers['CSH'] = $docHeaderButtons['csh'];
+               $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
+               $markers['CONTENT'] = $this->content;
+
+                       // Build the <body> for the module
+               $this->content = $this->doc->startPage('Backend User Administration');
+               $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
        }
 
        /**
-        * [Describe function...]
+        * Prints the content of the page
         *
-        * @return      [type]          ...
+        * @return      void
         */
        function printContent() {
-
-               $this->content.=$this->doc->endPage();
                echo $this->content;
        }
 
+       /**
+        * Create the panel of buttons for submitting the form or otherwise perform operations.
+        *
+        * @return      array   all available buttons as an assoc. array
+        */
+       protected function getButtons() {
+
+               $buttons = array(
+                       'csh' => '',
+                       'shortcut' => '',
+                       'save' => ''
+               );
+                       // CSH
+               //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
+
+                       // Shortcut
+               if ($GLOBALS['BE_USER']->mayMakeShortcut())     {
+                       $buttons['shortcut'] = $this->doc->makeShortcutIcon('be_user_uid,compareFlags','function', $this->MCONF['name']);
+               }
 
+               return $buttons;
+       }
 
 
 
@@ -1100,28 +1233,31 @@ class SC_mod_tools_be_user_index {
         ***************************/
 
        /**
-        * @param       [type]          $compareFlags: ...
-        * @return      [type]          ...
+        * Compares the users with the given flags
+        *
+        * @param       array           options that should be taking into account to compare the users
+        * @return      string          the content
         */
        function compareUsers($compareFlags)    {
-               global $SOBE;
                        // Menu:
                $options = array(
-                       'filemounts' => 'Filemounts',
-                       'webmounts' => 'Webmounts',
-                       'tempPath' => 'Default upload path',
-                       'firstMainGroup' => 'Main user group',
-                       'groupList' => 'Member of groups',
-                       'pagetypes_select' => 'Page types access',
-                       'tables_select' => 'Select tables',
-                       'tables_modify' => 'Modify tables',
-                       'non_exclude_fields' => 'Non-exclude fields',
-                       'explicit_allowdeny' => 'Explicit Allow/Deny',
-                       'allowed_languages' => 'Limit to languages',
-                       'custom_options' => 'Custom options',
-                       'modules' => 'Modules',
-                       'userTS' => 'TSconfig',
-                       'userTS_hl' => 'TSconfig HL',
+                       'filemounts' => $GLOBALS['LANG']->getLL('filemounts', true),
+                       'webmounts' => $GLOBALS['LANG']->getLL('webmounts', true),
+                       'tempPath' => $GLOBALS['LANG']->getLL('defaultUploadPath', true),
+                       'firstMainGroup' => $GLOBALS['LANG']->getLL('mainUserGroup', true),
+                       'groupList' => $GLOBALS['LANG']->getLL('memberOfGroups', true),
+                       'pagetypes_select' => $GLOBALS['LANG']->getLL('pageTypesAccess', true),
+                       'tables_select' => $GLOBALS['LANG']->getLL('selectTables', true),
+                       'tables_modify' => $GLOBALS['LANG']->getLL('modifyTables', true),
+                       'non_exclude_fields' => $GLOBALS['LANG']->getLL('nonExcludeFields', true),
+                       'explicit_allowdeny' => $GLOBALS['LANG']->getLL('explicitAllowDeny', true),
+                       'allowed_languages' => $GLOBALS['LANG']->getLL('limitToLanguages', true),
+                       'workspace_perms' => $GLOBALS['LANG']->getLL('workspacePermissions', true),
+                       'workspace_membership' => $GLOBALS['LANG']->getLL('workspaceMembership', true),
+                       'custom_options' => $GLOBALS['LANG']->getLL('customOptions', true),
+                       'modules' => $GLOBALS['LANG']->getLL('modules', true),
+                       'userTS' => $GLOBALS['LANG']->getLL('tsconfig', true),
+                       'userTS_hl' => $GLOBALS['LANG']->getLL('tsconfigHL', true),
                );
 
                $be_user_uid = t3lib_div::_GP('be_user_uid');
@@ -1137,8 +1273,7 @@ class SC_mod_tools_be_user_index {
                        $uInfo_dat = $tempBE_USER->ext_printOverview($uInfo,$options,1);
 
                        $lines=array();
-                       reset($options);
-                       while(list($kk,$vv)=each($options))     {
+                       foreach ($options as $kk => $vv) {
                                if ($kk=='modules')     {
                                        $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
                                        $loadModules->load($GLOBALS['TBE_MODULES'],$tempBE_USER);
@@ -1152,35 +1287,48 @@ class SC_mod_tools_be_user_index {
 
                                if ($kk=='webmounts' && !$tempBE_USER->isAdmin())       {
                                        $lines[]='<tr class="bgColor4">
-                                               <td nowrap="nowrap" valign="top">Non-mounted readable pages:&nbsp;&nbsp;</td>
+                                               <td nowrap="nowrap" valign="top">' . $GLOBALS['LANG']->getLL('nonMountedReadablePages', true) . '&nbsp;&nbsp;</td>
                                                <td>'.$tempBE_USER->ext_getReadableButNonmounted().'&nbsp;</td>
                                        </tr>';
                                }
                        }
 
-                       $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>';
-                       $outTable.= '<td>'.$tempBE_USER->user['realName'].($tempBE_USER->user['email'] ? ', <a href="mailto:'.$tempBE_USER->user['email'].'">'.$tempBE_USER->user['email'].'</a>' : '').'</td>';
+                       $email = htmlspecialchars($tempBE_USER->user['email']);
+                       $realname = htmlspecialchars($tempBE_USER->user['realName']);
+                       $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'].'"').htmlspecialchars($tempBE_USER->user['username']).'</td>';
+                       $outTable.= '<td>'.($realname?$realname.', ':'').($email ? '<a href="mailto:'.$email.'">'.$email.'</a>' : '').'</td>';
                        $outTable.= '<td>'.$this->elementLinks('be_users',$tempBE_USER->user).'</td></tr></table>';
-                       $outTable.= '<strong><a href="index.php">&lt; Back to overview</a></strong><br />';
+                       $outTable.= '<strong><a href="'.htmlspecialchars($this->MCONF['_']).'">' . $GLOBALS['LANG']->getLL('backToOverview', true) . '</a></strong><br />';
 
                        $outTable.= '<br /><table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
-                       $content.= $this->doc->section('User info',$outTable,0,1);
+                       $content.= $this->doc->section($GLOBALS['LANG']->getLL('userInfo', true),$outTable,0,1);
                } else {
-                       reset($options);
-                       $menu=array();
-                       while(list($kk,$vv)=each($options))     {
-                               $menu[]='<input type="checkbox" value="1" name="compareFlags['.$kk.']"'.($compareFlags[$kk]?' checked="checked"':'').'>'.htmlspecialchars($vv);
+                       $menu = array(0 => array());
+                       $rowCounter = 0;
+                       $columnCounter = 0;
+                       $itemsPerColumn = ceil(count($options) / 3);
+                       foreach ($options as $kk => $vv) {
+                               if ($rowCounter == $itemsPerColumn)     {
+                                       $rowCounter = 0;
+                                       $columnCounter++;
+                                       $menu[$columnCounter] = array();
+                               }
+                               $rowCounter++;
+                               $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>';
                        }
-                       $outCode = 'Group by:<br />'.implode('<br />',$menu);
-                       $outCode.='<br /><input type="submit" name="ads" value="Update">';
-                       $content = $this->doc->section('Group and Compare Users',$outCode,0,1);
+                       $outCode = '<p>' . $GLOBALS['LANG']->getLL('groupBy', true) . '</p>';
+                       $outCode .= '<table border="0" cellpadding="3" cellspacing="1" class="compare-checklist valign-top"><tr>';
+                       foreach ($menu as $column)      {
+                               $outCode .= '<td>' . implode('<br />', $column) . '</td>';
+                       }
+                       $outCode .= '</tr></table>';
+                       $outCode.='<br /><input type="submit" name="ads" value="' . $GLOBALS['LANG']->getLL('update', true) . '">';
+                       $content = $this->doc->section($GLOBALS['LANG']->getLL('groupAndCompareUsers', true),$outCode,0,1);
 
 
                                // Traverse all users
                        $users = t3lib_BEfunc::getUserNames();
                        $comparation=array();
-       //              debug($users);
-                       reset($users);
                        $counter=0;
 
 
@@ -1188,10 +1336,11 @@ class SC_mod_tools_be_user_index {
                        $numberAtTime=1000;
                        $tooManyUsers='';
 
-                       while(list(,$r)=each($users))   {
+                       foreach ($users as $r) {
                                if ($counter>=$offset)  {
                                                // This is used to test with other users. Development ONLY!
                                        $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth');     // New backend user object
+                                       /* @var $tempBE_USER local_beUserAuth */
                                        $tempBE_USER->OS = TYPO3_OS;
                                        $tempBE_USER->setBeUserByUid($r['uid']);
                                        $tempBE_USER->fetchGroupData();
@@ -1199,9 +1348,8 @@ class SC_mod_tools_be_user_index {
                                                // Making group data
                                        $md5pre='';
                                        $menu=array();
-                                       $uInfo = $tempBE_USER->ext_compileUserInfoForHash();
-                                       reset($options);
-                                       while(list($kk,$vv)=each($options))     {
+                                       $uInfo = $tempBE_USER->ext_compileUserInfoForHash((array)$compareFlags);
+                                       foreach ($options as $kk => $vv) {
                                                if ($compareFlags[$kk]) {
                                                        $md5pre.=serialize($uInfo[$kk]).'|';
                                                }
@@ -1212,12 +1360,12 @@ class SC_mod_tools_be_user_index {
                                                $comparation[$md5]=$tempBE_USER->ext_printOverview($uInfo,$compareFlags);
                                                $comparation[$md5]['users']=array();
                                        }
-                                       $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']);
+                                       $comparation[$md5]['users'][]=$tempBE_USER->user;
                                        unset($tempBE_USER);
                                }
                                $counter++;
                                if ($counter>=($numberAtTime+$offset)) {
-                                       $tooManyUsers='There were more than '.$numberAtTime.' users (total: '.count($users).') and this tool can display only '.$numberAtTime.' at a time!';
+                                       $tooManyUsers=$GLOBALS['LANG']->getLL('tooManyUsers', true) . ' ' . count($users) . '. ' . $GLOBALS['LANG']->getLL('canOnlyDisplay', true) . ' ' . $numberAtTime . '.';
                                        break;
                                }
                        }
@@ -1226,30 +1374,38 @@ class SC_mod_tools_be_user_index {
                        $allGroups=array();
                                // Header:
                        $allCells = array();
-                       reset($options);
-                       $allCells['USERS'] = '<b>Usernames:</b>';
-                       while(list($kk,$vv)=each($options))     {
+
+                       $link_createNewUser='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[be_users][0]=new',$this->doc->backPath,-1)).'">'.
+                               '<img' . t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_el.gif') . ' title="' . $GLOBALS['LANG']->getLL('newUser', true) . '" alt="" />'.
+                               '</a>';
+
+                       $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><td><b>' . $GLOBALS['LANG']->getLL('usernames', true) . '</b></td><td width="12">' . $link_createNewUser . '</td></tr></table>';
+
+                       foreach ($options as $kk => $vv) {
                                if ($compareFlags[$kk]) {
                                        $allCells[$kk] = '<b>'.$vv.':</b>';
                                }
                        }
                        $allGroups[]=$allCells;
 
-                       reset($comparation);
-                       while(list(,$dat)=each($comparation))   {
+                       foreach ($comparation as $dat) {
                                $allCells = array();
 
+                               $curUid = $GLOBALS['BE_USER']->user['uid'];
                                $uListArr=array();
-                               reset($dat['users']);
-                               while(list(,$uDat)=each($dat['users'])) {
-                                       $uListArr[] = '<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).
-                                               '<a href="'.t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'])).'" target="_top"><img src="'.$GLOBALS['BACK_PATH'].'gfx/su.gif" width="18" height="11" border="0" align="top" title="'.htmlspecialchars('Switch User to: '.$uDat['username']).'" alt="" /></a>'.
-                                               '</td></tr>';
+
+                               foreach ($dat['users'] as $uDat) {
+                                       $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);
+                                       if ($curUid != $uDat['uid'] && !$uDat['disable'] && ($uDat['starttime'] == 0 || $uDat['starttime'] < time()) && ($uDat['endtime'] == 0 || $uDat['endtime'] > time()))   {
+                                               $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($GLOBALS['LANG']->getLL('switchUserTo', true) . ' ' . $uDat['username']) . ' ' . $GLOBALS['LANG']->getLL('changeToMode', true) . '" alt="" /></a>'.
+                                                       '<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($GLOBALS['LANG']->getLL('switchUserTo', true) . ' ' . $uDat['username']) . ' ' . $GLOBALS['LANG']->getLL('switchBackMode', true) . '" alt="" /></a>';
+                                       }
+                                       $uItem .= '</td></tr>';
+                                       $uListArr[] = $uItem;
                                }
                                $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>';
 
-                               reset($options);
-                               while(list($kk,$vv)=each($options))     {
+                               foreach ($options as $kk => $vv) {
                                        if ($compareFlags[$kk]) {
                                                $allCells[$kk] = $dat[$kk];
                                        }
@@ -1259,78 +1415,80 @@ class SC_mod_tools_be_user_index {
 
                                // Make table
                        $outTable='';
-                       reset($allGroups);
                        $TDparams=' nowrap="nowrap" class="bgColor5" valign="top"';
-                       while(list(,$allCells)=each($allGroups))        {
+                       $i = 0;
+                       foreach ($allGroups as $allCells) {
                                $outTable.='<tr><td'.$TDparams.'>'.implode('</td><td'.$TDparams.'>',$allCells).'</td></tr>';
-                               $TDparams=' nowrap="nowrap" class="bgColor4" valign="top"';
+                               $TDparams=' nowrap="nowrap" class="'.($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6').'" valign="top"';
                        }
-                       $outTable='<table border="0" cellpadding="2" cellspacing="2">'.$outTable.'</table>';
-                       $outTable.=fw('<br /><br />(All cached group lists updated.)');
-                       $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">'.$tooManyUsers.'</span></strong>':'';
+                       $outTable='<table border="0" cellpadding="2" cellspacing="2">' . $outTable . '</table>';
+                       $outTable.=fw('<br /><br />' . $GLOBALS['LANG']->getLL('cachedGrouplistsUpdated', true) . '');
+                       $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">' . $tooManyUsers . '</span></strong>':'';
                        $content.= $this->doc->spacer(10);
-                       $content.= $this->doc->section('Result',$outTable,0,1);
+                       $content.= $this->doc->section($GLOBALS['LANG']->getLL('result', true),$outTable,0,1);
                }
                return $content;
        }
 
+
        /**
-        * [Describe function...]
+        * Creates a HTML anchor to the user record
         *
-        * @param       [type]          $str: ...
-        * @param       [type]          $rec: ...
-        * @return      [type]          ...
+        * @param       string          the string used to identify the user (inside the <a>...</a>)
+        * @param       array           the BE user record to link
+        * @return      string          the HTML anchor
         */
        function linkUser($str,$rec)    {
-               return '<a href="index.php?be_user_uid='.$rec['uid'].'">'.$str.'</a>';
+               return '<a href="'.htmlspecialchars($this->MCONF['_']).'&be_user_uid='.$rec['uid'].'">' . htmlspecialchars($str) . '</a>';
        }
 
+
        /**
-        * [Describe function...]
+        * Builds a list of all links for a specific element (here: BE user) and returns it for print.
         *
-        * @param       [type]          $table: ...
-        * @param       [type]          $row: ...
-        * @return      [type]          ...
+        * @param       string          the db table that should be used
+        * @param       array           the BE user record to use
+        * @return      string          a HTML formatted list of the link
         */
        function elementLinks($table,$row)      {
-               global $TCA;
                        // Info:
-               $cells[]='<a href="#" onclick="top.launchView(\''.$table.'\', \''.$row['uid'].'\',\''.$GLOBALS['BACK_PATH'].'\'); return false;"><img src="'.$GLOBALS['BACK_PATH'].'gfx/zoom2.gif" width="12" height="12" border="0" align="top" title="Show information" alt="" /></a>';
+               $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="' . $GLOBALS['LANG']->getLL('showInformation', true) . '" alt="" /></a>';
 
                        // Edit:
-               $params='&edit['.$table.']['.$row['uid'].']=edit';
-               $cells[]='<a href="#" onclick="'.t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'],'').'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/edit2.gif" width="11" height="12" border="0" align="top" title="Edit" alt="" /></a>';
+               $params='&edit[' . $table . '][' . $row['uid'] . ']=edit';
+               $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="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit', true) . '" alt="" /></a>';
 
                        // Hide:
-               $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
+               $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
                if ($row[$hiddenField]) {
-                       $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
-                       $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/button_unhide.gif" width="11" height="10" border="0" title="Disable" align="top" alt="" /></a>';
+                       $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=0';
+                       $cells[]='<a href="' . $this->doc->issueCommand($params) . '"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/button_unhide.gif') . ' border="0" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:enable', true) . '" align="top" alt="" /></a>';
                } else {
-                       $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
-                       $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/button_hide.gif" width="11" height="10" border="0" title="Disable" align="top" alt="" /></a>';
+                       $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=1';
+                       $cells[]='<a href="' . $this->doc->issueCommand($params) . '"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/button_hide.gif') . ' border="0" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disable', true) . '" align="top" alt="" /></a>';
                }
 
                        // Delete
-               $params='&cmd['.$table.']['.$row['uid'].'][delete]=1';
-               $cells[]='<a href="'.$this->doc->issueCommand($params).'" onclick="return confirm(unescape(\''.rawurlencode('Are you sure you want to delete this element?').'\'));"><img src="'.$GLOBALS['BACK_PATH'].'gfx/garbage.gif" width="11" height="12" border="0" align="top" title="Delete(!)" alt="" /></a>';
+               $params='&cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
+               $cells[]='<a href="' . $this->doc->issueCommand($params) . '" onclick="return confirm(unescape(\'' . rawurlencode($GLOBALS['LANG']->getLL('sureToDelete', true)) . '\'));"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/garbage.gif') . ' border="0" align="top" title="' . $GLOBALS['LANG']->getLL('delete', true) . '" alt="" /></a>';
 
                return implode('',$cells);
        }
 
+
        /**
-        * [Describe function...]
+        * Inits all BE-users available, for development ONLY!
         *
-        * @return      [type]          ...
+        * @return      void
         */
        function initUsers()    {
                        // Initializing all users in order to generate the usergroup_cached_list
                $users = t3lib_BEfunc::getUserNames();
-               //debug($users);
-               reset($users);
-               while(list(,$r)=each($users))   {
-                               // This is used to test with other users. Development ONLY!
+
+                       // This is used to test with other users. Development ONLY!
+               foreach ($users as $r) {
                        $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth');     // New backend user object
+                       /* @var $tempBE_USER local_beUserAuth */
                        $tempBE_USER->OS = TYPO3_OS;
                        $tempBE_USER->setBeUserByUid($r['uid']);
                        $tempBE_USER->fetchGroupData();
@@ -1338,48 +1496,115 @@ class SC_mod_tools_be_user_index {
        }
 
        /**
-        * [Describe function...]
+        * Returns the local path for this string (removes the PATH_site if it is included)
         *
-        * @param       [type]          $str: ...
-        * @return      [type]          ...
+        * @param       string          the path that will be checked
+        * @return      string          the local path
         */
        function localPath($str)        {
                if (substr($str,0,strlen(PATH_site))==PATH_site)        {
                        return substr($str,strlen(PATH_site));
-               } else return $str;
+               } else {
+                       return $str;
+               }
        }
 
        /**
-        * [Describe function...]
+        * Switches to a given user (SU-mode) and then redirects to the start page of the backend to refresh the navigation etc.
         *
-        * @param       [type]          $switchUser: ...
-        * @return      [type]          ...
+        * @param       array           BE-user record that will be switched to
+        * @return      void
         */
        function switchUser($switchUser)        {
                $uRec=t3lib_BEfunc::getRecord('be_users',$switchUser);
                if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin())  {
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id="'.$GLOBALS['TYPO3_DB']->quoteStr($GLOBALS['BE_USER']->id, 'be_sessions').'" AND ses_name="be_typo_user" AND ses_userid='.intval($GLOBALS['BE_USER']->user['uid']), array('ses_userid' => $uRec['uid']));
+                       $updateData['ses_userid'] = $uRec['uid'];
+                               // user switchback
+                       if (t3lib_div::_GP('switchBackUser'))   {
+                               $updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']);
+                       }
+                       $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);
 
                        header('Location: '.t3lib_div::locationHeaderUrl($GLOBALS['BACK_PATH'].'index.php'.($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']?'':'?commandLI=1')));
                        exit;
                }
        }
-}
-
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php'])       {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']);
-}
-
-
-
-
-
 
+       /***************************
+        *
+        * "WHO IS ONLINE" FUNCTIONS:
+        *
+        ***************************/
 
+       /**
+        * @author Martin Kutschker
+        */
+       function whoIsOnline()  {
+               $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';
+               $from_table = '(be_sessions, be_users u) LEFT OUTER JOIN be_users bu ON (ses_backuserid=bu.uid)';
+               $where_clause = 'ses_userid=u.uid';
+               $orderBy = 'u.username';
+
+               if (t3lib_div::testInt($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']))    {
+                       $where_clause .= ' AND '.$GLOBALS['EXEC_TIME'].'<(ses_tstamp+'.$GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'].')';
+               } else {
+                       $timeout = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
+                       if ($timeout > 0)       {
+                               $where_clause .= ' AND '.$GLOBALS['EXEC_TIME'].'<(ses_tstamp+'.$timeout.')';
+                       }
+               }
+                       // Fetch active sessions of other users from storage:
+               $sessions = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select_fields,$from_table,$where_clause,'',$orderBy);
+                       // Process and visualized each active session as a table row:
+               if (is_array($sessions)) {
+                       foreach ($sessions as $session) {
+                               $ip = $session['ses_iplock'];
+                               $hostName = '';
+                               if ($session['ses_iplock'] == '[DISABLED]' || $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 0) {
+                                       $ip = '-';
+                               } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 4) {
+                                       $hostName = ' title="' . @gethostbyaddr($session['ses_iplock']) . '"';
+                               } else {
+                                       $ip .= str_repeat('.*', 4-$GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP']);
+                               }
+                               $outTable .= '
+                                       <tr class="bgColor4" height="17" valign="top">' .
+                                               '<td nowrap="nowrap">' .
+                                                       date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $session['ses_tstamp']) .
+                                               '</td>' .
+                                               '<td nowrap="nowrap">' .
+                                                       '<span'.$hostName.'>'.$ip.'</span>' .
+                                               '</td>' .
+                                               '<td width="130">' .
+                                                       t3lib_iconWorks::getIconImage('be_users',$session,$GLOBALS['BACK_PATH'],'align="top" title="'.$session['uid'].'"').htmlspecialchars($session['username']).'&nbsp;' .
+                                               '</td>' .
+                                               '<td nowrap="nowrap">'.htmlspecialchars($session['realName']).'&nbsp;&nbsp;</td>' .
+                                               '<td nowrap="nowrap">'.$this->elementLinks('be_users',$session).'</td>' .
+                                               '<td nowrap="nowrap" valign="top">'.($session['bu_username'] ? '&nbsp;SU from: ' : '').htmlspecialchars($session['bu_username']).'&nbsp;</td>' .
+                                               '<td nowrap="nowrap" valign="top">&nbsp;'.htmlspecialchars($session['bu_realName']).'</td>' .
+                                       '</tr>';
+                       }
+               }
+                       // Wrap <table> tag around the rows:
+               $outTable = '
+               <table border="0" cellpadding="2" cellspacing="2">
+                       <tr class="bgColor5">
+                               <td valign="top"><b>' . $GLOBALS['LANG']->getLL('timestamp', true) . '</b></td>
+                               <td valign="top"><b>' . $GLOBALS['LANG']->getLL('host', true) . '</b></td>
+                               <td valign="top" colspan="5"><b>' . $GLOBALS['LANG']->getLL('username', true) . '</b></td>
+                       </tr>'.$outTable.'
+               </table>';
+
+               $content.= $this->doc->section($GLOBALS['LANG']->getLL('whoIsOnline', true),$outTable,0,1);
+               return $content;
+       }
 
+}
 
 
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php'])       {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']);
+}
 
 
 // Make instance:
@@ -1387,4 +1612,5 @@ $SOBE = t3lib_div::makeInstance('SC_mod_tools_be_user_index');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>