Fixed bug #6071: Switch to User does not work from context menu in List Module.
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / class.tx_beuser.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Class, adding SU link to context menu
29 *
30 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
31 */
32 /**
33 * [CLASS/FUNCTION INDEX of SCRIPT]
34 *
35 */
36
37
38
39
40
41
42
43
44
45
46
47
48 /**
49 * Class, adding SU link to context menu
50 *
51 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
52 * @package TYPO3
53 * @subpackage tx_beuser
54 */
55 class tx_beuser {
56
57 /**
58 * Adding various standard options to the context menu.
59 * This includes both first and second level.
60 *
61 * @param object The calling object. Value by reference.
62 * @param array Array with the currently collected menu items to show.
63 * @param string Table name of clicked item.
64 * @param integer UID of clicked item.
65 * @return array Modified $menuItems array
66 */
67 function main(&$backRef,$menuItems,$table,$uid) {
68 global $BE_USER,$TCA,$LANG;
69
70 $localItems = array(); // Accumulation of local items.
71
72 // Detecting menu level
73 if ($BE_USER->isAdmin() && !$backRef->cmLevel && $table == 'be_users') { // LEVEL: Primary menu.
74
75 // "SU" element added:
76 $url = 'mod.php?M=tools_beuser&SwitchUser='.rawurlencode($uid).'&switchBackUser=1';
77 $localItems[] = $backRef->linkItem(
78 'Switch To User',
79 $backRef->excludeIcon('<img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/su_back.gif').' border="0" align="top" title="" alt="" />'),
80 $backRef->urlRefForCM($url,'',1,'top'),
81 1
82 );
83
84 $menuItems=array_merge($menuItems,$localItems);
85 }
86 return $menuItems;
87 }
88
89 /**
90 * Include local lang file.
91 *
92 * @return array Local lang array.
93 */
94 function includeLL() {
95 global $LANG;
96
97 $LOCAL_LANG = $LANG->includeLLFile('EXT:extra_page_cm_options/locallang.php',FALSE);
98 return $LOCAL_LANG;
99 }
100 }
101
102 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/extra_page_cm_options/class.tx_extrapagecmoptions.php']) {
103 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/extra_page_cm_options/class.tx_extrapagecmoptions.php']);
104 }
105 ?>