[!!!][TASK] Remove SU mode "change to" in EXT:beuser 88/33688/9
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Sat, 1 Nov 2014 12:46:34 +0000 (13:46 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 2 Nov 2014 10:37:33 +0000 (11:37 +0100)
This patch removes the ability to switch to a user permanently.
The user now always gets an "exit" button offered to switch back.

Resolves: #62595
Releases: master
Change-Id: I08925c5249aca30225016ffb047be09b5f48b338
Reviewed-on: http://review.typo3.org/33688
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/beuser/Classes/Controller/BackendUserController.php
typo3/sysext/beuser/Classes/ViewHelpers/SwitchUserViewHelper.php
typo3/sysext/beuser/Resources/Private/Language/locallang.xlf
typo3/sysext/beuser/Resources/Private/Partials/BackendUser/IndexListRow.html
typo3/sysext/core/Documentation/Changelog/master/Breaking-62595-RemovedChangeToSwitchModeFromBeUser.rst [new file with mode: 0644]

index 4f9a815..3321c3c 100644 (file)
@@ -101,12 +101,10 @@ class BackendUserController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
                } else {
                        $this->moduleData->setDemand($demand);
                }
-               // Switch user permanently or only until logout
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SwitchUser')) {
-                       $this->switchUser(
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SwitchUser'),
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('switchBackUser')
-                       );
+               // Switch user until logout
+               $switchUser = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SwitchUser');
+               if ($switchUser > 0) {
+                       $this->switchUser($switchUser);
                }
                $compareUserList = $this->moduleData->getCompareUserList();
                $this->view->assign('demand', $demand);
@@ -198,21 +196,17 @@ class BackendUserController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
         * Switches to a given user (SU-mode) and then redirects to the start page of the backend to refresh the navigation etc.
         *
         * @param string $switchUser BE-user record that will be switched to
-        * @param bool $switchBack
         * @return void
         */
-       protected function switchUser($switchUser, $switchBack = FALSE) {
+       protected function switchUser($switchUser) {
                $targetUser = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('be_users', $switchUser);
                if (is_array($targetUser) && $GLOBALS['BE_USER']->isAdmin()) {
-                       $updateData['ses_userid'] = $targetUser['uid'];
-                       // User switchback or replace current session?
-                       if ($switchBack) {
-                               $updateData['ses_backuserid'] = (int)$GLOBALS['BE_USER']->user['uid'];
-
-                               // Set backend user listing module as starting module for switchback
-                               $GLOBALS['BE_USER']->uc['startModuleOnFirstLogin'] = 'system_BeuserTxBeuser';
-                               $GLOBALS['BE_USER']->writeUC();
-                       }
+                       $updateData['ses_userid'] = (int)$targetUser['uid'];
+                       $updateData['ses_backuserid'] = (int)$GLOBALS['BE_USER']->user['uid'];
+
+                       // Set backend user listing module as starting module for switchback
+                       $GLOBALS['BE_USER']->uc['startModuleOnFirstLogin'] = 'system_BeuserTxBeuser';
+                       $GLOBALS['BE_USER']->writeUC();
 
                        $whereClause = 'ses_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions');
                        $whereClause .= ' AND ses_name=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName(), 'be_sessions');
index 4adb0b2..dba715e 100644 (file)
@@ -25,15 +25,14 @@ class SwitchUserViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractView
         * Render link with sprite icon to change current backend user to target
         *
         * @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser Target backendUser to switch active session to
-        * @param bool $emulate Return to current session or logout after target session termination?
         * @return string
         */
-       public function render(\TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser, $emulate = FALSE) {
+       public function render(\TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser) {
                if ($backendUser->getUid() == $GLOBALS['BE_USER']->user['uid']) {
                        return '';
                }
-               $title = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(($emulate ? 'switchBackMode' : 'changeToMode'), 'beuser');
-               return '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('SwitchUser' => $backendUser->getUid(), 'switchBackUser' => $emulate))) . '" target="_top" title="' . htmlspecialchars($title) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon(('actions-system-backend-user-' . ($emulate ? 'emulate' : 'switch'))) . '</a>';
+               $title = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('switchBackMode', 'beuser');
+               return '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('SwitchUser' => $backendUser->getUid()))) . '" target="_top" title="' . htmlspecialchars($title) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon(('actions-system-backend-user-switch')) . '</a>';
        }
 
 }
index a3cbc93..ab1d18d 100644 (file)
                                <source>[change-to mode]</source>
                        </trans-unit>
                        <trans-unit id="switchBackMode" xml:space="preserve">
-                               <source>[switch-back mode]</source>
+                               <source>Switch to user</source>
                        </trans-unit>
                        <trans-unit id="confirm" xml:space="preserve">
                                <source>Are you sure you want to delete this backend user %s?</source>
                        </trans-unit>
                </body>
        </file>
-</xliff>
\ No newline at end of file
+</xliff>
index c116d37..a14bb99 100644 (file)
@@ -37,8 +37,7 @@
                        Only admin users may use the backend user administration.
                </f:comment>
                <f:if condition="{backendUser.active} == 1">
-                       <bu:SwitchUser backendUser="{backendUser}" emulate="FALSE" />
-                       <bu:SwitchUser backendUser="{backendUser}" emulate="TRUE" />
+                       <bu:SwitchUser backendUser="{backendUser}" />
                </f:if>
        </td>
        <td class="hidden-xs hidden-sm">
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-62595-RemovedChangeToSwitchModeFromBeUser.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-62595-RemovedChangeToSwitchModeFromBeUser.rst
new file mode 100644 (file)
index 0000000..a1ff374
--- /dev/null
@@ -0,0 +1,28 @@
+===========================================
+Breaking: #62595 - Remove SU change-to mode
+===========================================
+
+Description
+===========
+
+The permanent user switch has been removed from backend user list for a better UX.
+
+
+Impact
+======
+
+The parameter "emulate" in the view helper "SwitchUser" is dropped. Using the
+argument causes an error "Argument "emulate" was not registered".
+
+
+Affected installations
+======================
+
+Any installation using an extension that uses the view helper "SwitchUser" with
+"emulate" argument.
+
+
+Migration
+=========
+
+Drop the "emulate" argument in the view helper call.
\ No newline at end of file