[TASK] Split action buttons into two groups
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / Classes / ViewHelpers / RemoveUserViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Beuser\ViewHelpers;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\IconUtility;
18 use TYPO3\CMS\Beuser\Domain\Model\BackendUser;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
22 /**
23 * Displays 'Delete user' link with sprite icon to remove user
24 *
25 * @internal
26 */
27 class RemoveUserViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
28
29 /**
30 * Render link with sprite icon to remove user
31 *
32 * @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser Target backendUser to switch active session to
33 * @return string
34 */
35 public function render(BackendUser $backendUser) {
36 if ($backendUser->getUid() == $GLOBALS['BE_USER']->user['uid']) {
37 return '<span class="btn btn-default disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
38 }
39
40 $redirectUrl = GeneralUtility::getIndpEnv('REQUEST_URI');
41 $parameters = 'cmd[be_users][' . $backendUser->getUid() . '][delete]=1';
42 $url = $GLOBALS['BACK_PATH'] . BackendUtility::getModuleUrl('tce_db') . '&' . $parameters . '&redirect=' .
43 ($redirectUrl == '' ? '\' + T3_THIS_LOCATION + \'' : rawurlencode($redirectUrl)) . '&vC=' .
44 rawurlencode($GLOBALS['BE_USER']->veriCode()) . BackendUtility::getUrlToken('tceAction') . '&prErr=1&uPT=1';
45 return '<a class="btn btn-default" href="' . $url . '" onclick="return confirm(' .
46 GeneralUtility::quoteJSvalue(LocalizationUtility::translate('confirm', 'beuser', array($backendUser->getUserName()))) .
47 ')">' . IconUtility::getSpriteIcon(('actions-edit-delete')) . '</a>';
48 }
49
50 }