[TASK] Twitter Bootstrap EXT:beuser follow up
[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 use TYPO3\CMS\Backend\Utility\IconUtility;
17 use TYPO3\CMS\Beuser\Domain\Model\BackendUser;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
20 use TYPO3\CMS\Backend\Utility\BackendUtility;
21 /**
22 * Displays 'Delete user' link with sprite icon to remove user
23 *
24 * @internal
25 */
26 class RemoveUserViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
27
28 /**
29 * Render link with sprite icon to remove user
30 *
31 * @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser Target backendUser to switch active session to
32 * @return string
33 */
34 public function render(BackendUser $backendUser) {
35 if ($backendUser->getUid() == $GLOBALS['BE_USER']->user['uid']) {
36 return '<span class="btn disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
37 }
38
39 $redirectUrl = GeneralUtility::getIndpEnv('REQUEST_URI');
40 $parameters = 'cmd[be_users][' . $backendUser->getUid() . '][delete]=1';
41 $url = $GLOBALS['BACK_PATH'] . 'tce_db.php?&' . $parameters . '&redirect=' .
42 ($redirectUrl == '' ? '\' + T3_THIS_LOCATION + \'' : rawurlencode($redirectUrl)) . '&vC=' .
43 rawurlencode($GLOBALS['BE_USER']->veriCode()) . BackendUtility::getUrlToken('tceAction') . '&prErr=1&uPT=1';
44 return '<a class="btn" href="' . $url . '" onclick="return confirm(' .
45 GeneralUtility::quoteJSvalue(LocalizationUtility::translate('confirm', 'beuser', array($backendUser->getUserName()))) .
46 ')">' . IconUtility::getSpriteIcon(('actions-edit-delete')) . '</a>';
47 }
48
49 }