Fixed #10600: Cleaned up sysext usersetup module code (part 1) and the table method...
[Packages/TYPO3.CMS.git] / typo3 / sysext / setup / mod / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 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 require_once(PATH_t3lib.'class.t3lib_tcemain.php');
65 require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 /**
81 * Script class for the Setup module
82 *
83 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
84 * @package TYPO3
85 * @subpackage tx_setup
86 */
87 class SC_mod_user_setup_index {
88
89 // Internal variables:
90 var $MCONF = array();
91 var $MOD_MENU = array();
92 var $MOD_SETTINGS = array();
93
94 /**
95 * document template object
96 *
97 * @var mediumDoc
98 */
99 var $doc;
100
101 var $content;
102 var $overrideConf;
103
104 /**
105 * backend user object, set during simulate-user operation
106 *
107 * @var t3lib_beUserAuth
108 */
109 var $OLD_BE_USER;
110 var $languageUpdate;
111
112
113
114
115
116 /******************************
117 *
118 * Saving data
119 *
120 ******************************/
121
122 /**
123 * If settings are submitted to _POST[DATA], store them
124 * NOTICE: This method is called before the template.php is included. See buttom of document
125 *
126 * @return void
127 */
128 function storeIncomingData() {
129 global $BE_USER;
130
131
132 // First check if something is submittet in the data-array from POST vars
133 $d = t3lib_div::_POST('data');
134 if (is_array($d)) {
135
136 // UC hashed before applying changes
137 $save_before = md5(serialize($BE_USER->uc));
138
139 // PUT SETTINGS into the ->uc array:
140
141 // reload left frame when switching BE language
142 if (isset($d['lang']) && ($d['lang'] != $BE_USER->uc['lang'])) {
143 $this->languageUpdate = true;
144 }
145 // Language
146 $BE_USER->uc['lang'] = $d['lang'];
147
148 // Startup
149 $BE_USER->uc['condensedMode'] = $d['condensedMode'];
150 $BE_USER->uc['noMenuMode'] = $d['noMenuMode'];
151 $BE_USER->uc['startModule'] = $d['startModule'];
152 $BE_USER->uc['thumbnailsByDefault'] = $d['thumbnailsByDefault'];
153 $BE_USER->uc['helpText'] = $d['helpText'];
154 $BE_USER->uc['titleLen'] = intval($d['titleLen']);
155
156 // Advanced functions:
157 $BE_USER->uc['copyLevels'] = t3lib_div::intInRange($d['copyLevels'],0,100);
158 $BE_USER->uc['recursiveDelete'] = $d['recursiveDelete'];
159
160 // Edit
161 $BE_USER->uc['edit_wideDocument'] = $d['edit_wideDocument'];
162 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) { $BE_USER->uc['edit_RTE'] = $d['edit_RTE']; }
163 $BE_USER->uc['edit_docModuleUpload'] = $d['edit_docModuleUpload'];
164 $BE_USER->uc['edit_showFieldHelp'] = $d['edit_showFieldHelp'];
165 $BE_USER->uc['disableCMlayers'] = $d['disableCMlayers'];
166
167 // Personal:
168 $BE_USER->uc['emailMeAtLogin'] = $d['emailMeAtLogin'];
169
170
171 if ($d['setValuesToDefault']) { // If every value should be default
172 $BE_USER->resetUC();
173 }
174 $BE_USER->overrideUC(); // Inserts the overriding values.
175
176 $save_after = md5(serialize($BE_USER->uc));
177 if ($save_before!=$save_after) { // If something in the uc-array of the user has changed, we save the array...
178 $BE_USER->writeUC($BE_USER->uc);
179 $BE_USER->writelog(254,1,0,1,'Personal settings changed',Array());
180 }
181
182
183 // Personal data for the users be_user-record (email, name, password...)
184 // If email and name is changed, set it in the users record:
185 $be_user_data = t3lib_div::_GP('ext_beuser');
186 $this->PASSWORD_UPDATED = strlen($be_user_data['password1'].$be_user_data['password2'])>0 ? -1 : 0;
187 if ($be_user_data['email']!=$BE_USER->user['email']
188 || $be_user_data['realName']!=$BE_USER->user['realName']
189 || (strlen($be_user_data['password1'])==32
190 && !strcmp($be_user_data['password1'],$be_user_data['password2']))
191 ) {
192 $storeRec = array();
193 $BE_USER->user['realName'] = $storeRec['be_users'][$BE_USER->user['uid']]['realName'] = substr($be_user_data['realName'],0,80);
194 $BE_USER->user['email'] = $storeRec['be_users'][$BE_USER->user['uid']]['email'] = substr($be_user_data['email'],0,80);
195 if (strlen($be_user_data['password1'])==32 && !strcmp($be_user_data['password1'],$be_user_data['password2'])) {
196 $BE_USER->user['password'] = $storeRec['be_users'][$BE_USER->user['uid']]['password'] = $be_user_data['password1'];
197 $this->PASSWORD_UPDATED = 1;
198 }
199
200 // Make instance of TCE for storing the changes.
201 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
202 $tce->stripslashes_values=0;
203 $tce->start($storeRec,Array(),$BE_USER);
204 $tce->admin = 1; // This is so the user can actually update his user record.
205 $tce->bypassWorkspaceRestrictions = TRUE; // This is to make sure that the users record can be updated even if in another workspace. This is tolerated.
206 $tce->process_datamap();
207 unset($tce);
208 }
209 }
210 }
211
212
213
214
215
216
217
218
219
220
221
222
223 /******************************
224 *
225 * Rendering module
226 *
227 ******************************/
228
229 /**
230 * Initializes the module for display of the settings form.
231 *
232 * @return void
233 */
234 function init() {
235 $this->MCONF = $GLOBALS['MCONF'];
236
237 // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
238 $scriptUser = $this->getRealScriptUserObj();
239 // ... and checking module access for the logged in user.
240 $scriptUser->modAccess($this->MCONF, 1);
241
242 // Getting the 'override' values as set might be set in User TSconfig
243 $this->overrideConf = $GLOBALS['BE_USER']->getTSConfigProp('setup.override');
244
245 // Create instance of object for output of data
246 $this->doc = t3lib_div::makeInstance('template');
247 $this->doc->backPath = $GLOBALS['BACK_PATH'];
248 $this->doc->setModuleTemplate('templates/setup.html');
249 $this->doc->JScodeLibArray['dyntabmenu'] = $this->doc->getDynTabMenuJScode();
250 $this->doc->form = '<form action="index.php" method="post" name="usersetup" enctype="application/x-www-form-urlencoded">';
251 $this->doc->tableLayout = array(
252 'defRow' => array(
253 '0' => array('<td class="td-label">','</td>'),
254 '2' => array('<td class="td-label-right">','</td>'),
255 'defCol' => array('<td valign="top">','</td>')
256 )
257 );
258 $this->doc->table_TR = '<tr>';
259 $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2" id="typo3-userSettings">';
260 }
261
262 /**
263 * Generate the main settings formular:
264 *
265 * @return void
266 */
267 function main() {
268 global $BE_USER,$LANG,$BACK_PATH,$TBE_MODULES;
269
270 if ($this->languageUpdate) {
271 $this->doc->JScodeArray['languageUpdate'] .= '
272 if (top.refreshMenu) {
273 top.refreshMenu();
274 } else {
275 top.TYPO3ModuleMenu.refreshMenu();
276 }
277
278 if (top.shortcutFrame) {
279 top.shortcutFrame.refreshShortcuts();
280 }
281 ';
282 }
283
284 // Start page:
285 $menuItems = array();
286 $this->doc->loadJavascriptLib('md5.js');
287
288 // use a wrapper div
289 $this->content .= '<div id="user-setup-wrapper">';
290
291 // Load available backend modules
292 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
293 $this->loadModules->observeWorkspaces = true;
294 $this->loadModules->load($TBE_MODULES);
295
296 $this->content .= $this->doc->header($LANG->getLL('UserSettings').' - '.$BE_USER->user['realName'].' ['.$BE_USER->user['username'].']');
297
298 // If password is updated, output whether it failed or was OK.
299 if ($this->PASSWORD_UPDATED) {
300 if ($this->PASSWORD_UPDATED > 0) {
301 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_ok'),1,0,1);
302 } else {
303 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_failed'),1,0,2);
304 }
305 $this->content .= $this->doc->spacer(25);
306 }
307
308
309 //
310 // Personal data
311 //
312 // compile the languages dropdown
313 $languageOptions = array(
314 '000000000' => chr(10) . '<option value="">' . $LANG->getLL('lang_default', 1) . '</option>'
315 );
316 // traverse the number of languages
317 $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
318 foreach ($theLanguages as $language) {
319 if ($language != 'default') {
320 $languageValue = $GLOBALS['LOCAL_LANG']['default']['lang_' . $language];
321 $localLabel = ' - ['.htmlspecialchars($languageValue) . ']';
322 $unavailable = (!is_dir(PATH_typo3conf . 'l10n/' . $language) ? true : false);
323 if (!$unavailable) {
324 $languageOptions[$languageValue . '--' . $language] = '
325 <option value="'.$language.'"'.($BE_USER->uc['lang'] == $language ? ' selected="selected"' : '') . ($unavailable ? ' class="c-na"' : '').'>'.$LANG->getLL('lang_' . $language, 1) . $localLabel . '</option>';
326 }
327 }
328 }
329 ksort($languageOptions);
330 $languageCode = '
331 <select id="field_language" name="data[lang]">' .
332 implode('', $languageOptions) . '
333 </select>';
334 if ($BE_USER->uc['lang'] && !@is_dir(PATH_typo3conf . 'l10n/' . $BE_USER->uc['lang'])) {
335 $languageCode .= '<table border="0" cellpadding="0" cellspacing="0" class="warningbox"><tr><td>'.
336 $this->doc->icons(3) .
337 'The selected language is not available before the language pack is installed.<br />'.
338 ($BE_USER->isAdmin() ? 'You can use the Extension Manager to easily download and install new language packs.':'Please ask your system administrator to do this.') .
339 '</td></tr></table>';
340 }
341
342
343 // the data for the user configuration (uc),
344 $data = array(
345 'beUser_realName' => array(
346 'type' => 'text',
347 'form' => '<input id="field_beUser_realName" type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />',
348 ),
349 'beUser_email' => array(
350 'type' => 'text',
351 'form' => '<input id="field_beUser_email" type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />',
352 ),
353 'emailMeAtLogin' => array(
354 'type' => 'check',
355 'form' => '<input id="field_emailMeAtLogin" type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />',
356 ),
357 'newPassword' => array(
358 'type' => 'password',
359 'form' => '<input id="field_newPassword" type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />',
360 ),
361 'newPasswordAgain' => array(
362 'type' => 'password',
363 'form' => '<input id="field_newPasswordAgain" type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />',
364 ),
365 'language' => array(
366 'type' => 'select',
367 'form' => $languageCode,
368 ),
369 );
370 $menuItems[] = $this->renderUserSetupTab($data, ($LANG->getLL('language') . ' & ' . $LANG->getLL('personal_data')));
371
372
373 //
374 // compiling the 'Startup' section
375 //
376
377 // start module select
378 if (empty($BE_USER->uc['startModule'])) {
379 $BE_USER->uc['startModule'] = $BE_USER->uc_default['startModule'];
380 }
381 $startModuleSelect .= '<option value=""></option>';
382 foreach ($this->loadModules->modules as $mainMod => $modData) {
383 if (isset($modData['sub']) && is_array($modData['sub'])) {
384 $startModuleSelect .= '<option disabled="disabled">'.$LANG->moduleLabels['tabs'][$mainMod.'_tab'].'</option>';
385 foreach ($modData['sub'] as $subKey => $subData) {
386 $modName = $subData['name'];
387 $startModuleSelect .= '<option value="'.$modName.'"'.($BE_USER->uc['startModule']==$modName?' selected="selected"':'').'>';
388 $startModuleSelect .= ' - '.$LANG->moduleLabels['tabs'][$modName.'_tab'].'</option>';
389 }
390 }
391 }
392 $startModuleSelect = '<select id="field_startModule" name="data[startModule]">' . $startModuleSelect . '</select>';
393
394
395 $data = array(
396 'condensedMode' => array(
397 'type' => 'checkbox',
398 'form' => '<input id="field_condensedMode" type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />',
399 'label' => 'condensedMode'
400 ),
401 'noMenuMode' => array(
402 'type' => 'select',
403 'form' => '<select id="field_noMenuMode" name="data[noMenuMode]">
404 <option value=""'.(!$BE_USER->uc['noMenuMode']?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_def').'</option>
405 <option value="1"'.($BE_USER->uc['noMenuMode'] && (string)$BE_USER->uc['noMenuMode']!="icons"?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_sel').'</option>
406 <option value="icons"'.((string)$BE_USER->uc['noMenuMode']=='icons'?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_icons').'</option>
407 </select>',
408 'labelkey' => 'noMenuMode'
409 ),
410 'startModule' => array(
411 'type' => 'select',
412 'form' => $startModuleSelect,
413 'labelkey' => 'startModule'
414 ),
415 'showThumbs' => array(
416 'type' => 'check',
417 'form' => '<input id="field_showThumbs" type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />',
418 'labelkey' => 'thumbnailsByDefault',
419 ),
420 'helpText' => array(
421 'type' => 'check',
422 'form' => '<input id="field_helpText" type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />',
423 ),
424 'edit_showFieldHelp' => array(
425 'type' => 'select',
426 'form' => '<select id="field_edit_showFieldHelp" name="data[edit_showFieldHelp]">
427 <option value="">'.$LANG->getLL('edit_showFieldHelp_none').'</option>
428 <option value="icon"'.($BE_USER->uc['edit_showFieldHelp']=='icon'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_icon').'</option>
429 <option value="text"'.($BE_USER->uc['edit_showFieldHelp']=='text'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_message').'</option>
430 </select>',
431 ),
432 'maxTitleLen' => array(
433 'type' => 'text',
434 'form' => '<input id="field_maxTitleLen" type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />',
435 'labelkey' => 'titleLen',
436 ),
437
438 );
439
440 if ($GLOBALS['BE_USER']->uc['interfaceSetup'] != 'backend_old') {
441 unset($data['noMenuMode']);
442 }
443 $menuItems[] = $this->renderUserSetupTab($data, ($LANG->getLL('opening')));
444
445
446 //
447 // Edit section & advanced options
448 //
449
450 $data = array(
451 'edit_RTE' => array(
452 'type' => 'check',
453 'form' => '<input id="field_edit_RTE" type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />',
454 ),
455 'edit_docModuleUpload' => array(
456 'type' => 'check',
457 'form' => '<input id="field_edit_docModuleUpload" type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />'
458 ),
459 'disableCMlayers' => array(
460 'type' => 'check',
461 'form' => '<input id="field_disableCMlayers" type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />'
462 ),
463 'copyLevels' => array(
464 'type' => 'text',
465 'form' => '<input id="field_copyLevels" type="text" name="data[copyLevels]" value="'.$BE_USER->uc['copyLevels'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />&nbsp;'.$LANG->getLL('levels')
466 ),
467 'recursiveDelete' => array(
468 'type' => 'check',
469 'form' => '<input id="field_recursiveDelete" type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />',
470 ),
471 );
472
473 if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) {
474 unset($data['edit_RTE']);
475 }
476 $menuItems[] = $this->renderUserSetupTab($data, ($LANG->getLL('edit_functions') . ' & ' . $LANG->getLL('functions')));
477
478
479 //
480 // Admin functions
481 //
482 $data = array();
483 if ($BE_USER->isAdmin()) {
484 // Simulate selector box:
485 if ($this->simulateSelector) {
486 $data['simulate'] = array(
487 'type' => 'select',
488 'form' => $this->simulateSelector,
489 'csh' => 'simuser'
490 );
491 }
492 $menuItems[] = $this->renderUserSetupTab($data, $LANG->getLL('adminFunctions'));
493 }
494
495 // render the menu items;
496 $this->content .= $this->doc->spacer(20) . $this->doc->getDynTabMenu($menuItems, 'user-setup', false, false, 100);
497
498
499 // Submit and reset buttons
500 $this->content .= $this->doc->spacer(20);
501 $this->content .= $this->doc->section('', '
502 <input type="hidden" name="simUser" value="'.$this->simUser.'" />
503 <input type="submit" name="submit" value="'.$LANG->getLL('save').'" />
504 <input type="submit" name="data[setValuesToDefault]" value="'.$LANG->getLL('setToStandard').'" onclick="return confirm(\''.$LANG->getLL('setToStandardQuestion').'\');" />'.
505 t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $BACK_PATH)
506 );
507
508 // Notice
509 $this->content .= $this->doc->spacer(30);
510 $this->content .= $this->doc->section('', $LANG->getLL('activateChanges'));
511
512 // Setting up the buttons and markers for docheader
513 $docHeaderButtons = $this->getButtons();
514 $markers['CSH'] = $docHeaderButtons['csh'];
515 $markers['CONTENT'] = $this->content;
516
517 // Build the <body> for the module
518 $this->content = $this->doc->startPage($LANG->getLL('UserSettings'));
519 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
520 $this->content.= $this->doc->endPage();
521 $this->content = $this->doc->insertStylesAndJS($this->content);
522
523 // end of wrapper div
524 $this->content .= '</div>';
525 }
526
527 /**
528 * Prints the content / ends page
529 *
530 * @return void
531 */
532 function printContent() {
533 echo $this->content;
534 }
535
536 /**
537 * Create the panel of buttons for submitting the form or otherwise perform operations.
538 *
539 * @return array all available buttons as an assoc. array
540 */
541 protected function getButtons() {
542 $buttons = array(
543 'csh' => '',
544 'save' => '',
545 'shortcut' => '',
546 );
547
548 $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_user_setup', '', $GLOBALS['BACK_PATH'], '|', true);
549
550 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
551 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','',$this->MCONF['name']);
552 }
553
554 return $buttons;
555 }
556
557
558
559
560
561
562
563
564
565
566 /******************************
567 *
568 * Helper functions
569 *
570 ******************************/
571
572 /**
573 * Returns the backend user object, either the global OR the $this->OLD_BE_USER which is set during simulate-user operation.
574 * Anyway: The REAL user is returned - the one logged in.
575 *
576 * @return object The REAL user is returned - the one logged in.
577 */
578 function getRealScriptUserObj() {
579 return is_object($this->OLD_BE_USER) ? $this->OLD_BE_USER : $GLOBALS['BE_USER'];
580 }
581
582 /**
583 * renders the data for one tab in the user setup and returns
584 * everything that is needed to have a complete tab
585 * for the dyntab menu
586 * @param $data a multi-dimensional array that will be converted to table contents
587 * @param $tabLabel the label that is put on top of the tab array
588 * @return ready to use for the dyntabmenu itemarray
589 */
590 function renderUserSetupTab($data, $tabLabel) {
591 $code = array();
592 $i = 0;
593
594 // display full help is active?
595 $displayFullText = ($GLOBALS['BE_USER']->uc['edit_showFieldHelp'] == 'text');
596 if ($displayFullText) {
597 $this->doc->tableLayout['defRowEven'] = array('defCol' => array ('<td valign="top" colspan="3">','</td>'));
598 }
599
600 foreach ($data as $fieldname => $data) {
601 // add another table row with the full text help if needed
602 if ($displayFullText) {
603 $code[$i++][1] = $this->getCSH($data['csh'] ? $data['csh'] : $fieldname);
604 }
605 $code[$i][1] = $this->setLabel($fieldname, ($data['labelkey'] ? $data['labelkey'] : ''));
606 $code[$i][2] = $data['form'];
607 $code[$i++][3] = !$displayFullText ? $this->getCSH($data['csh'] ? $data['csh'] : $fieldname) : '&nbsp;';
608 }
609
610 return array(
611 'label' => $tabLabel,
612 'content' => $this->doc->spacer(20) . $this->doc->table($code)
613 );
614 }
615
616 /**
617 * Will make the simulate-user selector if the logged in user is administrator.
618 * 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)
619 *
620 * @return void
621 */
622 function simulateUser() {
623 global $BE_USER,$LANG,$BACK_PATH;
624
625 // *******************************************************************************
626 // If admin, allow simulation of another user
627 // *******************************************************************************
628 $this->simUser = 0;
629 $this->simulateSelector = '';
630 unset($this->OLD_BE_USER);
631 if ($BE_USER->isAdmin()) {
632 $this->simUser = t3lib_div::_GP('simUser');
633
634 // Make user-selector:
635 $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
636 $opt = array();
637 reset($users);
638 $opt[] = '<option></option>';
639 while(list(,$rr)=each($users)) {
640 if ($rr['uid']!=$BE_USER->user['uid']) {
641 $opt[] = '<option value="'.$rr['uid'].'"'.($this->simUser==$rr['uid']?' selected="selected"':'').'>'.htmlspecialchars($rr['username'].' ('.$rr['realName'].')').'</option>';
642 }
643 }
644 $this->simulateSelector = '<select id="field_simulate" name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;">'.implode('',$opt).'</select>';
645 }
646
647 if ($this->simUser>0) { // This can only be set if the previous code was executed.
648 $this->OLD_BE_USER = $BE_USER; // Save old user...
649 unset($BE_USER); // Unset current
650
651 $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth'); // New backend user object
652 $BE_USER->OS = TYPO3_OS;
653 $BE_USER->setBeUserByUid($this->simUser);
654 $BE_USER->fetchGroupData();
655 $BE_USER->backendSetUC();
656 $GLOBALS['BE_USER'] = $BE_USER; // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
657 }
658 }
659
660 /**
661 * Returns the label $str from getLL() and grays out the value if the $str/$key is found in $this->overrideConf array
662 *
663 * @param string Locallang key
664 * @param string Alternative override-config key
665 * @param boolean Defines whether the string should be wrapped in a <label> tag.
666 * @param string Alternative id for use in "for" attribute of <label> tag. By default the $str key is used prepended with "field_".
667 * @return string HTML output.
668 */
669 function setLabel($str, $key='', $addLabelTag=true, $altLabelTagId='') {
670 $out = $GLOBALS['LANG']->getLL($str) . ': ';
671 if (isset($this->overrideConf[($key?$key:$str)])) {
672 $out = '<span style="color:#999999">'.$out.'</span>';
673 }
674 if($addLabelTag) {
675 $out = '<label for="'.($altLabelTagId?$altLabelTagId:'field_'.$str).'">'.$out.'</label>';
676 }
677 return $out;
678 }
679
680 /**
681 * Returns the CSH Icon for given string
682 *
683 * @param string Locallang key
684 * @return string HTML output.
685 */
686 function getCSH($str) {
687 if (!t3lib_div::inList('language', $str)) {
688 $str = 'option_' . $str;
689 }
690 return t3lib_BEfunc::cshItem('_MOD_user_setup', $str, $GLOBALS['BACK_PATH'], '|', false, 'margin-bottom:0px;');
691 }
692 }
693
694
695 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']) {
696 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']);
697 }
698
699
700
701 // Make instance:
702 $SOBE = t3lib_div::makeInstance('SC_mod_user_setup_index');
703 $SOBE->simulateUser();
704 $SOBE->storeIncomingData();
705
706 // These includes MUST be afterwards the settings are saved...!
707 require ($BACK_PATH.'template.php');
708 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
709
710 $SOBE->init();
711 $SOBE->main();
712 $SOBE->printContent();
713
714 ?>