2005-11-12 Sebastian Kurfuerst <sebastian@garbage-group.de>
authorSebastian Kurfürst <sebastian.kurfuerst@typo3.org>
Sat, 12 Nov 2005 19:38:20 +0000 (19:38 +0000)
committerSebastian Kurfürst <sebastian.kurfuerst@typo3.org>
Sat, 12 Nov 2005 19:38:20 +0000 (19:38 +0000)
* New feature 1573: switch back to admin user after user switch
(SU-mode)

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@859 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/stddb/tables.sql
typo3/alt_menu.php
typo3/stylesheet.css
typo3/sysext/beuser/mod/index.php

index f38fe39..b535feb 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-12  Sebastian Kurfuerst  <sebastian@garbage-group.de>
+
+       * New feature 1573: switch back to admin user after user switch (SU-mode)
+
 2005-11-11  Sebastian Kurfuerst  <sebastian@garbage-group.de>
 
        * New feature #1519: new option for lockSSL: get redirected to standard http after BE login with SSL
index fdf143b..afadc4f 100755 (executable)
@@ -50,6 +50,7 @@ CREATE TABLE be_sessions (
   ses_userid int(11) unsigned DEFAULT '0' NOT NULL,
   ses_tstamp int(11) unsigned DEFAULT '0' NOT NULL,
   ses_data mediumblob NOT NULL,
+  ses_backuserid int(11) NOT NULL default '0',
   PRIMARY KEY (ses_id,ses_name)
 );
 
index b7c4044..9d120bf 100755 (executable)
@@ -162,6 +162,12 @@ class SC_alt_menu {
 ';
                }
 
+                       // superuser mode
+               if($BE_USER->user['ses_backuserid']) {
+                       $username = '<p id="username" class="typo3-red-background">[SU: '.htmlspecialchars($BE_USER->user['username']).']</p>';
+               } else {
+                       $username = '<p id="username">['.htmlspecialchars($BE_USER->user['username']).']</p>';
+               }
                        // Printing bottons (logout button)
                $this->content.='
 
@@ -169,8 +175,7 @@ class SC_alt_menu {
 <!--
   Logout button / username
 -->
-<div id="typo3-alt-menu-php-logininfo">'.$alt_menuObj->topButtons().
-                                               '<p id="username">['.htmlspecialchars($BE_USER->user['username']).']</p>
+<div id="typo3-alt-menu-php-logininfo">'.$alt_menuObj->topButtons().$username.'                                
 </div>';
 
                        // End page:
index 7f66e31..43ba7f5 100755 (executable)
@@ -486,6 +486,7 @@ TABLE.ver-subtree TR.typo3-ver-noComp TD { font-style : italic; }
 
 /* Red span tag color (warning, notice) */
 .typo3-red {color: red;}
+.typo3-red-background {background-color: red;}
 TABLE.warningbox { border: solid 2px black; background-color: yellow; margin: 20px 0px 20px 0px; }
 TABLE.warningbox TD { padding: 20px 20px 20px 20px; font-weight: bold; }
 
index 593e1a4..2e19994 100755 (executable)
@@ -1247,11 +1247,11 @@ class SC_mod_tools_be_user_index {
                                // Header:
                        $allCells = array();
                        reset($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','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('new',1).'" alt="" />'.
                                '</a>';
-                       
+
                        $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><td><b>Usernames:</b></td><td width="12">'.$link_createNewUser.'</td></tr></table>';
 
                        while(list($kk,$vv)=each($options))     {
@@ -1270,6 +1270,7 @@ class SC_mod_tools_be_user_index {
                                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>'.
+                                               '<a href="'.t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'], 'switchBackUser' => 1)).'" 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']).' [SU-mode]" alt="" style="background-color:red;" /></a>'.
                                                '</td></tr>';
                                }
                                $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>';
@@ -1384,7 +1385,12 @@ class SC_mod_tools_be_user_index {
        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']->fullQuoteStr($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;