TYPO3 CMS  TYPO3_6-2
SetupModuleController.php
Go to the documentation of this file.
1 <?php
3 
19 
33 
34  // Internal variables:
38  public $MCONF = array();
39 
43  public $MOD_MENU = array();
44 
48  public $MOD_SETTINGS = array();
49 
56  public $doc;
57 
61  public $content;
62 
66  public $overrideConf;
67 
74  public $OLD_BE_USER;
75 
80 
81  protected $pagetreeNeedsRefresh = FALSE;
82 
83  protected $isAdmin;
84 
85  protected $dividers2tabs;
86 
87  protected $tsFieldConf;
88 
89  protected $saveData = FALSE;
90 
91  protected $passwordIsUpdated = FALSE;
92 
93  protected $passwordIsSubmitted = FALSE;
94 
95  protected $setupIsUpdated = FALSE;
96 
97  protected $tempDataIsCleared = FALSE;
98 
99  protected $settingsAreResetToDefault = FALSE;
100 
106  protected $formProtection;
107 
108  /******************************
109  *
110  * Saving data
111  *
112  ******************************/
116  public function __construct() {
118  }
119 
125  public function getFormProtection() {
126  return $this->formProtection;
127  }
128 
136  public function storeIncomingData() {
137  // First check if something is submitted in the data-array from POST vars
138  $d = GeneralUtility::_POST('data');
139  $columns = $GLOBALS['TYPO3_USER_SETTINGS']['columns'];
140  $beUserId = $GLOBALS['BE_USER']->user['uid'];
141  $storeRec = array();
142  $fieldList = $this->getFieldsFromShowItem();
143  if (is_array($d) && $this->formProtection->validateToken((string) GeneralUtility::_POST('formToken'), 'BE user setup', 'edit')) {
144  // UC hashed before applying changes
145  $save_before = md5(serialize($GLOBALS['BE_USER']->uc));
146  // PUT SETTINGS into the ->uc array:
147  // Reload left frame when switching BE language
148  if (isset($d['lang']) && $d['lang'] != $GLOBALS['BE_USER']->uc['lang']) {
149  $this->languageUpdate = TRUE;
150  }
151  // Reload pagetree if the title length is changed
152  if (isset($d['titleLen']) && $d['titleLen'] !== $GLOBALS['BE_USER']->uc['titleLen']) {
153  $this->pagetreeNeedsRefresh = TRUE;
154  }
155  if ($d['setValuesToDefault']) {
156  // If every value should be default
157  $GLOBALS['BE_USER']->resetUC();
158  $this->settingsAreResetToDefault = TRUE;
159  } elseif ($d['clearSessionVars']) {
160  foreach ($GLOBALS['BE_USER']->uc as $key => $value) {
161  if (!isset($columns[$key])) {
162  unset($GLOBALS['BE_USER']->uc[$key]);
163  }
164  }
165  $this->tempDataIsCleared = TRUE;
166  } elseif ($d['save']) {
167  // Save all submitted values if they are no array (arrays are with table=be_users) and exists in $GLOBALS['TYPO3_USER_SETTINGS'][columns]
168  foreach ($columns as $field => $config) {
169  if (!in_array($field, $fieldList)) {
170  continue;
171  }
172  if ($config['table']) {
173  if ($config['table'] == 'be_users' && !in_array($field, array('password', 'password2', 'email', 'realName', 'admin'))) {
174  if (!isset($config['access']) || $this->checkAccess($config) && $GLOBALS['BE_USER']->user[$field] !== $d['be_users'][$field]) {
175  if ($config['type'] === 'check') {
176  $fieldValue = isset($d['be_users'][$field]) ? 1 : 0;
177  } else {
178  $fieldValue = $d['be_users'][$field];
179  }
180  $storeRec['be_users'][$beUserId][$field] = $fieldValue;
181  $GLOBALS['BE_USER']->user[$field] = $fieldValue;
182  }
183  }
184  }
185  if ($config['type'] == 'check') {
186  $GLOBALS['BE_USER']->uc[$field] = isset($d[$field]) ? 1 : 0;
187  } else {
188  $GLOBALS['BE_USER']->uc[$field] = htmlspecialchars($d[$field]);
189  }
190  }
191  // Personal data for the users be_user-record (email, name, password...)
192  // If email and name is changed, set it in the users record:
193  $be_user_data = $d['be_users'];
194  // Possibility to modify the transmitted values. Useful to do transformations, like RSA password decryption
195  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/setup/mod/index.php']['modifyUserDataBeforeSave'])) {
196  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/setup/mod/index.php']['modifyUserDataBeforeSave'] as $function) {
197  $params = array('be_user_data' => &$be_user_data);
198  GeneralUtility::callUserFunction($function, $params, $this);
199  }
200  }
201  $this->passwordIsSubmitted = strlen($be_user_data['password']) > 0;
202  $passwordIsConfirmed = $this->passwordIsSubmitted && $be_user_data['password'] === $be_user_data['password2'];
203  // Update the real name:
204  if ($be_user_data['realName'] !== $GLOBALS['BE_USER']->user['realName']) {
205  $GLOBALS['BE_USER']->user['realName'] = ($storeRec['be_users'][$beUserId]['realName'] = substr($be_user_data['realName'], 0, 80));
206  }
207  // Update the email address:
208  if ($be_user_data['email'] !== $GLOBALS['BE_USER']->user['email']) {
209  $GLOBALS['BE_USER']->user['email'] = ($storeRec['be_users'][$beUserId]['email'] = substr($be_user_data['email'], 0, 80));
210  }
211  // Update the password:
212  if ($passwordIsConfirmed) {
213  $storeRec['be_users'][$beUserId]['password'] = $be_user_data['password2'];
214  $this->passwordIsUpdated = TRUE;
215  }
216  $this->saveData = TRUE;
217  }
218  // Inserts the overriding values.
219  $GLOBALS['BE_USER']->overrideUC();
220  $save_after = md5(serialize($GLOBALS['BE_USER']->uc));
221  // If something in the uc-array of the user has changed, we save the array...
222  if ($save_before != $save_after) {
223  $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc);
224  $GLOBALS['BE_USER']->writelog(254, 1, 0, 1, 'Personal settings changed', array());
225  $this->setupIsUpdated = TRUE;
226  }
227  // If the temporary data has been cleared, lets make a log note about it
228  if ($this->tempDataIsCleared) {
229  $GLOBALS['BE_USER']->writelog(254, 1, 0, 1, $GLOBALS['LANG']->getLL('tempDataClearedLog'), array());
230  }
231  // Persist data if something has changed:
232  if (count($storeRec) && $this->saveData) {
233  // Make instance of TCE for storing the changes.
234  $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
235  $tce->stripslashes_values = FALSE;
236  // This is so the user can actually update his user record.
237  $beUser = $GLOBALS['BE_USER'];
238  $isAdmin = $beUser->user['admin'];
239  $beUser->user['admin'] = 1;
240  $tce->start($storeRec, array(), $beUser);
241  // This is to make sure that the users record can be updated even if in another workspace. This is tolerated.
242  $tce->bypassWorkspaceRestrictions = TRUE;
243  $tce->process_datamap();
244  unset($tce);
245  if (!$this->passwordIsUpdated || count($storeRec['be_users'][$beUserId]) > 1) {
246  $this->setupIsUpdated = TRUE;
247  }
248  // Restore admin status after processing
249  $beUser->user['admin'] = $isAdmin;
250  }
251  }
252  }
253 
254  /******************************
255  *
256  * Rendering module
257  *
258  ******************************/
265  public function init() {
266  $GLOBALS['LANG']->includeLLFile('EXT:setup/mod/locallang.xlf');
267  $this->MCONF = $GLOBALS['MCONF'];
268  // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
269  $scriptUser = $this->getRealScriptUserObj();
270  // ... and checking module access for the logged in user.
271  $scriptUser->modAccess($this->MCONF, 1);
272  $this->isAdmin = $scriptUser->isAdmin();
273  // Getting the 'override' values as set might be set in User TSconfig
274  $this->overrideConf = $GLOBALS['BE_USER']->getTSConfigProp('setup.override');
275  // Getting the disabled fields might be set in User TSconfig (eg setup.fields.password.disabled=1)
276  $this->tsFieldConf = $GLOBALS['BE_USER']->getTSConfigProp('setup.fields');
277  // id password is disabled, disable repeat of password too (password2)
278  if (isset($this->tsFieldConf['password.']) && $this->tsFieldConf['password.']['disabled']) {
279  $this->tsFieldConf['password2.']['disabled'] = 1;
280  }
281  // Create instance of object for output of data
282  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
283  $this->doc->backPath = $GLOBALS['BACK_PATH'];
284  $this->doc->setModuleTemplate('EXT:setup/Resources/Private/Templates/setup.html');
285  $this->doc->form = '<form action="' . BackendUtility::getModuleUrl('user_setup') . '" method="post" name="usersetup" enctype="application/x-www-form-urlencoded">';
286  $this->doc->tableLayout = array(
287  'defRow' => array(
288  '0' => array('<td class="td-label">', '</td>'),
289  'defCol' => array('<td valign="top">', '</td>')
290  )
291  );
292  $this->doc->table_TR = '<tr>';
293  $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2" class="typo3-usersettings">';
294  $this->doc->JScode .= $this->getJavaScript();
295  }
296 
302  protected function getJavaScript() {
303  $javaScript = '';
304  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/setup/mod/index.php']['setupScriptHook'])) {
305  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/setup/mod/index.php']['setupScriptHook'] as $function) {
306  $params = array();
307  $javaScript .= GeneralUtility::callUserFunction($function, $params, $this);
308  }
309  }
310  return $javaScript;
311  }
312 
319  public function main() {
320  global $LANG;
321  if ($this->languageUpdate) {
322  $this->doc->JScodeArray['languageUpdate'] .= '
323  if (top.refreshMenu) {
324  top.refreshMenu();
325  } else {
326  top.TYPO3ModuleMenu.refreshMenu();
327  }
328  ';
329  }
330  if ($this->pagetreeNeedsRefresh) {
331  BackendUtility::setUpdateSignal('updatePageTree');
332  }
333  // Start page:
334  $this->doc->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js');
335  // Use a wrapper div
336  $this->content .= '<div id="user-setup-wrapper">';
337  // Load available backend modules
338  $this->loadModules = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
339  $this->loadModules->observeWorkspaces = TRUE;
340  $this->loadModules->load($GLOBALS['TBE_MODULES']);
341  $this->content .= $this->doc->header($LANG->getLL('UserSettings'));
342  // Show if setup was saved
343  if ($this->setupIsUpdated && !$this->tempDataIsCleared && !$this->settingsAreResetToDefault) {
344  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('setupWasUpdated'), $LANG->getLL('UserSettings'));
345  $this->content .= $flashMessage->render();
346  }
347  // Show if temporary data was cleared
348  if ($this->tempDataIsCleared) {
349  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('tempDataClearedFlashMessage'), $LANG->getLL('tempDataCleared'));
350  $this->content .= $flashMessage->render();
351  }
352  // Show if temporary data was cleared
353  if ($this->settingsAreResetToDefault) {
354  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('settingsAreReset'), $LANG->getLL('resetConfiguration'));
355  $this->content .= $flashMessage->render();
356  }
357  // Notice
358  if ($this->setupIsUpdated || $this->settingsAreResetToDefault) {
359  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('activateChanges'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
360  $this->content .= $flashMessage->render();
361  }
362  // If password is updated, output whether it failed or was OK.
363  if ($this->passwordIsSubmitted) {
364  if ($this->passwordIsUpdated) {
365  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('newPassword_ok'), $LANG->getLL('newPassword'));
366  } else {
367  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('newPassword_failed'), $LANG->getLL('newPassword'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
368  }
369  $this->content .= $flashMessage->render();
370  }
371  // Render the menu items
372  $menuItems = $this->renderUserSetup();
373  $this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', FALSE, FALSE, 1, FALSE, 1, $this->dividers2tabs);
374  $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
375  $this->content .= $this->doc->section('', '<input type="hidden" name="simUser" value="' . $this->simUser . '" />
376  <input type="hidden" name="formToken" value="' . $formToken . '" />
377  <input type="hidden" value="1" name="data[save]" />
378  <input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />
379  <input type="hidden" name="data[clearSessionVars]" value="0" id="clearSessionVars" />');
380  // End of wrapper div
381  $this->content .= '</div>';
382  // Setting up the buttons and markers for docheader
383  $docHeaderButtons = $this->getButtons();
384  $markers['CSH'] = $docHeaderButtons['csh'];
385  $markers['CONTENT'] = $this->content;
386  // Build the <body> for the module
387  $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
388  // Renders the module page
389  $this->content = $this->doc->render($LANG->getLL('UserSettings'), $this->content);
390  }
391 
398  public function printContent() {
399  echo $this->content;
400  }
401 
407  protected function getButtons() {
408  $buttons = array(
409  'csh' => '',
410  'save' => '',
411  'shortcut' => ''
412  );
413  $buttons['csh'] = BackendUtility::cshItem('_MOD_user_setup', '', $GLOBALS['BACK_PATH'], '|', TRUE);
414  $buttons['save'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save', array('html' => '<input type="image" name="data[save]" class="c-inputButton" src="clear.gif" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" />'));
415  if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
416  $buttons['shortcut'] = $this->doc->makeShortcutIcon('', '', $this->MCONF['name']);
417  }
418  return $buttons;
419  }
420 
421  /******************************
422  *
423  * Render module
424  *
425  ******************************/
432  protected function renderUserSetup() {
433  $result = array();
434  $firstTabLabel = '';
435  $code = array();
436  $i = 0;
437  $fieldArray = $this->getFieldsFromShowItem();
438  $this->dividers2tabs = isset($GLOBALS['TYPO3_USER_SETTINGS']['ctrl']['dividers2tabs']) ? (int)$GLOBALS['TYPO3_USER_SETTINGS']['ctrl']['dividers2tabs'] : 0;
439  $tabLabel = '';
440  foreach ($fieldArray as $fieldName) {
441  $more = '';
442  if (substr($fieldName, 0, 8) == '--div--;') {
443  if ($firstTabLabel == '') {
444  // First tab
445  $tabLabel = $this->getLabel(substr($fieldName, 8), '', FALSE);
446  $firstTabLabel = $tabLabel;
447  } else {
448  if ($this->dividers2tabs) {
449  $result[] = array(
450  'label' => $tabLabel,
451  'content' => count($code) ? $this->doc->table($code) : ''
452  );
453  $tabLabel = $this->getLabel(substr($fieldName, 8), '', FALSE);
454  $i = 0;
455  $code = array();
456  }
457  }
458  continue;
459  }
460  $config = $GLOBALS['TYPO3_USER_SETTINGS']['columns'][$fieldName];
461  // Field my be disabled in setup.fields
462  if (isset($this->tsFieldConf[$fieldName . '.']['disabled']) && $this->tsFieldConf[$fieldName . '.']['disabled'] == 1) {
463  continue;
464  }
465  if (isset($config['access']) && !$this->checkAccess($config)) {
466  continue;
467  }
468  $label = $this->getLabel($config['label'], $fieldName);
469  $label = $this->getCSH($config['csh'] ?: $fieldName, $label);
470  $type = $config['type'];
471  $eval = $config['eval'];
472  $class = $config['class'];
473  $style = $config['style'];
474  if ($class) {
475  $more .= ' class="' . $class . '"';
476  }
477  if ($style) {
478  $more .= ' style="' . $style . '"';
479  }
480  if (isset($this->overrideConf[$fieldName])) {
481  $more .= ' disabled="disabled"';
482  }
483  $value = $config['table'] == 'be_users' ? $GLOBALS['BE_USER']->user[$fieldName] : $GLOBALS['BE_USER']->uc[$fieldName];
484  if (!$value && isset($config['default'])) {
485  $value = $config['default'];
486  }
487  $dataAdd = '';
488  if ($config['table'] == 'be_users') {
489  $dataAdd = '[be_users]';
490  }
491  switch ($type) {
492  case 'text':
493  case 'password':
494  $noAutocomplete = '';
495  if ($type === 'password') {
496  $value = '';
497  $noAutocomplete = 'autocomplete="off" ';
498  }
499  $html = '<input id="field_' . $fieldName . '"
500  type="' . $type . '"
501  name="data' . $dataAdd . '[' . $fieldName . ']" ' . $noAutocomplete . 'value="' . htmlspecialchars($value) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . $more . ' />';
502  break;
503  case 'check':
504  if (!$class) {
505  $more .= ' class="check"';
506  }
507  $html = '<input id="field_' . $fieldName . '"
508  type="checkbox"
509  name="data' . $dataAdd . '[' . $fieldName . ']"' . ($value ? ' checked="checked"' : '') . $more . ' />';
510  break;
511  case 'select':
512  if (!$class) {
513  $more .= ' class="select"';
514  }
515  if ($config['itemsProcFunc']) {
516  $html = GeneralUtility::callUserFunction($config['itemsProcFunc'], $config, $this, '');
517  } else {
518  $html = '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_' . $fieldName . '" name="data' . $dataAdd . '[' . $fieldName . ']"' . $more . '>' . LF;
519  foreach ($config['items'] as $key => $optionLabel) {
520  $html .= '<option value="' . $key . '"' . ($value == $key ? ' selected="selected"' : '') . '>' . $this->getLabel($optionLabel, '', FALSE) . '</option>' . LF;
521  }
522  $html .= '</select>';
523  }
524  break;
525  case 'user':
526  $html = GeneralUtility::callUserFunction($config['userFunc'], $config, $this, '');
527  break;
528  case 'button':
529  $html = '';
530  if ($config['onClick']) {
531  $onClick = $config['onClick'];
532  if ($config['onClickLabels']) {
533  foreach ($config['onClickLabels'] as $key => $labelclick) {
534  $config['onClickLabels'][$key] = $this->getLabel($labelclick, '', FALSE);
535  }
536  $onClick = vsprintf($onClick, $config['onClickLabels']);
537  }
538  $html = '<input ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' type="button" value="' . $this->getLabel($config['buttonlabel'], '', FALSE) . '" onclick="' . $onClick . '" />';
539  }
540  break;
541  default:
542  $html = '';
543  }
544  if ($html) {
545  $code[$i][1] = $label;
546  $code[$i++][2] = $html;
547  }
548  }
549  if ($this->dividers2tabs == 0) {
550  $tabLabel = $firstTabLabel;
551  }
552  $result[] = array(
553  'label' => $tabLabel,
554  'content' => count($code) ? $this->doc->table($code) : ''
555  );
556  return $result;
557  }
558 
559  /******************************
560  *
561  * Helper functions
562  *
563  ******************************/
570  protected function getRealScriptUserObj() {
571  return is_object($this->OLD_BE_USER) ? $this->OLD_BE_USER : $GLOBALS['BE_USER'];
572  }
573 
579  public function renderLanguageSelect($params, $pObj) {
580  $languageOptions = array();
581  // Compile the languages dropdown
582  $langDefault = $GLOBALS['LANG']->getLL('lang_default', TRUE);
583  $languageOptions[$langDefault] = '<option value=""' . ($GLOBALS['BE_USER']->uc['lang'] === '' ? ' selected="selected"' : '') . '>' . $langDefault . '</option>';
584  // Traverse the number of languages
586  $locales = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Locales');
587  $languages = $locales->getLanguages();
588  foreach ($languages as $locale => $name) {
589  if ($locale !== 'default') {
590  $defaultName = isset($GLOBALS['LOCAL_LANG']['default']['lang_' . $locale]) ? $GLOBALS['LOCAL_LANG']['default']['lang_' . $locale][0]['source'] : $name;
591  $localizedName = $GLOBALS['LANG']->getLL('lang_' . $locale, TRUE);
592  if ($localizedName === '') {
593  $localizedName = htmlspecialchars($name);
594  }
595  $localLabel = ' - [' . htmlspecialchars($defaultName) . ']';
596  $available = is_dir(PATH_typo3conf . 'l10n/' . $locale) ? TRUE : FALSE;
597  if ($available) {
598  $languageOptions[$defaultName] = '<option value="' . $locale . '"' . ($GLOBALS['BE_USER']->uc['lang'] === $locale ? ' selected="selected"' : '') . '>' . $localizedName . $localLabel . '</option>';
599  }
600  }
601  }
602  ksort($languageOptions);
603  $languageCode = '
604  <select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_lang" name="data[lang]" class="select">' . implode('', $languageOptions) . '
605  </select>';
606  if ($GLOBALS['BE_USER']->uc['lang'] && !@is_dir((PATH_typo3conf . 'l10n/' . $GLOBALS['BE_USER']->uc['lang']))) {
607  $languageUnavailableWarning = 'The selected language "' . $GLOBALS['LANG']->getLL(('lang_' . $GLOBALS['BE_USER']->uc['lang']), TRUE) . '" is not available before the language files are installed.<br />' . ($GLOBALS['BE_USER']->isAdmin() ? 'You can use the Language module to easily download new language files.' : 'Please ask your system administrator to do this.');
608  $languageUnavailableMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $languageUnavailableWarning, '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
609  $languageCode = $languageUnavailableMessage->render() . $languageCode;
610  }
611  return $languageCode;
612  }
613 
619  public function renderStartModuleSelect($params, $pObj) {
620  // Start module select
621  if (empty($GLOBALS['BE_USER']->uc['startModule'])) {
622  $GLOBALS['BE_USER']->uc['startModule'] = $GLOBALS['BE_USER']->uc_default['startModule'];
623  }
624  $startModuleSelect = '<option value=""></option>';
625  foreach ($pObj->loadModules->modules as $mainMod => $modData) {
626  if (isset($modData['sub']) && is_array($modData['sub'])) {
627  $startModuleSelect .= '<option disabled="disabled">' . $GLOBALS['LANG']->moduleLabels['tabs'][($mainMod . '_tab')] . '</option>';
628  foreach ($modData['sub'] as $subKey => $subData) {
629  $modName = $subData['name'];
630  $startModuleSelect .= '<option value="' . $modName . '"' . ($GLOBALS['BE_USER']->uc['startModule'] == $modName ? ' selected="selected"' : '') . '>';
631  $startModuleSelect .= ' - ' . $GLOBALS['LANG']->moduleLabels['tabs'][($modName . '_tab')] . '</option>';
632  }
633  }
634  }
635  return '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . 'id="field_startModule" name="data[startModule]" class="select">' . $startModuleSelect . '</select>';
636  }
637 
644  public function simulateUser() {
645  // If admin, allow simulation of another user
646  $this->simUser = 0;
647  $this->simulateSelector = '';
648  unset($this->OLD_BE_USER);
649  if ($GLOBALS['BE_USER']->isAdmin()) {
650  $this->simUser = (int)GeneralUtility::_GP('simUser');
651  // Make user-selector:
652  $users = BackendUtility::getUserNames('username,usergroup,usergroup_cached_list,uid,realName', BackendUtility::BEenableFields('be_users'));
653  $opt = array();
654  foreach ($users as $rr) {
655  if ($rr['uid'] != $GLOBALS['BE_USER']->user['uid']) {
656  $opt[] = '<option value="' . $rr['uid'] . '"' . ($this->simUser == $rr['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars(($rr['username'] . ' (' . $rr['realName'] . ')')) . '</option>';
657  }
658  }
659  if (count($opt)) {
660  $this->simulateSelector = '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_simulate" name="simulateUser" onchange="' . htmlspecialchars('window.location.href=\'' . BackendUtility::getModuleUrl('user_setup') . '&simUser=\'+this.options[this.selectedIndex].value;') . '"><option></option>' . implode('', $opt) . '</select>';
661  }
662  }
663  // This can only be set if the previous code was executed.
664  if ($this->simUser > 0) {
665  // Save old user...
666  $this->OLD_BE_USER = $GLOBALS['BE_USER'];
667  unset($GLOBALS['BE_USER']);
668  // Unset current
669  // New backend user object
670  $BE_USER = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
671  $BE_USER->OS = TYPO3_OS;
672  $BE_USER->setBeUserByUid($this->simUser);
673  $BE_USER->fetchGroupData();
674  $BE_USER->backendSetUC();
675  // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
676  $GLOBALS['BE_USER'] = $BE_USER;
677  }
678  }
679 
685  public function renderSimulateUserSelect($params, $pObj) {
686  return $pObj->simulateSelector;
687  }
688 
695  protected function checkAccess(array $config) {
696  $access = $config['access'];
697  // Check for hook
698  $accessObject = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['setup']['accessLevelCheck'][$access] . ':&' . $access);
699  if (is_object($accessObject) && method_exists($accessObject, 'accessLevelCheck')) {
700  // Initialize vars. If method fails, $set will be set to FALSE
701  return $accessObject->accessLevelCheck($config);
702  } elseif ($access == 'admin') {
703  return $this->isAdmin;
704  }
705  }
706 
716  protected function getLabel($str, $key = '', $addLabelTag = TRUE, $altLabelTagId = '') {
717  if (substr($str, 0, 4) == 'LLL:') {
718  $out = $GLOBALS['LANG']->sL($str);
719  } else {
720  $out = htmlspecialchars($str);
721  }
722  if (isset($this->overrideConf[$key ?: $str])) {
723  $out = '<span style="color:#999999">' . $out . '</span>';
724  }
725  if ($addLabelTag) {
726  $out = '<label for="' . ($altLabelTagId ?: 'field_' . $key) . '">' . $out . '</label>';
727  }
728  return $out;
729  }
730 
738  protected function getCSH($str, $label) {
739  $context = '_MOD_user_setup';
740  $field = $str;
741  $strParts = explode(':', $str);
742  if (count($strParts) > 1) {
743  // Setting comes from another extension
744  $context = $strParts[0];
745  $field = $strParts[1];
746  } elseif (!GeneralUtility::inList('language,simuser,reset', $str)) {
747  $field = 'option_' . $str;
748  }
749  return BackendUtility::wrapInHelp($context, $field, $label);
750  }
751 
757  protected function getFieldsFromShowItem() {
758  $fieldList = $GLOBALS['TYPO3_USER_SETTINGS']['showitem'];
759  // Disable fields depended on settings
760  if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) {
761  $fieldList = GeneralUtility::rmFromList('edit_RTE', $fieldList);
762  }
763  $fieldArray = GeneralUtility::trimExplode(',', $fieldList, TRUE);
764  return $fieldArray;
765  }
766 
767 }
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
static wrapInHelp($table, $field, $text='', array $overloadHelpText=array())
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
static getUserNames($fields='username, usergroup, usergroup_cached_list, uid', $where='')
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
static setUpdateSignal($set='', $params='')
getLabel($str, $key='', $addLabelTag=TRUE, $altLabelTagId='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
$BE_USER
Definition: index_ts.php:114
$locales
Definition: be_users.php:6