Added feature #11783: Change existing warning boxes to use flash messages
[Packages/TYPO3.CMS.git] / typo3 / sysext / setup / mod / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 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 * Module: User configuration
29 *
30 * This module lets users viev and change their individual settings
31 *
32 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
33 * Revised for TYPO3 3.7 6/2004 by Kasper Skaarhoj
34 * XHTML compatible.
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 86: class SC_mod_user_setup_index
42 *
43 * SECTION: Saving data
44 * 114: function storeIncomingData()
45 *
46 * SECTION: Rendering module
47 * 216: function init()
48 * 248: function main()
49 * 403: function printContent()
50 *
51 * SECTION: Helper functions
52 * 432: function getRealScriptUserObj()
53 * 442: function simulateUser()
54 * 488: function setLabel($str,$key='')
55 *
56 * TOTAL FUNCTIONS: 7
57 * (This index is automatically created/updated by the extension "extdeveval")
58 *
59 */
60
61 unset($MCONF);
62 require('conf.php');
63 require($BACK_PATH.'init.php');
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 /**
79 * Script class for the Setup module
80 *
81 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
82 * @package TYPO3
83 * @subpackage tx_setup
84 */
85 class SC_mod_user_setup_index {
86
87 // Internal variables:
88 var $MCONF = array();
89 var $MOD_MENU = array();
90 var $MOD_SETTINGS = array();
91
92 /**
93 * document template object
94 *
95 * @var mediumDoc
96 */
97 var $doc;
98
99 var $content;
100 var $overrideConf;
101
102 /**
103 * backend user object, set during simulate-user operation
104 *
105 * @var t3lib_beUserAuth
106 */
107 var $OLD_BE_USER;
108 var $languageUpdate;
109
110 protected $isAdmin;
111 protected $dividers2tabs;
112
113 protected $tsFieldConf;
114
115
116
117 /******************************
118 *
119 * Saving data
120 *
121 ******************************/
122
123 /**
124 * If settings are submitted to _POST[DATA], store them
125 * NOTICE: This method is called before the template.php is included. See buttom of document
126 *
127 * @return void
128 */
129 function storeIncomingData() {
130 global $BE_USER;
131
132
133 // First check if something is submittet in the data-array from POST vars
134 $d = t3lib_div::_POST('data');
135 $columns = $GLOBALS['TYPO3_USER_SETTINGS']['columns'];
136
137 if (is_array($d)) {
138
139 // UC hashed before applying changes
140 $save_before = md5(serialize($BE_USER->uc));
141
142 // PUT SETTINGS into the ->uc array:
143
144 // reload left frame when switching BE language
145 if (isset($d['lang']) && ($d['lang'] != $BE_USER->uc['lang'])) {
146 $this->languageUpdate = true;
147 }
148
149 if ($d['setValuesToDefault']) {
150 // If every value should be default
151 $BE_USER->resetUC();
152 } else {
153 // save all submitted values if they are no array (arrays are with table=be_users) and exists in $GLOBALS['TYPO3_USER_SETTINGS'][columns]
154 foreach($columns as $field => $config) {
155 if ($config['table']) {
156 continue;
157 }
158 if ($config['type'] == 'check') {
159 $BE_USER->uc[$field] = isset($d[$field]) ? 1 : 0;
160 } else {
161 $BE_USER->uc[$field] = htmlspecialchars($d[$field]);
162 }
163 }
164 }
165 $BE_USER->overrideUC(); // Inserts the overriding values.
166
167 $save_after = md5(serialize($BE_USER->uc));
168 if ($save_before!=$save_after) { // If something in the uc-array of the user has changed, we save the array...
169 $BE_USER->writeUC($BE_USER->uc);
170 $BE_USER->writelog(254,1,0,1,'Personal settings changed',Array());
171 }
172
173
174 // Personal data for the users be_user-record (email, name, password...)
175 // If email and name is changed, set it in the users record:
176 $be_user_data = $d['be_users'];
177 $this->PASSWORD_UPDATED = strlen($be_user_data['password'].$be_user_data['password2'])>0 ? -1 : 0;
178 if ($be_user_data['email']!=$BE_USER->user['email']
179 || $be_user_data['realName']!=$BE_USER->user['realName']
180 || (strlen($be_user_data['password'])==32
181 && !strcmp($be_user_data['password'],$be_user_data['password2']))
182 ) {
183 $storeRec = array();
184 $BE_USER->user['realName'] = $storeRec['be_users'][$BE_USER->user['uid']]['realName'] = substr($be_user_data['realName'],0,80);
185 $BE_USER->user['email'] = $storeRec['be_users'][$BE_USER->user['uid']]['email'] = substr($be_user_data['email'],0,80);
186 if (strlen($be_user_data['password'])==32 && !strcmp($be_user_data['password'],$be_user_data['password2'])) {
187 $BE_USER->user['password'] = $storeRec['be_users'][$BE_USER->user['uid']]['password'] = $be_user_data['password2'];
188 $this->PASSWORD_UPDATED = 1;
189 }
190
191 // Make instance of TCE for storing the changes.
192 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
193 $tce->stripslashes_values=0;
194 $tce->start($storeRec,Array(),$BE_USER);
195 $tce->admin = 1; // This is so the user can actually update his user record.
196 $tce->bypassWorkspaceRestrictions = TRUE; // This is to make sure that the users record can be updated even if in another workspace. This is tolerated.
197 $tce->process_datamap();
198 unset($tce);
199 }
200 }
201 }
202
203
204
205
206
207
208
209
210
211
212
213
214 /******************************
215 *
216 * Rendering module
217 *
218 ******************************/
219
220 /**
221 * Initializes the module for display of the settings form.
222 *
223 * @return void
224 */
225 function init() {
226 $this->MCONF = $GLOBALS['MCONF'];
227
228
229 // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
230 $scriptUser = $this->getRealScriptUserObj();
231 // ... and checking module access for the logged in user.
232 $scriptUser->modAccess($this->MCONF, 1);
233
234 $this->isAdmin = $scriptUser->isAdmin();
235
236 // Getting the 'override' values as set might be set in User TSconfig
237 $this->overrideConf = $GLOBALS['BE_USER']->getTSConfigProp('setup.override');
238 // Getting the disabled fields might be set in User TSconfig (eg setup.fields.password.disabled=1)
239 $this->tsFieldConf = $GLOBALS['BE_USER']->getTSConfigProp('setup.fields');
240
241 // Create instance of object for output of data
242 $this->doc = t3lib_div::makeInstance('template');
243 $this->doc->backPath = $GLOBALS['BACK_PATH'];
244 $this->doc->setModuleTemplate('templates/setup.html');
245 $this->doc->JScodeLibArray['dyntabmenu'] = $this->doc->getDynTabMenuJScode();
246 $this->doc->form = '<form action="index.php" method="post" name="usersetup" enctype="application/x-www-form-urlencoded">';
247 $this->doc->tableLayout = array(
248 'defRow' => array(
249 '0' => array('<td class="td-label">','</td>'),
250 'defCol' => array('<td valign="top">','</td>')
251 )
252 );
253 $this->doc->table_TR = '<tr>';
254 $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2" class="typo3-usersettings">';
255 }
256
257 /**
258 * Generate the main settings formular:
259 *
260 * @return void
261 */
262 function main() {
263 global $BE_USER,$LANG,$BACK_PATH,$TBE_MODULES;
264
265 // file creation / delete
266 if ($this->isAdmin) {
267 if (t3lib_div::_POST('deleteInstallToolEnableFile')) {
268 unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
269 }
270 if (t3lib_div::_POST('createInstallToolEnableFile')) {
271 touch(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
272 }
273 }
274
275 if ($this->languageUpdate) {
276 $this->doc->JScodeArray['languageUpdate'] .= '
277 if (top.refreshMenu) {
278 top.refreshMenu();
279 } else {
280 top.TYPO3ModuleMenu.refreshMenu();
281 }
282
283 if (top.shortcutFrame) {
284 top.shortcutFrame.refreshShortcuts();
285 }
286 ';
287 }
288
289 // Start page:
290 $this->doc->loadJavascriptLib('md5.js');
291
292 // use a wrapper div
293 $this->content .= '<div id="user-setup-wrapper">';
294
295 // Load available backend modules
296 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
297 $this->loadModules->observeWorkspaces = true;
298 $this->loadModules->load($TBE_MODULES);
299
300 $this->content .= $this->doc->header($LANG->getLL('UserSettings').' - '.$BE_USER->user['realName'].' ['.$BE_USER->user['username'].']');
301
302 // If password is updated, output whether it failed or was OK.
303 if ($this->PASSWORD_UPDATED) {
304 if ($this->PASSWORD_UPDATED > 0) {
305 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_ok'),1,0,1);
306 } else {
307 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_failed'),1,0,2);
308 }
309 }
310
311 // render the menu items
312 $menuItems = $this->renderUserSetup();
313
314 $this->content .= $this->doc->spacer(20) . $this->doc->getDynTabMenu($menuItems, 'user-setup', false, false, 100, 1, false, 1, $this->dividers2tabs);
315
316
317 // Submit and reset buttons
318 $this->content .= $this->doc->spacer(20);
319 $this->content .= $this->doc->section('',
320 t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $BACK_PATH) . '
321 <input type="hidden" name="simUser" value="'.$this->simUser.'" />
322 <input type="submit" name="submit" value="'.$LANG->getLL('save').'" />
323 <input type="submit" name="data[setValuesToDefault]" value="'.$LANG->getLL('setToStandard').'" onclick="return confirm(\''.$LANG->getLL('setToStandardQuestion').'\');" />'
324 );
325
326 // Install Tool access file
327 if ($this->isAdmin) {
328 $installToolEnableFileExists = is_file(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
329 $installToolEnableButton = $installToolEnableFileExists ?
330 '<input type="submit" name="deleteInstallToolEnableFile" value="' . $LANG->getLL('enableInstallTool.deleteFile') . '" />' :
331 '<input type="submit" name="createInstallToolEnableFile" value="' . $LANG->getLL('enableInstallTool.createFile') . '" />';
332
333 $this->content .= $this->doc->spacer(30);
334 $this->content .= $this->doc->section($LANG->getLL('enableInstallTool.headerTitle'),
335 $LANG->getLL('enableInstallTool.description')
336 );
337 $this->content .= $this->doc->spacer(10);
338 $this->content .= $this->doc->section('',
339 $installToolEnableButton
340 );
341 }
342
343 // Notice
344 $this->content .= $this->doc->spacer(30);
345 $this->content .= $this->doc->section('', $LANG->getLL('activateChanges'));
346
347 // Setting up the buttons and markers for docheader
348 $docHeaderButtons = $this->getButtons();
349 $markers['CSH'] = $docHeaderButtons['csh'];
350 $markers['CONTENT'] = $this->content;
351
352 // Build the <body> for the module
353 $this->content = $this->doc->startPage($LANG->getLL('UserSettings'));
354 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
355 // end of wrapper div
356 $this->content .= '</div>';
357 $this->content.= $this->doc->endPage();
358 $this->content = $this->doc->insertStylesAndJS($this->content);
359
360 }
361
362 /**
363 * Prints the content / ends page
364 *
365 * @return void
366 */
367 function printContent() {
368 echo $this->content;
369 }
370
371 /**
372 * Create the panel of buttons for submitting the form or otherwise perform operations.
373 *
374 * @return array all available buttons as an assoc. array
375 */
376 protected function getButtons() {
377 $buttons = array(
378 'csh' => '',
379 'save' => '',
380 'shortcut' => '',
381 );
382
383 $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_user_setup', '', $GLOBALS['BACK_PATH'], '|', true);
384
385 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
386 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','',$this->MCONF['name']);
387 }
388
389 return $buttons;
390 }
391
392
393
394
395 /******************************
396 *
397 * Render module
398 *
399 ******************************/
400
401
402 /**
403 * renders the data for all tabs in the user setup and returns
404 * everything that is needed with tabs and dyntab menu
405 *
406 * @return ready to use for the dyntabmenu itemarray
407 */
408 protected function renderUserSetup() {
409 $result = array();
410 $firstTabLabel = '';
411 $code = array();
412 $i = 0;
413
414 $fieldList = $GLOBALS['TYPO3_USER_SETTINGS']['showitem'];
415
416 // disable fields depended on settings
417 if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) {
418 $fieldList = t3lib_div::rmFromList('edit_RTE', $fieldList);
419 }
420
421 if ($GLOBALS['BE_USER']->uc['interfaceSetup'] != 'backend_old') {
422 $fieldList = t3lib_div::rmFromList('noMenuMode', $fieldList);
423 }
424
425 $fieldArray = t3lib_div::trimExplode(',', $fieldList, true);
426 $this->dividers2tabs = isset($GLOBALS['TYPO3_USER_SETTINGS']['ctrl']['dividers2tabs']) ? intval($GLOBALS['TYPO3_USER_SETTINGS']['ctrl']['dividers2tabs']) : 0;
427
428
429 // "display full help" is active?
430 $displayFullText = ($GLOBALS['BE_USER']->uc['edit_showFieldHelp'] == 'text');
431 if ($displayFullText) {
432 $this->doc->tableLayout['defRowEven'] = array('defCol' => array ('<td valign="top" colspan="3">','</td>'));
433 }
434
435 foreach ($fieldArray as $fieldName) {
436 $more = '';
437
438 if (substr($fieldName, 0, 8) == '--div--;') {
439 if ($firstTabLabel == '') {
440 // first tab
441 $tabLabel = $this->getLabel(substr($fieldName, 8), '', false);
442 $firstTabLabel = $tabLabel;
443 } else {
444 if ($this->dividers2tabs) {
445 $result[] = array(
446 'label' => $tabLabel,
447 'content' => count($code) ? $this->doc->spacer(20) . $this->doc->table($code) : ''
448 );
449 $tabLabel = $this->getLabel(substr($fieldName, 8), '', false);
450 $i = 0;
451 $code = array();
452 }
453 }
454 continue;
455 }
456
457 $config = $GLOBALS['TYPO3_USER_SETTINGS']['columns'][$fieldName];
458
459 // field my be disabled in setup.fields
460 if (isset($this->tsFieldConf[$fieldName . '.']['disabled']) && $this->tsFieldConf[$fieldName . '.']['disabled'] == 1) {
461 continue;
462 }
463 if (isset($config['access']) && !$this->checkAccess($config['access'])) {
464 continue;
465 }
466
467 $label = $this->getLabel($config['label'], $fieldName);
468 $csh = $this->getCSH($config['csh'] ? $config['csh'] : $fieldName);
469 $type = $config['type'];
470 $eval = $config['eval'];
471 $class = $config['class'];
472 $style = $config['style'];
473
474 if ($class) {
475 $more .= ' class="' . $class . '"';
476 }
477 if ($style) {
478 $more .= ' style="' . $style . '"';
479 }
480
481 switch ($type) {
482 case 'text':
483 case 'password':
484 $dataAdd = '';
485 if ($config['table'] == 'be_users') {
486 $dataAdd = '[be_users]';
487 $value = $GLOBALS['BE_USER']->user[$fieldName];
488 } else {
489 $value = $GLOBALS['BE_USER']->uc[$fieldName];
490 }
491 if ($eval == 'md5') {
492 $more .= ' onchange="this.value=this.value?MD5(this.value):\'\';"';
493 }
494
495 if ($type == 'password') {
496 $value = '';
497 }
498
499 $html = '<input id="field_' . $fieldName . '"
500 type="' . $type . '"
501 name="data' . $dataAdd . '[' . $fieldName . ']"
502 value="' . htmlspecialchars($value) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . $more . ' />';
503 break;
504 case 'check':
505 if (!$class) {
506 $more .= ' class="check"';
507 }
508 $html = '<input id="field_' . $fieldName . '"
509 type="checkbox"
510 name="data[' . $fieldName . ']"' .
511 ($GLOBALS['BE_USER']->uc[$fieldName] ? ' checked="checked"' : '') . $more . ' />';
512 break;
513 case 'select':
514 if (!$class) {
515 $more .= ' class="select"';
516 }
517
518 if ($config['itemsProcFunc']) {
519 $parts = explode('->', $config['itemsProcFunc']);
520 $html = call_user_func(array($parts[0], $parts[1]));
521 } else {
522 $html = '<select id="field_' . $fieldName . '" name="data[' . $fieldName . ']"' . $more . '>' . chr(10);
523 foreach ($config['items'] as $key => $value) {
524 $html .= '<option value="' . $key . '"' .
525 ($GLOBALS['BE_USER']->uc[$fieldName] == $key ? ' selected="selected"' : '') .
526 '>' . $this->getLabel($value,'',false) . '</option>' . chr(10);
527 }
528 $html .= '</select>';
529 }
530
531 break;
532 default:
533 $html = '';
534 }
535
536
537 // add another table row with the full text help if needed
538 if ($displayFullText) {
539 $code[$i++][1] = $csh;
540 $csh = '';
541 }
542
543 $code[$i][1] = $csh . $label;
544 $code[$i++][2] = $html;
545
546
547
548 }
549
550 if ($this->dividers2tabs == 0) {
551 $tabLabel = $firstTabLabel;
552 }
553
554 $result[] = array(
555 'label' => $tabLabel,
556 'content' => count($code) ? $this->doc->spacer(20) . $this->doc->table($code) : ''
557 );
558
559
560 return $result;
561 }
562
563
564
565
566
567
568 /******************************
569 *
570 * Helper functions
571 *
572 ******************************/
573
574 /**
575 * Returns the backend user object, either the global OR the $this->OLD_BE_USER which is set during simulate-user operation.
576 * Anyway: The REAL user is returned - the one logged in.
577 *
578 * @return object The REAL user is returned - the one logged in.
579 */
580 protected function getRealScriptUserObj() {
581 return is_object($this->OLD_BE_USER) ? $this->OLD_BE_USER : $GLOBALS['BE_USER'];
582 }
583
584
585 /**
586 * Return a select with available languages
587 *
588 * @return string complete select as HTML string or warning box if something went wrong.
589 */
590 protected function renderLanguageSelect() {
591
592 // compile the languages dropdown
593 $languageOptions = array(
594 '000000000' => chr(10) . '<option value="">' . $GLOBALS['LANG']->getLL('lang_default', 1) . '</option>'
595 );
596 // traverse the number of languages
597 $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
598 foreach ($theLanguages as $language) {
599 if ($language != 'default') {
600 $languageValue = $GLOBALS['LOCAL_LANG']['default']['lang_' . $language];
601 $localLabel = ' - ['.htmlspecialchars($languageValue) . ']';
602 $unavailable = (is_dir(PATH_typo3conf . 'l10n/' . $language) ? false : true);
603 if (!$unavailable) {
604 $languageOptions[$languageValue . '--' . $language] = '
605 <option value="'.$language.'"'.($GLOBALS['BE_USER']->uc['lang'] == $language ? ' selected="selected"' : '') . ($unavailable ? ' class="c-na"' : '').'>'.$GLOBALS['LANG']->getLL('lang_' . $language, 1) . $localLabel . '</option>';
606 }
607 }
608 }
609 ksort($languageOptions);
610 $languageCode = '
611 <select id="field_lang" name="data[lang]" class="select">' .
612 implode('', $languageOptions) . '
613 </select>';
614 if ($GLOBALS['BE_USER']->uc['lang'] && !@is_dir(PATH_typo3conf . 'l10n/' . $GLOBALS['BE_USER']->uc['lang'])) {
615 $languageUnavailableWarning = 'The selected language is not available before the language pack is installed.<br />'
616 . ($GLOBALS['BE_USER']->isAdmin() ?
617 'You can use the Extension Manager to easily download and install new language packs.'
618 : 'Please ask your system administrator to do this.');
619
620
621 $languageUnavailableMessage = t3lib_div::makeInstance(
622 't3lib_FlashMessage',
623 $languageUnavailableWarning,
624 '',
625 t3lib_FlashMessage::WARNING
626 );
627
628 $languageCode = $languageUnavailableMessage->render() . $languageCode;
629 }
630
631 return $languageCode;
632 }
633
634 /**
635 * Returns a select with all modules for startup
636 *
637 * @return string complete select as HTML string
638 */
639 protected function renderStartModuleSelect() {
640 // start module select
641 if (empty($GLOBALS['BE_USER']->uc['startModule'])) {
642 $GLOBALS['BE_USER']->uc['startModule'] = $GLOBALS['BE_USER']->uc_default['startModule'];
643 }
644 $startModuleSelect .= '<option value=""></option>';
645 foreach ($this->loadModules->modules as $mainMod => $modData) {
646 if (isset($modData['sub']) && is_array($modData['sub'])) {
647 $startModuleSelect .= '<option disabled="disabled">'.$GLOBALS['LANG']->moduleLabels['tabs'][$mainMod.'_tab'].'</option>';
648 foreach ($modData['sub'] as $subKey => $subData) {
649 $modName = $subData['name'];
650 $startModuleSelect .= '<option value="' . $modName . '"' . ($GLOBALS['BE_USER']->uc['startModule'] == $modName ? ' selected="selected"' : '') . '>';
651 $startModuleSelect .= ' - ' . $GLOBALS['LANG']->moduleLabels['tabs'][$modName.'_tab'] . '</option>';
652 }
653 }
654 }
655
656
657 return '<select id="field_startModule" name="data[startModule]" class="select">' . $startModuleSelect . '</select>';
658 }
659
660
661
662 /**
663 * Will make the simulate-user selector if the logged in user is administrator.
664 * It will also set the GLOBAL(!) BE_USER to the simulated user selected if any (and set $this->OLD_BE_USER to logged in user)
665 *
666 * @return void
667 */
668 function simulateUser() {
669 global $BE_USER,$LANG,$BACK_PATH;
670
671 // *******************************************************************************
672 // If admin, allow simulation of another user
673 // *******************************************************************************
674 $this->simUser = 0;
675 $this->simulateSelector = '';
676 unset($this->OLD_BE_USER);
677 if ($BE_USER->isAdmin()) {
678 $this->simUser = t3lib_div::_GP('simUser');
679
680 // Make user-selector:
681 $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName', t3lib_BEfunc::BEenableFields('be_users'));
682 $opt = array();
683 foreach ($users as $rr) {
684 if ($rr['uid'] != $BE_USER->user['uid']) {
685 $opt[] = '<option value="'.$rr['uid'].'"'.($this->simUser==$rr['uid']?' selected="selected"':'').'>'.htmlspecialchars($rr['username'].' ('.$rr['realName'].')').'</option>';
686 }
687 }
688 if (count($opt)) {
689 $this->simulateSelector = '<select id="field_simulate" name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;"><option></option>'.implode('',$opt).'</select>';
690 }
691 }
692
693 if ($this->simUser>0) { // This can only be set if the previous code was executed.
694 $this->OLD_BE_USER = $BE_USER; // Save old user...
695 unset($BE_USER); // Unset current
696
697 $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth'); // New backend user object
698 $BE_USER->OS = TYPO3_OS;
699 $BE_USER->setBeUserByUid($this->simUser);
700 $BE_USER->fetchGroupData();
701 $BE_USER->backendSetUC();
702 $GLOBALS['BE_USER'] = $BE_USER; // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
703 }
704 }
705
706 /**
707 * Returns a select with simulate users
708 *
709 * @return string complete select as HTML string
710 */
711 protected function renderSimulateUserSelect() {
712 return $this->simulateSelector;
713 }
714
715 /**
716 * Returns access check (currently only "admin" is supported)
717 *
718 * @param $level check against user level (currently only "admin")
719 * @return boolean true if same access level, else false
720 */
721 protected function checkAccess($level) {
722 if ($level == 'admin') {
723 return $this->isAdmin;
724 }
725 }
726
727
728 /**
729 * Returns the label $str from getLL() and grays out the value if the $str/$key is found in $this->overrideConf array
730 *
731 * @param string Locallang key
732 * @param string Alternative override-config key
733 * @param boolean Defines whether the string should be wrapped in a <label> tag.
734 * @param string Alternative id for use in "for" attribute of <label> tag. By default the $str key is used prepended with "field_".
735 * @return string HTML output.
736 */
737 protected function getLabel($str, $key='', $addLabelTag=true, $altLabelTagId='') {
738 if (substr($str, 0, 4) == 'LLL:') {
739 $out = $GLOBALS['LANG']->sL($str);
740 } else {
741 $out = htmlspecialchars($str);
742 }
743
744
745 if (isset($this->overrideConf[($key?$key:$str)])) {
746 $out = '<span style="color:#999999">'.$out.'</span>';
747 }
748
749 if($addLabelTag) {
750 $out = '<label for="' . ($altLabelTagId ? $altLabelTagId : 'field_' . $key) . '">' . $out . '</label>';
751 }
752 return $out;
753 }
754
755 /**
756 * Returns the CSH Icon for given string
757 *
758 * @param string Locallang key
759 * @return string HTML output.
760 */
761 protected function getCSH($str) {
762 if (!t3lib_div::inList('language,simuser', $str)) {
763 $str = 'option_' . $str;
764 }
765 return t3lib_BEfunc::cshItem('_MOD_user_setup', $str, $GLOBALS['BACK_PATH'], '|', false, 'margin-bottom:0px;');
766 }
767 }
768
769
770 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']) {
771 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']);
772 }
773
774
775
776 // Make instance:
777 $SOBE = t3lib_div::makeInstance('SC_mod_user_setup_index');
778 $SOBE->simulateUser();
779 $SOBE->storeIncomingData();
780
781 // These includes MUST be afterwards the settings are saved...!
782 require ($BACK_PATH.'template.php');
783 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
784
785 $SOBE->init();
786 $SOBE->main();
787 $SOBE->printContent();
788
789 ?>