index.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Module: User configuration
00029  *
00030  * This module lets users viev and change their individual settings
00031  *
00032  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00033  * Revised for TYPO3 3.7 6/2004 by Kasper Skaarhoj
00034  * XHTML compatible.
00035  */
00036 /**
00037  * [CLASS/FUNCTION INDEX of SCRIPT]
00038  *
00039  *
00040  *
00041  *   86: class SC_mod_user_setup_index
00042  *
00043  *              SECTION: Saving data
00044  *  114:     function storeIncomingData()
00045  *
00046  *              SECTION: Rendering module
00047  *  216:     function init()
00048  *  248:     function main()
00049  *  403:     function printContent()
00050  *
00051  *              SECTION: Helper functions
00052  *  432:     function getRealScriptUserObj()
00053  *  442:     function simulateUser()
00054  *  488:     function setLabel($str,$key='')
00055  *
00056  * TOTAL FUNCTIONS: 7
00057  * (This index is automatically created/updated by the extension "extdeveval")
00058  *
00059  */
00060 
00061 unset($MCONF);
00062 require('conf.php');
00063 require($BACK_PATH.'init.php');
00064 require_once(PATH_t3lib.'class.t3lib_tcemain.php');
00065 require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 /**
00081  * Script class for the Setup module
00082  *
00083  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00084  * @package TYPO3
00085  * @subpackage tx_setup
00086  */
00087 class SC_mod_user_setup_index {
00088 
00089         // Internal variables:
00090     var $MCONF = array();
00091     var $MOD_MENU = array();
00092     var $MOD_SETTINGS = array();
00093 
00094     /**
00095      * document template object
00096      *
00097      * @var mediumDoc
00098      */
00099     var $doc;
00100 
00101     var $content;
00102     var $overrideConf;
00103 
00104     /**
00105      * backend user object, set during simulate-user operation
00106      *
00107      * @var t3lib_beUserAuth
00108      */
00109     var $OLD_BE_USER;
00110     var $languageUpdate;
00111 
00112 
00113 
00114 
00115 
00116     /******************************
00117      *
00118      * Saving data
00119      *
00120      ******************************/
00121 
00122     /**
00123      * If settings are submitted to _POST[DATA], store them
00124      * NOTICE: This method is called before the template.php is included. See buttom of document
00125      *
00126      * @return  void
00127      */
00128     function storeIncomingData()    {
00129         global $BE_USER;
00130 
00131 
00132             // First check if something is submittet in the data-array from POST vars
00133         $d = t3lib_div::_POST('data');
00134         if (is_array($d))   {
00135 
00136                 // UC hashed before applying changes
00137             $save_before = md5(serialize($BE_USER->uc));
00138 
00139                 // PUT SETTINGS into the ->uc array:
00140 
00141                 // reload left frame when switching BE language
00142             if (isset($d['lang']) && ($d['lang'] != $BE_USER->uc['lang'])) {
00143                 $this->languageUpdate = true;
00144             }
00145                 // Language
00146             $BE_USER->uc['lang'] = $d['lang'];
00147 
00148                 // Startup
00149             $BE_USER->uc['condensedMode'] = $d['condensedMode'];
00150             $BE_USER->uc['noMenuMode'] = $d['noMenuMode'];
00151             $BE_USER->uc['startModule'] = $d['startModule'];
00152             $BE_USER->uc['thumbnailsByDefault'] = $d['thumbnailsByDefault'];
00153             $BE_USER->uc['helpText'] = $d['helpText'];
00154             $BE_USER->uc['titleLen'] = intval($d['titleLen']);
00155 
00156                 // Advanced functions:
00157             $BE_USER->uc['copyLevels'] = t3lib_div::intInRange($d['copyLevels'],0,100);
00158             $BE_USER->uc['recursiveDelete'] = $d['recursiveDelete'];
00159 
00160                 // Edit
00161             $BE_USER->uc['edit_wideDocument'] = $d['edit_wideDocument'];
00162             if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])    { $BE_USER->uc['edit_RTE'] = $d['edit_RTE']; }
00163             $BE_USER->uc['edit_docModuleUpload'] = $d['edit_docModuleUpload'];
00164             $BE_USER->uc['edit_showFieldHelp'] = $d['edit_showFieldHelp'];
00165             $BE_USER->uc['disableCMlayers'] = $d['disableCMlayers'];
00166 
00167                 // Personal:
00168             $BE_USER->uc['emailMeAtLogin'] = $d['emailMeAtLogin'];
00169 
00170 
00171             if ($d['setValuesToDefault'])   {   // If every value should be default
00172                 $BE_USER->resetUC();
00173             }
00174             $BE_USER->overrideUC(); // Inserts the overriding values.
00175 
00176             $save_after = md5(serialize($BE_USER->uc));
00177             if ($save_before!=$save_after)  {   // If something in the uc-array of the user has changed, we save the array...
00178                 $BE_USER->writeUC($BE_USER->uc);
00179                 $BE_USER->writelog(254,1,0,1,'Personal settings changed',Array());
00180             }
00181 
00182 
00183                 // Personal data for the users be_user-record (email, name, password...)
00184                 // If email and name is changed, set it in the users record:
00185             $be_user_data = t3lib_div::_GP('ext_beuser');
00186             $this->PASSWORD_UPDATED = strlen($be_user_data['password1'].$be_user_data['password2'])>0 ? -1 : 0;
00187             if ($be_user_data['email']!=$BE_USER->user['email']
00188                     || $be_user_data['realName']!=$BE_USER->user['realName']
00189                     || (strlen($be_user_data['password1'])==32
00190                             && !strcmp($be_user_data['password1'],$be_user_data['password2']))
00191                     )   {
00192                 $storeRec = array();
00193                 $BE_USER->user['realName'] = $storeRec['be_users'][$BE_USER->user['uid']]['realName'] = substr($be_user_data['realName'],0,80);
00194                 $BE_USER->user['email'] = $storeRec['be_users'][$BE_USER->user['uid']]['email'] = substr($be_user_data['email'],0,80);
00195                 if (strlen($be_user_data['password1'])==32 && !strcmp($be_user_data['password1'],$be_user_data['password2']))   {
00196                     $BE_USER->user['password'] = $storeRec['be_users'][$BE_USER->user['uid']]['password'] = $be_user_data['password1'];
00197                     $this->PASSWORD_UPDATED = 1;
00198                 }
00199 
00200                     // Make instance of TCE for storing the changes.
00201                 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00202                 $tce->stripslashes_values=0;
00203                 $tce->start($storeRec,Array(),$BE_USER);
00204                 $tce->admin = 1;    // This is so the user can actually update his user record.
00205                 $tce->bypassWorkspaceRestrictions = TRUE;   // This is to make sure that the users record can be updated even if in another workspace. This is tolerated.
00206                 $tce->process_datamap();
00207                 unset($tce);
00208             }
00209         }
00210     }
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223     /******************************
00224      *
00225      * Rendering module
00226      *
00227      ******************************/
00228 
00229     /**
00230      * Initializes the module for display of the settings form.
00231      *
00232      * @return  void
00233      */
00234     function init() {
00235         global $BE_USER,$BACK_PATH;
00236         $this->MCONF = $GLOBALS['MCONF'];
00237 
00238             // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
00239         $scriptUser = $this->getRealScriptUserObj();
00240         $scriptUser->modAccess($this->MCONF,1); // ... and checking module access for the logged in user.
00241 
00242             // Getting the 'override' values as set might be set in User TSconfig
00243         $this->overrideConf = $BE_USER->getTSConfigProp('setup.override');
00244 
00245             // Create instance of object for output of data
00246         $this->doc = t3lib_div::makeInstance('template');
00247         $this->doc->backPath = $BACK_PATH;
00248         $this->doc->setModuleTemplate('templates/setup.html');
00249         $this->doc->JScodeLibArray['dyntabmenu'] = $this->doc->getDynTabMenuJScode();
00250 
00251         $this->doc->form = '<form action="index.php" method="post" name="usersetup" enctype="application/x-www-form-urlencoded">';
00252         $this->doc->tableLayout = array (
00253             'defRow' => array (
00254                 '0' => array('<td class="td-label">','</td>'),
00255                 '2' => array('<td class="td-label-right">','</td>'),
00256                 'defCol' => array('<td valign="top">','</td>')
00257             )
00258         );
00259         $this->doc->table_TR = '<tr>';
00260         $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2" id="typo3-userSettings">';
00261     }
00262 
00263     /**
00264      * Generate the main settings formular:
00265      *
00266      * @return  void
00267      */
00268     function main() {
00269         global $BE_USER,$LANG,$BACK_PATH,$TBE_MODULES;
00270 
00271         if ($this->languageUpdate) {
00272             $this->doc->JScode.= '<script language="javascript" type="text/javascript">
00273     if(top.refreshMenu) {
00274         top.refreshMenu();
00275     } else {
00276         top.TYPO3ModuleMenu.refreshMenu();
00277     }
00278 
00279     if(top.shortcutFrame) {
00280         top.shortcutFrame.refreshShortcuts();
00281     }
00282 </script>';
00283         }
00284 
00285             // Start page:
00286         $menuItems = array();
00287         $this->doc->loadJavascriptLib('md5.js');
00288 
00289             // use a wrapper div
00290         $this->content .= '<div id="user-setup-wrapper">';
00291 
00292             // Load available backend modules
00293         $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00294         $this->loadModules->observeWorkspaces = TRUE;
00295         $this->loadModules->load($TBE_MODULES);
00296 
00297         $this->content .= $this->doc->header($LANG->getLL('UserSettings').' - '.$BE_USER->user['realName'].' ['.$BE_USER->user['username'].']');
00298 
00299             // If password is updated, output whether it failed or was OK.
00300         if ($this->PASSWORD_UPDATED)    {
00301             if ($this->PASSWORD_UPDATED>0)  {
00302                 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_ok'),1,0,1);
00303             } else {
00304                 $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_failed'),1,0,2);
00305             }
00306             $this->content .= $this->doc->spacer(25);
00307         }
00308 
00309             // display full help is active?
00310         $displayFullText = ($BE_USER->uc['edit_showFieldHelp'] == 'text');
00311         if ($displayFullText) {
00312             $this->doc->tableLayout['defRowEven'] = array ('defCol' => array ('<td valign="top" colspan="3">','</td>'));
00313         }
00314 
00315             // Personal data
00316         $code = array();
00317         $i = 0;
00318 
00319         if ($displayFullText) {
00320             $code[$i++][1] = $this->getCSH('beUser_realName');
00321 
00322         }
00323         $code[$i][1] = $this->setLabel('beUser_realName');
00324         $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).' />';
00325         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_realName');
00326 
00327         if ($displayFullText) {
00328             $code[$i++][1] = $this->getCSH('beUser_email');
00329         }
00330         $code[$i][1] = $this->setLabel('beUser_email');
00331         $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).' />';
00332         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('beUser_email');
00333 
00334         if ($displayFullText) {
00335             $code[$i++][1] = $this->getCSH('emailMeAtLogin');
00336         }
00337         $code[$i][1] = $this->setLabel('emailMeAtLogin').($BE_USER->user['email'] ? ' ('.$BE_USER->user['email'].')' : '');
00338         $code[$i][2] = '<input id="field_emailMeAtLogin" type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
00339         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('emailMeAtLogin');
00340 
00341         if ($displayFullText) {
00342             $code[$i++][1] = $this->getCSH('newPassword');
00343         }
00344         $code[$i][1] = $this->setLabel('newPassword');
00345         $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):\'\';" />';
00346         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPassword');
00347 
00348         if ($displayFullText) {
00349             $code[$i++][1] = $this->getCSH('newPasswordAgain');
00350         }
00351         $code[$i][1] = $this->setLabel('newPasswordAgain');
00352         $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):\'\'" />';
00353         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('newPasswordAgain');
00354 
00355             // Languages:
00356         $opt = array();
00357         $opt['000000000']='
00358                     <option value="">'.$LANG->getLL('lang_default',1).'</option>';
00359         $theLanguages = t3lib_div::trimExplode('|',TYPO3_languages);
00360 
00361             // Character set conversion object:
00362         $csConvObj = t3lib_div::makeInstance('t3lib_cs');
00363 
00364             // traverse the number of languages:
00365         foreach($theLanguages as $val)  {
00366             if ($val!='default')    {
00367                 $localLabel = '  -  ['.htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_'.$val]).']';
00368                 $unavailable = $val!='default' && !@is_dir(PATH_typo3conf.'l10n/'.$val) ? '1' : '';
00369                 if (!$unavailable) $opt[$GLOBALS['LOCAL_LANG']['default']['lang_'.$val].'--'.$val]='
00370                     <option value="'.$val.'"'.($BE_USER->uc['lang']==$val?' selected="selected"':'').($unavailable ? ' class="c-na"' : '').'>'.$LANG->getLL('lang_'.$val,1).$localLabel.'</option>';
00371             }
00372         }
00373         ksort($opt);
00374         $languageCode = '
00375                 <select id="field_language" name="data[lang]">'.
00376                     implode('',$opt).'
00377                 </select>';
00378             if ($BE_USER->uc['lang'] && !@is_dir(PATH_typo3conf.'l10n/'.$BE_USER->uc['lang']))  {
00379                 $languageCode.= '<table border="0" cellpadding="0" cellspacing="0" class="warningbox"><tr><td>'.
00380                             $this->doc->icons(3).
00381                             'The selected language is not available before the language pack is installed.<br />'.
00382                             ($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.').
00383                         '</td></tr></table>';
00384             }
00385 
00386 
00387         if ($displayFullText) {
00388             $code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
00389         }
00390         $code[$i][1] = $this->setLabel('language');
00391         $code[$i][2] = $languageCode;
00392         $code[$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH);
00393 
00394         $menuItems[] = array(
00395                 'label'   => $LANG->getLL('language').' & '.$LANG->getLL('personal_data'),
00396                 'content' => $this->doc->spacer(20).$this->doc->table($code)
00397         );
00398 
00399 
00400 
00401             // compiling the 'Startup' section
00402         $code = array();
00403         $i = 0;
00404 
00405         if ($displayFullText) {
00406             $code[$i++][1] = $this->getCSH('condensedMode');
00407         }
00408         $code[$i][1] = $this->setLabel('condensedMode','condensedMode');
00409         $code[$i][2] = '<input id="field_condensedMode" type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
00410         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('condensedMode');
00411 
00412         if($GLOBALS['BE_USER']->uc['interfaceSetup'] == 'backend_old') {
00413             $code[$i][1] = $this->setLabel('noMenuMode','noMenuMode');
00414             $code[$i][2] = '<select id="field_noMenuMode" name="data[noMenuMode]">
00415                 <option value=""'.(!$BE_USER->uc['noMenuMode']?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_def').'</option>
00416                 <option value="1"'.($BE_USER->uc['noMenuMode'] && (string)$BE_USER->uc['noMenuMode']!="icons"?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_sel').'</option>
00417                 <option value="icons"'.((string)$BE_USER->uc['noMenuMode']=='icons'?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_icons').'</option>
00418             </select>';
00419             $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('noMenuMode');
00420         }
00421 
00422         if ($displayFullText) {
00423             $code[$i++][1] = $this->getCSH('startModule');
00424         }
00425         $code[$i][1] = $this->setLabel('startModule','startModule');
00426         $modSelect = '<select id="field_startModule" name="data[startModule]">';
00427         $modSelect .= '<option value=""></option>';
00428         if (empty($BE_USER->uc['startModule'])) {
00429             $BE_USER->uc['startModule'] = $BE_USER->uc_default['startModule'];
00430         }
00431         foreach ($this->loadModules->modules as $mainMod => $modData) {
00432             if (isset($modData['sub']) && is_array($modData['sub'])) {
00433                 $modSelect .= '<option disabled="disabled">'.$LANG->moduleLabels['tabs'][$mainMod.'_tab'].'</option>';
00434                 foreach ($modData['sub'] as $subKey => $subData) {
00435                     $modName = $subData['name'];
00436                     $modSelect .= '<option value="'.$modName.'"'.($BE_USER->uc['startModule']==$modName?' selected="selected"':'').'>';
00437                     $modSelect .= ' - '.$LANG->moduleLabels['tabs'][$modName.'_tab'].'</option>';
00438                 }
00439             }
00440         }
00441         $modSelect .= '</select>';
00442         $code[$i][2] = $modSelect;
00443         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('startModule');
00444 
00445         if ($displayFullText) {
00446             $code[$i++][1] = $this->getCSH('showThumbs');
00447         }
00448         $code[$i][1] = $this->setLabel('showThumbs','thumbnailsByDefault');
00449         $code[$i][2] = '<input id="field_showThumbs" type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
00450         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('showThumbs');
00451 
00452         if ($displayFullText) {
00453             $code[$i++][1] = $this->getCSH('helpText');
00454         }
00455         $code[$i][1] = $this->setLabel('helpText');
00456         $code[$i][2] = '<input id="field_helpText" type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
00457         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('helpText');
00458 
00459         if ($displayFullText) {
00460             $code[$i++][1] = $this->getCSH('edit_showFieldHelp');
00461         }
00462         $code[$i][1] = $this->setLabel('edit_showFieldHelp');
00463         $code[$i][2] = '<select id="field_edit_showFieldHelp" name="data[edit_showFieldHelp]">
00464             <option value="">'.$LANG->getLL('edit_showFieldHelp_none').'</option>
00465             <option value="icon"'.($BE_USER->uc['edit_showFieldHelp']=='icon'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_icon').'</option>
00466             <option value="text"'.($BE_USER->uc['edit_showFieldHelp']=='text'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_message').'</option>
00467         </select>';
00468         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_showFieldHelp');
00469 
00470         if ($displayFullText) {
00471             $code[$i++][1] = $this->getCSH('maxTitleLen');
00472         }
00473         $code[$i][1] = $this->setLabel('maxTitleLen','titleLen');
00474         $code[$i][2] = '<input id="field_maxTitleLen" type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
00475         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('maxTitleLen');
00476 
00477         $menuItems[] = array(
00478                 'label' => $LANG->getLL('opening'),
00479                 'content' => $this->doc->spacer(20).$this->doc->table($code)
00480         );
00481 
00482 
00483             // Edit
00484         $code = array();
00485         $i = 0;
00486 
00487         if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])    {
00488             if ($displayFullText) {
00489                 $code[$i++][1] = $this->getCSH('edit_RTE');
00490             }
00491             $code[$i][1] = $this->setLabel('edit_RTE');
00492             $code[$i][2] = '<input id="field_edit_RTE" type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
00493             $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_RTE');
00494         }
00495 
00496         if ($displayFullText) {
00497             $code[$i++][1] = $this->getCSH('edit_docModuleUpload');
00498         }
00499         $code[$i][1] = $this->setLabel('edit_docModuleUpload');
00500         $code[$i][2] = '<input id="field_edit_docModuleUpload" type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
00501         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('edit_docModuleUpload');
00502 
00503         if ($displayFullText) {
00504             $code[$i++][1] = $this->getCSH('disableCMlayers');
00505         }
00506         $code[$i][1] = $this->setLabel('disableCMlayers');
00507         $code[$i][2] = '<input id="field_disableCMlayers" type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
00508         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('disableCMlayers');
00509 
00510 
00511             // Advanced Operations:
00512         if ($displayFullText) {
00513             $code[$i++][1] = $this->getCSH('copyLevels');
00514         }
00515         $code[$i][1] = $this->setLabel('copyLevels');
00516         $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');
00517         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('copyLevels');
00518 
00519         if ($displayFullText) {
00520             $code[$i++][1] = $this->getCSH('recursiveDelete');
00521         }
00522         $code[$i][1] = $this->setLabel('recursiveDelete');
00523         $code[$i][2] = '<input id="field_recursiveDelete" type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
00524         $code[$i++][3] = $displayFullText ? '&nbsp;' : $this->getCSH('recursiveDelete');
00525 
00526         $menuItems[] = array(
00527                 'label'   => $LANG->getLL('edit_functions') . ' & ' . $LANG->getLL('functions'),
00528                 'content' => $this->doc->spacer(20).$this->doc->table($code)
00529         );
00530 
00531 
00532         $code = array();
00533         $i = 0;
00534 
00535             // Admin functions
00536         if($BE_USER->isAdmin()) {
00537                 // Simulate selector box:
00538             if ($this->simulateSelector)    {
00539                 if ($displayFullText) {
00540                     $code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
00541                 }
00542                 $code[$i][1] = $this->setLabel('simulate');
00543                 $code[$i][2] = $this->simulateSelector;
00544                 $code[$i++][3] = $displayFullText ? '&nbsp;' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH);
00545             }
00546 
00547             $menuItems[] = array(
00548                     'label'   => $LANG->getLL('adminFunctions'),
00549                     'content' => $this->doc->spacer(20).$this->doc->table($code)
00550             );
00551         }
00552 
00553         $this->content .= $this->doc->spacer(20);
00554         $this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', false, false, 100);
00555 
00556 
00557             // Submit and reset buttons
00558         $this->content .= $this->doc->spacer(20);
00559         $this->content .= $this->doc->section('','
00560             <input type="hidden" name="simUser" value="'.$this->simUser.'" />
00561             <input type="submit" name="submit" value="'.$LANG->getLL('save').'" />
00562             <input type="submit" name="data[setValuesToDefault]" value="'.$LANG->getLL('setToStandard').'" onclick="return confirm(\''.$LANG->getLL('setToStandardQuestion').'\');" />'.
00563             t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $BACK_PATH)
00564         );
00565 
00566             // Notice
00567         $this->content .= $this->doc->spacer(30);
00568         $this->content .= $this->doc->section('', $LANG->getLL('activateChanges'));
00569 
00570             // Setting up the buttons and markers for docheader
00571         $docHeaderButtons = $this->getButtons();
00572         $markers['CSH'] = $docHeaderButtons['csh'];
00573         $markers['CONTENT'] = $this->content;
00574 
00575             // Build the <body> for the module
00576         $this->content = $this->doc->startPage($LANG->getLL('UserSettings'));
00577         $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00578         $this->content.= $this->doc->endPage();
00579         $this->content = $this->doc->insertStylesAndJS($this->content);
00580 
00581             // end of wrapper div
00582         $this->content .= '</div>';
00583     }
00584 
00585     /**
00586      * Prints the content / ends page
00587      *
00588      * @return  void
00589      */
00590     function printContent() {
00591         echo $this->content;
00592     }
00593 
00594     /**
00595      * Create the panel of buttons for submitting the form or otherwise perform operations.
00596      *
00597      * @return  array   all available buttons as an assoc. array
00598      */
00599     protected function getButtons() {
00600         global $LANG, $BACK_PATH, $BE_USER;
00601 
00602         $buttons = array(
00603             'csh' => '',
00604             'save' => '',
00605             'shortcut' => '',
00606         );
00607 
00608             //CSH
00609         $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_user_setup', '', $BACK_PATH, '|', TRUE);
00610 
00611         if ($BE_USER->mayMakeShortcut())    {
00612                 // Shortcut
00613             $buttons['shortcut'] = $this->doc->makeShortcutIcon('','',$this->MCONF['name']);
00614         }
00615 
00616         return $buttons;
00617     }
00618 
00619 
00620 
00621 
00622 
00623 
00624 
00625 
00626 
00627 
00628     /******************************
00629      *
00630      * Helper functions
00631      *
00632      ******************************/
00633 
00634     /**
00635      * Returns the backend user object, either the global OR the $this->OLD_BE_USER which is set during simulate-user operation.
00636      * Anyway: The REAL user is returned - the one logged in.
00637      *
00638      * @return  object      The REAL user is returned - the one logged in.
00639      */
00640     function getRealScriptUserObj() {
00641         return is_object($this->OLD_BE_USER) ? $this->OLD_BE_USER : $GLOBALS['BE_USER'];
00642     }
00643 
00644     /**
00645      * Will make the simulate-user selector if the logged in user is administrator.
00646      * 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)
00647      *
00648      * @return  void
00649      */
00650     function simulateUser() {
00651         global $BE_USER,$LANG,$BACK_PATH;
00652 
00653         // *******************************************************************************
00654         // If admin, allow simulation of another user
00655         // *******************************************************************************
00656         $this->simUser = 0;
00657         $this->simulateSelector = '';
00658         unset($this->OLD_BE_USER);
00659         if ($BE_USER->isAdmin())    {
00660             $this->simUser = t3lib_div::_GP('simUser');
00661 
00662                 // Make user-selector:
00663             $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
00664             $opt = array();
00665             reset($users);
00666             $opt[] = '<option></option>';
00667             while(list(,$rr)=each($users))  {
00668                 if ($rr['uid']!=$BE_USER->user['uid'])  {
00669                     $opt[] = '<option value="'.$rr['uid'].'"'.($this->simUser==$rr['uid']?' selected="selected"':'').'>'.htmlspecialchars($rr['username'].' ('.$rr['realName'].')').'</option>';
00670                 }
00671             }
00672             $this->simulateSelector = '<select id="field_simulate" name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;">'.implode('',$opt).'</select>';
00673         }
00674 
00675         if ($this->simUser>0)   {   // This can only be set if the previous code was executed.
00676             $this->OLD_BE_USER = $BE_USER;  // Save old user...
00677             unset($BE_USER);    // Unset current
00678 
00679             $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth'); // New backend user object
00680             $BE_USER->OS = TYPO3_OS;
00681             $BE_USER->setBeUserByUid($this->simUser);
00682             $BE_USER->fetchGroupData();
00683             $BE_USER->backendSetUC();
00684             $GLOBALS['BE_USER'] = $BE_USER; // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
00685         }
00686     }
00687 
00688     /**
00689      * Returns the label $str from getLL() and grays out the value if the $str/$key is found in $this->overrideConf array
00690      *
00691      * @param   string      Locallang key
00692      * @param   string      Alternative override-config key
00693      * @param   boolean     Defines whether the string should be wrapped in a <label> tag.
00694      * @param   string      Alternative id for use in "for" attribute of <label> tag. By default the $str key is used prepended with "field_".
00695      * @return  string      HTML output.
00696      */
00697     function setLabel($str, $key='', $addLabelTag=true, $altLabelTagId='')  {
00698         $out = $GLOBALS['LANG']->getLL($str) . ': ';
00699         if (isset($this->overrideConf[($key?$key:$str)]))   {
00700             $out = '<span style="color:#999999">'.$out.'</span>';
00701         }
00702         if($addLabelTag) {
00703             $out = '<label for="'.($altLabelTagId?$altLabelTagId:'field_'.$str).'">'.$out.'</label>';
00704         }
00705         return $out;
00706     }
00707 
00708     /**
00709      * Returns the CSH Icon for given string
00710      *
00711      * @param   string      Locallang key
00712      * @return  string      HTML output.
00713      */
00714     function getCSH($str) {
00715         return t3lib_BEfunc::cshItem('_MOD_user_setup', 'option_'.$str, $GLOBALS['BACK_PATH'],'|',FALSE,'margin-bottom:0px;');
00716     }
00717 }
00718 
00719 
00720 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']) {
00721     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']);
00722 }
00723 
00724 
00725 
00726 // Make instance:
00727 $SOBE = t3lib_div::makeInstance('SC_mod_user_setup_index');
00728 $SOBE->simulateUser();
00729 $SOBE->storeIncomingData();
00730 
00731 // These includes MUST be afterwards the settings are saved...!
00732 require ($BACK_PATH.'template.php');
00733 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
00734 
00735 $SOBE->init();
00736 $SOBE->main();
00737 $SOBE->printContent();
00738 
00739 ?>

Generated on Sat Jan 3 04:23:25 2009 for TYPO3 API by  doxygen 1.4.7