[TASK] Backend user management: add delete button 91/21591/7
authorKrzysztof Adamczyk <k.adamczyk@macopedia.pl>
Sat, 22 Jun 2013 13:54:44 +0000 (15:54 +0200)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Tue, 25 Jun 2013 19:09:39 +0000 (21:09 +0200)
Add remove button in the backend users list with
a confirmation dialog.

Resolves: #43053
Releases: 6.2
Change-Id: I5bffc18c4aabdcc597094f4b173c187e8c8ccac2
Reviewed-on: https://review.typo3.org/21591
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
typo3/sysext/beuser/Classes/ViewHelpers/RemoveUserViewHelper.php [new file with mode: 0644]
typo3/sysext/beuser/Resources/Private/Language/locallang.xlf
typo3/sysext/beuser/Resources/Private/Partials/BackendUser/IndexListRow.html

diff --git a/typo3/sysext/beuser/Classes/ViewHelpers/RemoveUserViewHelper.php b/typo3/sysext/beuser/Classes/ViewHelpers/RemoveUserViewHelper.php
new file mode 100644 (file)
index 0000000..f86dee2
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+namespace TYPO3\CMS\Beuser\ViewHelpers;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Krzysztof Adamczyk <k.adamczyk@macopedia.pl>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Displays 'Delete user' link with sprite icon to remove user
+ */
+class RemoveUserViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+
+       /**
+        * Render link with sprite icon to remove user
+        *
+        * @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser Target backendUser to switch active session to
+        * @return string
+        */
+       public function render(\TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser) {
+               if ($backendUser->getUid() == $GLOBALS['BE_USER']->user['uid']) {
+                       return '';
+               }
+
+               $redirectUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI');
+               $parameters = 'cmd[be_users][' . $backendUser->getUid() . '][delete]=1';
+               $url = $GLOBALS['BACK_PATH'] . 'tce_db.php?&' . $parameters . '&redirect=' . ($redirectUrl == '' ? '\' + T3_THIS_LOCATION + \'' : rawurlencode($redirectUrl)) . '&vC=' . rawurlencode($GLOBALS['BE_USER']->veriCode()) . \TYPO3\CMS\Backend\Utility\BackendUtility::getUrlToken('tceAction') . '&prErr=1&uPT=1';
+               return '<a href="' . $url . '"  onclick="return confirm(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('confirm', 'beuser', array($backendUser->getUserName()))) . ')">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon(('actions-edit-delete')) . '</a>';
+       }
+
+}
+
+?>
\ No newline at end of file
index 639053c..6eddc2e 100644 (file)
                        <trans-unit id="switchBackMode" xml:space="preserve">
                                <source>[switch-back mode]</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
index 31196f2..75222bd 100755 (executable)
@@ -26,6 +26,7 @@
                <a href="alt_doc.php?edit[be_users][{backendUser.uid}]=edit&returnUrl={returnUrl}">
                        <bu:spriteManagerIcon iconName="actions-document-open" />
                </a>
+
                <f:if condition="{backendUser.isDisabled} == 1">
                        <f:then>
                                <a href="<bu:issueCommand parameters="tce_db.php?&data[be_users][{backendUser.uid}][disable]=0&redirect={redirectUrl}" />">
@@ -38,6 +39,9 @@
                                </a>
                        </f:else>
                </f:if>
+
+               <bu:removeUser backendUser="{backendUser}" />
+
                <f:comment>
                        No need to check if currently listed user is current user.
                        SU does not work with admin users and current user must always be admin.
@@ -58,4 +62,4 @@
                        </f:else>
                </f:if>
        </td>
-</tr>
\ No newline at end of file
+</tr>