[TASK] Make Backend Module URLs absolute
[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 $redirect = '&redirect=' . ($redirectUrl == '' ? '\' + T3_THIS_LOCATION + \'' : rawurlencode($redirectUrl));
42 $urlParameters = [
43 'cmd[be_users][' . $backendUser->getUid() . '][delete]' => 1,
44 'vC' => $GLOBALS['BE_USER']->veriCode(),
45 'prErr' => 1,
46 'uPT' => 1
47 ];
48 $url = BackendUtility::getModuleUrl('tce_db', $urlParameters) . $redirect . BackendUtility::getUrlToken('tceAction');
49
50 return '<a class="btn btn-default" href="' . $url . '" onclick="return confirm(' .
51 GeneralUtility::quoteJSvalue(LocalizationUtility::translate('confirm', 'beuser', array($backendUser->getUserName()))) .
52 ')">' . IconUtility::getSpriteIcon(('actions-edit-delete')) . '</a>';
53 }
54
55 }