"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/setup/mod/index.php Source File", "datetime" => "Sat Dec 2 19:22:17 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 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 ***************************************************************/
00061 unset($MCONF);
00062 require('conf.php');
00063 require($BACK_PATH.'init.php');
00064 require_once(PATH_t3lib.'class.t3lib_tcemain.php');
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00086 class SC_mod_user_setup_index {
00087 
00088                 // Internal variables:
00089         var $MCONF = array();
00090         var $MOD_MENU = array();
00091         var $MOD_SETTINGS = array();
00092         var $doc;
00093 
00094         var $content;
00095         var $overrideConf;
00096         var $OLD_BE_USER;
00097 
00098 
00099 
00100 
00101 
00102         /******************************
00103          *
00104          * Saving data
00105          *
00106          ******************************/
00107 
00114         function storeIncomingData()    {
00115                 global $BE_USER;
00116 
00117 
00118                         // First check if something is submittet in the data-array from POST vars
00119                 $d = t3lib_div::_POST('data');
00120                 if (is_array($d))       {
00121 
00122                                 // UC hashed before applying changes
00123                         $save_before = md5(serialize($BE_USER->uc));
00124 
00125                                 // PUT SETTINGS into the ->uc array:
00126 
00127                                 // Language
00128                         $BE_USER->uc['lang'] = $d['lang'];
00129 
00130                                 // Startup
00131                         $BE_USER->uc['condensedMode'] = $d['condensedMode'];
00132                         $BE_USER->uc['noMenuMode'] = $d['noMenuMode'];
00133                         if (t3lib_extMgm::isLoaded('taskcenter'))       $BE_USER->uc['startInTaskCenter'] = $d['startInTaskCenter'];
00134                         $BE_USER->uc['thumbnailsByDefault'] = $d['thumbnailsByDefault'];
00135                         $BE_USER->uc['helpText'] = $d['helpText'];
00136                         $BE_USER->uc['titleLen'] = intval($d['titleLen']);
00137 
00138                                 // Advanced functions:
00139                         $BE_USER->uc['copyLevels'] = t3lib_div::intInRange($d['copyLevels'],0,100);
00140                         $BE_USER->uc['recursiveDelete'] = $d['recursiveDelete'];
00141 
00142                                 // Edit
00143                         $BE_USER->uc['edit_wideDocument'] = $d['edit_wideDocument'];
00144                         if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])    { $BE_USER->uc['edit_RTE'] = $d['edit_RTE']; }
00145                         $BE_USER->uc['edit_docModuleUpload'] = $d['edit_docModuleUpload'];
00146                         $BE_USER->uc['edit_showFieldHelp'] = $d['edit_showFieldHelp'];
00147                         $BE_USER->uc['disableCMlayers'] = $d['disableCMlayers'];
00148 
00149                                 // Personal:
00150                         $BE_USER->uc['emailMeAtLogin'] = $d['emailMeAtLogin'];
00151 
00152 
00153                         if ($d['setValuesToDefault'])   {       // If every value should be default
00154                                 $BE_USER->resetUC();
00155                         }
00156                         $BE_USER->overrideUC(); // Inserts the overriding values.
00157 
00158                         $save_after = md5(serialize($BE_USER->uc));
00159                         if ($save_before!=$save_after)  {       // If something in the uc-array of the user has changed, we save the array...
00160                                 $BE_USER->writeUC($BE_USER->uc);
00161                                 $BE_USER->writelog(254,1,0,1,'Personal settings changed',Array());
00162                         }
00163 
00164 
00165                                 // Personal data for the users be_user-record (email, name, password...)
00166                                 // If email and name is changed, set it in the users record:
00167                         $be_user_data = t3lib_div::_GP('ext_beuser');
00168                         $this->PASSWORD_UPDATED = strlen($be_user_data['password1'].$be_user_data['password2'])>0 ? -1 : 0;
00169                         if ($be_user_data['email']!=$BE_USER->user['email']
00170                                         || $be_user_data['realName']!=$BE_USER->user['realName']
00171                                         || (strlen($be_user_data['password1'])==32
00172                                                         && !strcmp($be_user_data['password1'],$be_user_data['password2']))
00173                                         )       {
00174                                 $storeRec = array();
00175                                 $BE_USER->user['realName'] = $storeRec['be_users'][$BE_USER->user['uid']]['realName'] = substr($be_user_data['realName'],0,80);
00176                                 $BE_USER->user['email'] = $storeRec['be_users'][$BE_USER->user['uid']]['email'] = substr($be_user_data['email'],0,80);
00177                                 if (strlen($be_user_data['password1'])==32 && !strcmp($be_user_data['password1'],$be_user_data['password2']))   {
00178                                         $BE_USER->user['password'] = $storeRec['be_users'][$BE_USER->user['uid']]['password'] = $be_user_data['password1'];
00179                                         $this->PASSWORD_UPDATED = 1;
00180                                 }
00181 
00182                                         // Make instance of TCE for storing the changes.
00183                                 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00184                                 $tce->stripslashes_values=0;
00185                                 $tce->start($storeRec,Array(),$BE_USER);
00186                                 $tce->admin = 1;        // This is so the user can actually update his user record.
00187                                 $tce->bypassWorkspaceRestrictions = TRUE;       // This is to make sure that the users record can be updated even if in another workspace. This is tolerated.
00188                                 $tce->process_datamap();
00189                                 unset($tce);
00190                         }
00191                 }
00192         }
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205         /******************************
00206          *
00207          * Rendering module
00208          *
00209          ******************************/
00210 
00216         function init() {
00217                 global $BE_USER,$BACK_PATH;
00218                 $this->MCONF = $GLOBALS['MCONF'];
00219 
00220                         // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
00221                 $scriptUser = $this->getRealScriptUserObj();
00222                 $scriptUser->modAccess($this->MCONF,1); // ... and checking module access for the logged in user.
00223 
00224                         // Getting the 'override' values as set might be set in User TSconfig
00225                 $this->overrideConf = $BE_USER->getTSConfigProp('setup.override');
00226 
00227                         // Create instance of object for output of data
00228                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00229                 $this->doc->backPath = $BACK_PATH;
00230                 $this->doc->docType = 'xhtml_trans';
00231 
00232                 $this->doc->form = '<form action="index.php" method="post" enctype="application/x-www-form-urlencoded">';
00233                 $this->doc->tableLayout = Array (
00234                         'defRow' => Array (
00235                                 '0' => Array('<td align="left" width="300">','</td>'),
00236                                 'defCol' => Array('<td valign="top">','</td>')
00237                         )
00238                 );
00239                 $this->doc->table_TR = '<tr class="bgColor4">';
00240                 $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2">';
00241         }
00242 
00248         function main() {
00249                 global $BE_USER,$LANG,$BACK_PATH;
00250 
00251                         // Start page:
00252                 $this->doc->JScode.= '<script language="javascript" type="text/javascript" src="'.$BACK_PATH.'md5.js"></script>';
00253                 $this->content.= $this->doc->startPage($LANG->getLL('UserSettings'));
00254                 $this->content.= $this->doc->header($LANG->getLL('UserSettings').' - ['.$BE_USER->user['username'].']');
00255 
00256                         // CSH general:
00257                 $this->content.= t3lib_BEfunc::cshItem('_MOD_user_setup', '', $GLOBALS['BACK_PATH'],'|');
00258 
00259                         // If password is updated, output whether it failed or was OK.
00260                 if ($this->PASSWORD_UPDATED)    {
00261                         if ($this->PASSWORD_UPDATED>0)  {
00262                                 $this->content.=$this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_ok'),1,0,1);
00263                         } else {
00264                                 $this->content.=$this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_failed'),1,0,2);
00265                         }
00266                         $this->content.=$this->doc->spacer(25);
00267                 }
00268 
00269                         // Simulate selector box:
00270                 if ($this->simulateSelector)    {
00271                         $this->content.=$this->doc->section($LANG->getLL('simulate').':',$this->simulateSelector.t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $GLOBALS['BACK_PATH'],'|'),1,0,($this->simUser?2:0));
00272                 }
00273 
00274 
00275                         // Languages:
00276                 $opt = array();
00277                 $opt['000000000']='
00278                                         <option value="">'.$LANG->getLL('lang_default',1).'</option>';
00279                 $theLanguages = t3lib_div::trimExplode('|',TYPO3_languages);
00280 
00281                         // Character set conversion object:
00282                 $csConvObj = t3lib_div::makeInstance('t3lib_cs');
00283 
00284                         // traverse the number of languages:
00285                 foreach($theLanguages as $val)  {
00286                         if ($val!='default')    {
00287                                 $localLabel = '  -  ['.htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_'.$val]).']';
00288                                 $unavailable = $val!='default' && !@is_dir(PATH_site.'typo3conf/l10n/'.$val) ? '1' : '';
00289                                 $opt[$GLOBALS['LOCAL_LANG']['default']['lang_'.$val].'--'.$val]='
00290                                         <option value="'.$val.'"'.($BE_USER->uc['lang']==$val?' selected="selected"':'').($unavailable ? ' class="c-na"' : '').'>'.$LANG->getLL('lang_'.$val,1).$localLabel.'</option>';
00291                         }
00292                 }
00293                 ksort($opt);
00294                 $code='
00295                                 <select name="data[lang]">'.
00296                                         implode('',$opt).'
00297                                 </select>'.
00298                                 t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $GLOBALS['BACK_PATH'],'|');
00299                                 if ($BE_USER->uc['lang'] && !@is_dir(PATH_site.'typo3conf/l10n/'.$BE_USER->uc['lang'])) {
00300                                         $code.= '<table border="0" cellpadding="0" cellspacing="0" class="warningbox"><tr><td>'.
00301                                                                 $this->doc->icons(3).
00302                                                                 'The selected language is not available before the language pack is installed.<br />'.
00303                                                                 ($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.').
00304                                                         '</td></tr></table>';
00305                                 }
00306                 $this->content.=$this->doc->section($LANG->getLL('language').':',$code,0,1);
00307 
00308 
00309                         // 'Startup' section:
00310                 $code = Array();
00311 
00312                 $code[2][1] = $this->setLabel('condensedMode','condensedMode');
00313                 $code[2][2] = '<input type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
00314                 $code[3][1] = $this->setLabel('noMenuMode','noMenuMode');
00315                 $code[3][2] = '<select name="data[noMenuMode]">
00316                         <option value=""'.(!$BE_USER->uc['noMenuMode']?' selected="selected"':'').'>'.$this->setLabel('noMenuMode_def').'</option>
00317                         <option value="1"'.($BE_USER->uc['noMenuMode'] && (string)$BE_USER->uc['noMenuMode']!="icons"?' selected="selected"':'').'>'.$this->setLabel('noMenuMode_sel').'</option>
00318                         <option value="icons"'.((string)$BE_USER->uc['noMenuMode']=='icons'?' selected="selected"':'').'>'.$this->setLabel('noMenuMode_icons').'</option>
00319                 </select>';
00320                 if (t3lib_extMgm::isLoaded('taskcenter'))       {
00321                         $code[4][1] = $this->setLabel('startInTaskCenter','startInTaskCenter');
00322                         $code[4][2] = '<input type="checkbox" name="data[startInTaskCenter]"'.($BE_USER->uc['startInTaskCenter']?' checked="checked"':'').' />';
00323                 }
00324                 $code[5][1] = $this->setLabel('showThumbs','thumbnailsByDefault');
00325                 $code[5][2] = '<input type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
00326                 $code[6][1] = $this->setLabel('helpText');
00327                 $code[6][2] = '<input type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
00328                 $code[7][1] = $this->setLabel('maxTitleLen','titleLen');
00329                 $code[7][2] = '<input type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
00330 
00331                 $this->content.=$this->doc->section($LANG->getLL('opening').':',$this->doc->table($code),0,1);
00332 
00333 
00334                         // Advanced Operations:
00335                 $code = Array();
00336                 $code[1][1] = $this->setLabel('copyLevels');
00337                 $code[1][2] = '<input type="text" name="data[copyLevels]" value="'.$BE_USER->uc['copyLevels'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" /> '.$this->setLabel('levels','copyLevels');
00338                 $code[2][1] = $this->setLabel('recursiveDelete');
00339                 $code[2][2] = '<input type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
00340 
00341                 $this->content.=$this->doc->section($LANG->getLL('functions').":",$this->doc->table($code),0,1);
00342 
00343 
00344                         // Edit
00345                 $code = Array();
00346                 $code[2][1] = $this->setLabel('edit_wideDocument');
00347                 $code[2][2] = '<input type="checkbox" name="data[edit_wideDocument]"'.($BE_USER->uc['edit_wideDocument']?' checked="checked"':'').' />';
00348                 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])    {
00349                         $code[3][1] = $this->setLabel('edit_RTE');
00350                         $code[3][2] = '<input type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
00351                 }
00352                 $code[4][1] = $this->setLabel('edit_docModuleUpload');
00353                 $code[4][2] = '<input type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
00354 
00355                 $code[6][1] = $this->setLabel('edit_showFieldHelp');
00356                 $code[6][2] = '<select name="data[edit_showFieldHelp]">
00357                         <option value=""></option>
00358                         <option value="icon"'.($BE_USER->uc['edit_showFieldHelp']=='icon'?' selected="selected"':'').'>'.$this->setLabel('edit_showFieldHelp_icon').'</option>
00359                         <option value="text"'.($BE_USER->uc['edit_showFieldHelp']=='text'?' selected="selected"':'').'>'.$this->setLabel('edit_showFieldHelp_message').'</option>
00360                 </select>';
00361 
00362                 $code[7][1] = $this->setLabel('disableCMlayers');
00363                 $code[7][2] = '<input type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
00364 
00365                 $this->content.=$this->doc->section($LANG->getLL('edit_functions').":",$this->doc->table($code),0,1);
00366 
00367 
00368                         // Personal data
00369                 $code = Array();
00370                 $code[1][1] = $this->setLabel('beUser_realName');
00371                 $code[1][2] = '<input type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
00372                 $code[2][1] = $this->setLabel('beUser_email');
00373                 $code[2][2] = '<input type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
00374                 $code[3][1] = $this->setLabel('emailMeAtLogin').' ('.$GLOBALS['BE_USER']->user['email'].')';
00375                 $code[3][2] = '<input type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
00376                 $code[4][1] = $this->setLabel('newPassword');
00377                 $code[4][2] = '<input type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />';
00378                 $code[5][1] = $this->setLabel('newPasswordAgain');
00379                 $code[5][2] = '<input type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />';
00380 
00381                 $this->content.=$this->doc->section($LANG->getLL('personal_data').":",$this->doc->table($code),0,1);
00382 
00383 
00384                         // Submit:
00385                 $this->content.=$this->doc->spacer(20);
00386                 $this->content.=$this->doc->section('','
00387                         <input type="submit" name="submit" value="'.$LANG->getLL('save').'" />
00388                          &nbsp; <b>'.$LANG->getLL('setToStandard').': </b><input type="checkbox" name="data[setValuesToDefault]" />'.
00389                          t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $GLOBALS['BACK_PATH'],'|').'
00390                         <input type="hidden" name="simUser" value="'.$this->simUser.'" />');
00391 
00392 
00393                         // Notice
00394                 $this->content.=$this->doc->spacer(5);
00395                 $this->content.=$this->doc->section('',$LANG->getLL('activateChanges'));
00396         }
00397 
00403         function printContent() {
00404                 $this->content.= $this->doc->endPage();
00405                 echo $this->content;
00406                 exit;
00407         }
00408 
00409 
00410 
00411 
00412 
00413 
00414 
00415 
00416 
00417 
00418 
00419 
00420         /******************************
00421          *
00422          * Helper functions
00423          *
00424          ******************************/
00425 
00432         function getRealScriptUserObj() {
00433                 return is_object($this->OLD_BE_USER) ? $this->OLD_BE_USER : $GLOBALS['BE_USER'];
00434         }
00435 
00442         function simulateUser() {
00443                 global $BE_USER,$LANG,$BACK_PATH;
00444 
00445                 // *******************************************************************************
00446                 // If admin, allow simulation of another user
00447                 // *******************************************************************************
00448                 $this->simUser = 0;
00449                 $this->simulateSelector = '';
00450                 unset($this->OLD_BE_USER);
00451                 if ($BE_USER->isAdmin())        {
00452                         $this->simUser = t3lib_div::_GP('simUser');
00453 
00454                                 // Make user-selector:
00455                         $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
00456                         $opt = array();
00457                         reset($users);
00458                         $opt[] = '<option></option>';
00459                         while(list(,$rr)=each($users))  {
00460                                 if ($rr['uid']!=$BE_USER->user['uid'])  {
00461                                         $opt[] = '<option value="'.$rr['uid'].'"'.($this->simUser==$rr['uid']?' selected="selected"':'').'>'.htmlspecialchars($rr['username'].' ('.$rr['realName'].')').'</option>';
00462                                 }
00463                         }
00464                         $this->simulateSelector = '<select name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;">'.implode('',$opt).'</select>';
00465                 }
00466 
00467                 if ($this->simUser>0)   {       // This can only be set if the previous code was executed.
00468                         $this->OLD_BE_USER = $BE_USER;  // Save old user...
00469                         unset($BE_USER);        // Unset current
00470 
00471                         $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth'); // New backend user object
00472                         $BE_USER->OS = TYPO3_OS;
00473                         $BE_USER->setBeUserByUid($this->simUser);
00474                         $BE_USER->fetchGroupData();
00475                         $BE_USER->backendSetUC();
00476                         $GLOBALS['BE_USER'] = $BE_USER; // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
00477                 }
00478         }
00479 
00488         function setLabel($str,$key='') {
00489                 $out = $GLOBALS['LANG']->getLL($str);
00490                 if (isset($this->overrideConf[($key?$key:$str)]))       {
00491                         $out = '<span style="color:#999999">'.$out.'</span>';
00492                 }
00493 
00494                         // CSH:
00495                 $csh = t3lib_BEfunc::cshItem('_MOD_user_setup', 'option_'.$str, $GLOBALS['BACK_PATH'],'|',FALSE,'margin-bottom:0px;');
00496                 if (strlen($csh))       $csh = ': '.$csh;
00497 
00498                         // Return value:
00499                 return $out.$csh;
00500         }
00501 }
00502 
00503 // Include extension?
00504 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']) {
00505         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']);
00506 }
00507 
00508 
00509 
00510 
00511 
00512 
00513 
00514 
00515 
00516 
00517 
00518 
00519 // Make instance:
00520 $SOBE = t3lib_div::makeInstance('SC_mod_user_setup_index');
00521 $SOBE->simulateUser();
00522 $SOBE->storeIncomingData();
00523 
00524 // These includes MUST be afterwards the settings are saved...!
00525 require ($BACK_PATH.'template.php');
00526 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
00527 
00528 $SOBE->init();
00529 $SOBE->main();
00530 $SOBE->printContent();
00531 ?>