67cd88480a931e036afa70987f5e71692aa72c22
[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 global $BE_USER,$BACK_PATH;
236 $this->MCONF = $GLOBALS['MCONF'];
237
238 // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
239 $scriptUser = $this->getRealScriptUserObj();
240 $scriptUser->modAccess($this->MCONF,1); // ... and checking module access for the logged in user.
241
242 // Getting the 'override' values as set might be set in User TSconfig
243 $this->overrideConf = $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 = $BACK_PATH;
248 $this->doc->setModuleTemplate('templates/setup.html');
249 $this->doc->JScodeLibArray['dyntabmenu'] = $this->doc->getDynTabMenuJScode();
250
251 $this->doc->form = '<form action="index.php" method="post" name="usersetup" enctype="application/x-www-form-urlencoded">';
252 $this->doc->tableLayout = array (
253 'defRow' => array (
254 '0' => array('<td class="td-label">','</td>'),
255 '2' => array('<td class="td-label-right">','</td>'),
256 'defCol' => array('<td valign="top">','</td>')
257 )
258 );
259 $this->doc->table_TR = '<tr>';
260 $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2" id="typo3-userSettings">';
261 }
262
263 /**
264 * Generate the main settings formular:
265 *
266 * @return void
267 */
268 function main() {
269 global $BE_USER,$LANG,$BACK_PATH,$TBE_MODULES;
270
271 if ($this->languageUpdate) {
272 $this->doc->JScode.= '<script language="javascript" type="text/javascript">
273 if(top.refreshMenu) {
274 top.refreshMenu();
275 } else {
276 top.TYPO3ModuleMenu.refreshMenu();
277 }
278
279 if(top.shortcutFrame) {
280 top.shortcutFrame.refreshShortcuts();
281 }
282 </script>';
283 }
284
285 // Start page:
286 $menuItems = array();
287 $this->doc->loadJavascriptLib('md5.js');
288
289 // use a wrapper div
290 $this->content .= '<div id="user-setup-wrapper">';
291
292 // Load available backend modules
293 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
294 $this->loadModules->observeWorkspaces = TRUE;
295 $this->loadModules->load($TBE_MODULES);
296
297 $this->content .= $this->doc->header($LANG->getLL('UserSettings').' - '.$BE_USER->user['realName'].' ['.$BE_USER->user['username'].']');
298
299 // If password is updated, output whether it failed or was OK.
300 if ($this->PASSWORD_UPDATED) {
301 if ($this->PASSWORD_UPDATED>0) {
302 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_ok'),1,0,1);
303 } else {
304 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_failed'),1,0,2);
305 }
306 $this->content .= $this->doc->spacer(25);
307 }
308
309 // display full help is active?
310 $displayFullText = ($BE_USER->uc['edit_showFieldHelp'] == 'text');
311 if ($displayFullText) {
312 $this->doc->tableLayout['defRowEven'] = array ('defCol' => array ('<td valign="top" colspan="3">','</td>'));
313 }
314
315 // Personal data
316 $code = array();
317 $i = 0;
318
319 if ($displayFullText) {
320 $code[$i++][1] = $this->getCSH('beUser_realName');
321
322 }
323 $code[$i][1] = $this->setLabel('beUser_realName');
324 $code[$i][2] = '<input id="field_beUser_realName" type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
325 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_realName');
326
327 if ($displayFullText) {
328 $code[$i++][1] = $this->getCSH('beUser_email');
329 }
330 $code[$i][1] = $this->setLabel('beUser_email');
331 $code[$i][2] = '<input id="field_beUser_email" type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
332 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_email');
333
334 if ($displayFullText) {
335 $code[$i++][1] = $this->getCSH('emailMeAtLogin');
336 }
337 $code[$i][1] = $this->setLabel('emailMeAtLogin').($BE_USER->user['email'] ? ' ('.$BE_USER->user['email'].')' : '');
338 $code[$i][2] = '<input id="field_emailMeAtLogin" type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
339 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('emailMeAtLogin');
340
341 if ($displayFullText) {
342 $code[$i++][1] = $this->getCSH('newPassword');
343 }
344 $code[$i][1] = $this->setLabel('newPassword');
345 $code[$i][2] = '<input id="field_newPassword" type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />';
346 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPassword');
347
348 if ($displayFullText) {
349 $code[$i++][1] = $this->getCSH('newPasswordAgain');
350 }
351 $code[$i][1] = $this->setLabel('newPasswordAgain');
352 $code[$i][2] = '<input id="field_newPasswordAgain" type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />';
353 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPasswordAgain');
354
355 // Languages:
356 $opt = array();
357 $opt['000000000']='
358 <option value="">'.$LANG->getLL('lang_default',1).'</option>';
359 $theLanguages = t3lib_div::trimExplode('|',TYPO3_languages);
360
361 // Character set conversion object:
362 $csConvObj = t3lib_div::makeInstance('t3lib_cs');
363
364 // traverse the number of languages:
365 foreach($theLanguages as $val) {
366 if ($val!='default') {
367 $localLabel = ' - ['.htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_'.$val]).']';
368 $unavailable = $val!='default' && !@is_dir(PATH_typo3conf.'l10n/'.$val) ? '1' : '';
369 if (!$unavailable) $opt[$GLOBALS['LOCAL_LANG']['default']['lang_'.$val].'--'.$val]='
370 <option value="'.$val.'"'.($BE_USER->uc['lang']==$val?' selected="selected"':'').($unavailable ? ' class="c-na"' : '').'>'.$LANG->getLL('lang_'.$val,1).$localLabel.'</option>';
371 }
372 }
373 ksort($opt);
374 $languageCode = '
375 <select id="field_language" name="data[lang]">'.
376 implode('',$opt).'
377 </select>';
378 if ($BE_USER->uc['lang'] && !@is_dir(PATH_typo3conf.'l10n/'.$BE_USER->uc['lang'])) {
379 $languageCode.= '<table border="0" cellpadding="0" cellspacing="0" class="warningbox"><tr><td>'.
380 $this->doc->icons(3).
381 'The selected language is not available before the language pack is installed.<br />'.
382 ($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.').
383 '</td></tr></table>';
384 }
385
386
387 if ($displayFullText) {
388 $code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
389 }
390 $code[$i][1] = $this->setLabel('language');
391 $code[$i][2] = $languageCode;
392 $code[$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
393
394 $menuItems[] = array(
395 'label' => $LANG->getLL('language').' & '.$LANG->getLL('personal_data'),
396 'content' => $this->doc->spacer(20).$this->doc->table($code)
397 );
398
399
400
401 // compiling the 'Startup' section
402 $code = array();
403 $i = 0;
404
405 if ($displayFullText) {
406 $code[$i++][1] = $this->getCSH('condensedMode');
407 }
408 $code[$i][1] = $this->setLabel('condensedMode','condensedMode');
409 $code[$i][2] = '<input id="field_condensedMode" type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
410 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('condensedMode');
411
412 if($GLOBALS['BE_USER']->uc['interfaceSetup'] == 'backend_old') {
413 $code[$i][1] = $this->setLabel('noMenuMode','noMenuMode');
414 $code[$i][2] = '<select id="field_noMenuMode" name="data[noMenuMode]">
415 <option value=""'.(!$BE_USER->uc['noMenuMode']?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_def').'</option>
416 <option value="1"'.($BE_USER->uc['noMenuMode'] && (string)$BE_USER->uc['noMenuMode']!="icons"?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_sel').'</option>
417 <option value="icons"'.((string)$BE_USER->uc['noMenuMode']=='icons'?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_icons').'</option>
418 </select>';
419 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('noMenuMode');
420 }
421
422 if ($displayFullText) {
423 $code[$i++][1] = $this->getCSH('startModule');
424 }
425 $code[$i][1] = $this->setLabel('startModule','startModule');
426 $modSelect = '<select id="field_startModule" name="data[startModule]">';
427 $modSelect .= '<option value=""></option>';
428 if (empty($BE_USER->uc['startModule'])) {
429 $BE_USER->uc['startModule'] = $BE_USER->uc_default['startModule'];
430 }
431 foreach ($this->loadModules->modules as $mainMod => $modData) {
432 if (isset($modData['sub']) && is_array($modData['sub'])) {
433 $modSelect .= '<option disabled="disabled">'.$LANG->moduleLabels['tabs'][$mainMod.'_tab'].'</option>';
434 foreach ($modData['sub'] as $subKey => $subData) {
435 $modName = $subData['name'];
436 $modSelect .= '<option value="'.$modName.'"'.($BE_USER->uc['startModule']==$modName?' selected="selected"':'').'>';
437 $modSelect .= ' - '.$LANG->moduleLabels['tabs'][$modName.'_tab'].'</option>';
438 }
439 }
440 }
441 $modSelect .= '</select>';
442 $code[$i][2] = $modSelect;
443 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('startModule');
444
445 if ($displayFullText) {
446 $code[$i++][1] = $this->getCSH('showThumbs');
447 }
448 $code[$i][1] = $this->setLabel('showThumbs','thumbnailsByDefault');
449 $code[$i][2] = '<input id="field_showThumbs" type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
450 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('showThumbs');
451
452 if ($displayFullText) {
453 $code[$i++][1] = $this->getCSH('helpText');
454 }
455 $code[$i][1] = $this->setLabel('helpText');
456 $code[$i][2] = '<input id="field_helpText" type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
457 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('helpText');
458
459 if ($displayFullText) {
460 $code[$i++][1] = $this->getCSH('edit_showFieldHelp');
461 }
462 $code[$i][1] = $this->setLabel('edit_showFieldHelp');
463 $code[$i][2] = '<select id="field_edit_showFieldHelp" name="data[edit_showFieldHelp]">
464 <option value="">'.$LANG->getLL('edit_showFieldHelp_none').'</option>
465 <option value="icon"'.($BE_USER->uc['edit_showFieldHelp']=='icon'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_icon').'</option>
466 <option value="text"'.($BE_USER->uc['edit_showFieldHelp']=='text'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_message').'</option>
467 </select>';
468 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_showFieldHelp');
469
470 if ($displayFullText) {
471 $code[$i++][1] = $this->getCSH('maxTitleLen');
472 }
473 $code[$i][1] = $this->setLabel('maxTitleLen','titleLen');
474 $code[$i][2] = '<input id="field_maxTitleLen" type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
475 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('maxTitleLen');
476
477 $menuItems[] = array(
478 'label' => $LANG->getLL('opening'),
479 'content' => $this->doc->spacer(20).$this->doc->table($code)
480 );
481
482
483 // Edit
484 $code = array();
485 $i = 0;
486
487 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) {
488 if ($displayFullText) {
489 $code[$i++][1] = $this->getCSH('edit_RTE');
490 }
491 $code[$i][1] = $this->setLabel('edit_RTE');
492 $code[$i][2] = '<input id="field_edit_RTE" type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
493 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_RTE');
494 }
495
496 if ($displayFullText) {
497 $code[$i++][1] = $this->getCSH('edit_docModuleUpload');
498 }
499 $code[$i][1] = $this->setLabel('edit_docModuleUpload');
500 $code[$i][2] = '<input id="field_edit_docModuleUpload" type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
501 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_docModuleUpload');
502
503 if ($displayFullText) {
504 $code[$i++][1] = $this->getCSH('disableCMlayers');
505 }
506 $code[$i][1] = $this->setLabel('disableCMlayers');
507 $code[$i][2] = '<input id="field_disableCMlayers" type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
508 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('disableCMlayers');
509
510
511 // Advanced Operations:
512 if ($displayFullText) {
513 $code[$i++][1] = $this->getCSH('copyLevels');
514 }
515 $code[$i][1] = $this->setLabel('copyLevels');
516 $code[$i][2] = '<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');
517 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('copyLevels');
518
519 if ($displayFullText) {
520 $code[$i++][1] = $this->getCSH('recursiveDelete');
521 }
522 $code[$i][1] = $this->setLabel('recursiveDelete');
523 $code[$i][2] = '<input id="field_recursiveDelete" type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
524 $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('recursiveDelete');
525
526 $menuItems[] = array(
527 'label' => $LANG->getLL('edit_functions') . ' & ' . $LANG->getLL('functions'),
528 'content' => $this->doc->spacer(20).$this->doc->table($code)
529 );
530
531
532 $code = array();
533 $i = 0;
534
535 // Admin functions
536 if($BE_USER->isAdmin()) {
537 // Simulate selector box:
538 if ($this->simulateSelector) {
539 if ($displayFullText) {
540 $code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
541 }
542 $code[$i][1] = $this->setLabel('simulate');
543 $code[$i][2] = $this->simulateSelector;
544 $code[$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
545 }
546
547 $menuItems[] = array(
548 'label' => $LANG->getLL('adminFunctions'),
549 'content' => $this->doc->spacer(20).$this->doc->table($code)
550 );
551 }
552
553 $this->content .= $this->doc->spacer(20);
554 $this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', false, false, 100);
555
556
557 // Submit and reset buttons
558 $this->content .= $this->doc->spacer(20);
559 $this->content .= $this->doc->section('','
560 <input type="hidden" name="simUser" value="'.$this->simUser.'" />
561 <input type="submit" name="submit" value="'.$LANG->getLL('save').'" />
562 <input type="submit" name="data[setValuesToDefault]" value="'.$LANG->getLL('setToStandard').'" onclick="return confirm(\''.$LANG->getLL('setToStandardQuestion').'\');" />'.
563 t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $BACK_PATH)
564 );
565
566 // Notice
567 $this->content .= $this->doc->spacer(30);
568 $this->content .= $this->doc->section('', $LANG->getLL('activateChanges'));
569
570 // Setting up the buttons and markers for docheader
571 $docHeaderButtons = $this->getButtons();
572 $markers['CSH'] = $docHeaderButtons['csh'];
573 $markers['CONTENT'] = $this->content;
574
575 // Build the <body> for the module
576 $this->content = $this->doc->startPage($LANG->getLL('UserSettings'));
577 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
578 $this->content.= $this->doc->endPage();
579 $this->content = $this->doc->insertStylesAndJS($this->content);
580
581 // end of wrapper div
582 $this->content .= '</div>';
583 }
584
585 /**
586 * Prints the content / ends page
587 *
588 * @return void
589 */
590 function printContent() {
591 echo $this->content;
592 }
593
594 /**
595 * Create the panel of buttons for submitting the form or otherwise perform operations.
596 *
597 * @return array all available buttons as an assoc. array
598 */
599 protected function getButtons() {
600 global $LANG, $BACK_PATH, $BE_USER;
601
602 $buttons = array(
603 'csh' => '',
604 'save' => '',
605 'shortcut' => '',
606 );
607
608 //CSH
609 $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_user_setup', '', $BACK_PATH, '|', TRUE);
610
611 if ($BE_USER->mayMakeShortcut()) {
612 // Shortcut
613 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','',$this->MCONF['name']);
614 }
615
616 return $buttons;
617 }
618
619
620
621
622
623
624
625
626
627
628 /******************************
629 *
630 * Helper functions
631 *
632 ******************************/
633
634 /**
635 * Returns the backend user object, either the global OR the $this->OLD_BE_USER which is set during simulate-user operation.
636 * Anyway: The REAL user is returned - the one logged in.
637 *
638 * @return object The REAL user is returned - the one logged in.
639 */
640 function getRealScriptUserObj() {
641 return is_object($this->OLD_BE_USER) ? $this->OLD_BE_USER : $GLOBALS['BE_USER'];
642 }
643
644 /**
645 * Will make the simulate-user selector if the logged in user is administrator.
646 * 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)
647 *
648 * @return void
649 */
650 function simulateUser() {
651 global $BE_USER,$LANG,$BACK_PATH;
652
653 // *******************************************************************************
654 // If admin, allow simulation of another user
655 // *******************************************************************************
656 $this->simUser = 0;
657 $this->simulateSelector = '';
658 unset($this->OLD_BE_USER);
659 if ($BE_USER->isAdmin()) {
660 $this->simUser = t3lib_div::_GP('simUser');
661
662 // Make user-selector:
663 $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
664 $opt = array();
665 reset($users);
666 $opt[] = '<option></option>';
667 while(list(,$rr)=each($users)) {
668 if ($rr['uid']!=$BE_USER->user['uid']) {
669 $opt[] = '<option value="'.$rr['uid'].'"'.($this->simUser==$rr['uid']?' selected="selected"':'').'>'.htmlspecialchars($rr['username'].' ('.$rr['realName'].')').'</option>';
670 }
671 }
672 $this->simulateSelector = '<select id="field_simulate" name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;">'.implode('',$opt).'</select>';
673 }
674
675 if ($this->simUser>0) { // This can only be set if the previous code was executed.
676 $this->OLD_BE_USER = $BE_USER; // Save old user...
677 unset($BE_USER); // Unset current
678
679 $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth'); // New backend user object
680 $BE_USER->OS = TYPO3_OS;
681 $BE_USER->setBeUserByUid($this->simUser);
682 $BE_USER->fetchGroupData();
683 $BE_USER->backendSetUC();
684 $GLOBALS['BE_USER'] = $BE_USER; // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
685 }
686 }
687
688 /**
689 * Returns the label $str from getLL() and grays out the value if the $str/$key is found in $this->overrideConf array
690 *
691 * @param string Locallang key
692 * @param string Alternative override-config key
693 * @param boolean Defines whether the string should be wrapped in a <label> tag.
694 * @param string Alternative id for use in "for" attribute of <label> tag. By default the $str key is used prepended with "field_".
695 * @return string HTML output.
696 */
697 function setLabel($str, $key='', $addLabelTag=true, $altLabelTagId='') {
698 $out = $GLOBALS['LANG']->getLL($str) . ': ';
699 if (isset($this->overrideConf[($key?$key:$str)])) {
700 $out = '<span style="color:#999999">'.$out.'</span>';
701 }
702 if($addLabelTag) {
703 $out = '<label for="'.($altLabelTagId?$altLabelTagId:'field_'.$str).'">'.$out.'</label>';
704 }
705 return $out;
706 }
707
708 /**
709 * Returns the CSH Icon for given string
710 *
711 * @param string Locallang key
712 * @return string HTML output.
713 */
714 function getCSH($str) {
715 return t3lib_BEfunc::cshItem('_MOD_user_setup', 'option_'.$str, $GLOBALS['BACK_PATH'],'|',FALSE,'margin-bottom:0px;');
716 }
717 }
718
719
720 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']) {
721 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']);
722 }
723
724
725
726 // Make instance:
727 $SOBE = t3lib_div::makeInstance('SC_mod_user_setup_index');
728 $SOBE->simulateUser();
729 $SOBE->storeIncomingData();
730
731 // These includes MUST be afterwards the settings are saved...!
732 require ($BACK_PATH.'template.php');
733 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
734
735 $SOBE->init();
736 $SOBE->main();
737 $SOBE->printContent();
738
739 ?>