Documentation TYPO3 par Ameos

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;
00187                                 $tce->process_datamap();
00188                                 unset($tce);
00189                         }
00190                 }
00191         }
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204         /******************************
00205          *
00206          * Rendering module
00207          *
00208          ******************************/
00209 
00215         function init() {
00216                 global $BE_USER,$BACK_PATH;
00217                 $this->MCONF = $GLOBALS['MCONF'];
00218 
00219                         // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!)
00220                 $scriptUser = $this->getRealScriptUserObj();
00221                 $scriptUser->modAccess($this->MCONF,1); // ... and checking module access for the logged in user.
00222 
00223                         // Getting the 'override' values as set might be set in User TSconfig
00224                 $this->overrideConf = $BE_USER->getTSConfigProp('setup.override');
00225 
00226                         // Create instance of object for output of data
00227                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00228                 $this->doc->backPath = $BACK_PATH;
00229                 $this->doc->docType = 'xhtml_trans';
00230 
00231                 $this->doc->form = '<form action="index.php" method="post" enctype="application/x-www-form-urlencoded">';
00232                 $this->doc->tableLayout = Array (
00233                         'defRow' => Array (
00234                                 '0' => Array('<td align="left" width="300">','</td>'),
00235                                 'defCol' => Array('<td valign="top">','</td>')
00236                         )
00237                 );
00238                 $this->doc->table_TR = '<tr class="bgColor4">';
00239                 $this->doc->table_TABLE = '<table border="0" cellspacing="1" cellpadding="2">';
00240         }
00241 
00247         function main() {
00248                 global $BE_USER,$LANG,$BACK_PATH;
00249 
00250                         // Start page:
00251                 $this->doc->JScode.= '<script language="javascript" type="text/javascript" src="'.$BACK_PATH.'md5.js"></script>';
00252                 $this->content.= $this->doc->startPage($LANG->getLL('UserSettings'));
00253                 $this->content.= $this->doc->header($LANG->getLL('UserSettings').' - ['.$BE_USER->user['username'].']');
00254 
00255                         // CSH general:
00256                 $this->content.= t3lib_BEfunc::cshItem('_MOD_user_setup', '', $GLOBALS['BACK_PATH'],'|');
00257 
00258                         // If password is updated, output whether it failed or was OK.
00259                 if ($this->PASSWORD_UPDATED)    {
00260                         if ($this->PASSWORD_UPDATED>0)  {
00261                                 $this->content.=$this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_ok'),1,0,1);
00262                         } else {
00263                                 $this->content.=$this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_failed'),1,0,2);
00264                         }
00265                         $this->content.=$this->doc->spacer(25);
00266                 }
00267 
00268                         // Simulate selector box:
00269                 if ($this->simulateSelector)    {
00270                         $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));
00271                 }
00272 
00273 
00274                         // Languages:
00275                 $opt = array();
00276                 $opt['000000000']='
00277                                         <option value="">'.$LANG->getLL('lang_default',1).'</option>';
00278                 $theLanguages = t3lib_div::trimExplode('|',TYPO3_languages);
00279 
00280                         // Character set conversion object:
00281                 $csConvObj = t3lib_div::makeInstance('t3lib_cs');
00282 
00283                         // traverse the number of languages:
00284                 foreach($theLanguages as $val)  {
00285                         if ($val!='default')    {
00286                                 $localLabel = '  -  ['.htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_'.$val]).']';
00287                                 $unavailable = $val!='default' && !t3lib_extMgm::isLoaded('csh_'.$val) ? '1' : '';
00288                                 $opt[$GLOBALS['LOCAL_LANG']['default']['lang_'.$val].'--'.$val]='
00289                                         <option value="'.$val.'"'.($BE_USER->uc['lang']==$val?' selected="selected"':'').($unavailable ? ' class="c-na"' : '').'>'.$LANG->getLL('lang_'.$val,1).$localLabel.'</option>';
00290                         }
00291                 }
00292                 ksort($opt);
00293                 $code='
00294                                 <select name="data[lang]">'.
00295                                         implode('',$opt).'
00296                                 </select>'.
00297                                 t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $GLOBALS['BACK_PATH'],'|');
00298                                 if ($BE_USER->uc['lang'] && !t3lib_extMgm::isLoaded('csh_'.$BE_USER->uc['lang']))       {
00299                                         $code.= '<table border="0" cellpadding="0" cellspacing="0" class="warningbox"><tr><td>'.
00300                                                                 $this->doc->icons(3).
00301                                                                 sprintf(nl2br('The selected language is not fully available before the associated language pack extension, "%s", is installed on the system.
00302                                                                 Please ask your system administrator for this.'), 'csh_'.$BE_USER->uc['lang']).
00303                                                         '</td></tr></table>';
00304                                 }
00305                 $this->content.=$this->doc->section($LANG->getLL('language').':',$code,0,1);
00306 
00307 
00308                         // 'Startup' section:
00309                 $code = Array();
00310 
00311                 $code[2][1] = $this->setLabel('condensedMode','condensedMode').':';
00312                 $code[2][2] = '<input type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
00313                 $code[3][1] = $this->setLabel('noMenuMode','noMenuMode').':';
00314                 $code[3][2] = '<select name="data[noMenuMode]">
00315                         <option value=""'.(!$BE_USER->uc['noMenuMode']?' selected="selected"':'').'>'.$this->setLabel('noMenuMode_def').'</option>
00316                         <option value="1"'.($BE_USER->uc['noMenuMode'] && (string)$BE_USER->uc['noMenuMode']!="icons"?' selected="selected"':'').'>'.$this->setLabel('noMenuMode_sel').'</option>
00317                         <option value="icons"'.((string)$BE_USER->uc['noMenuMode']=='icons'?' selected="selected"':'').'>'.$this->setLabel('noMenuMode_icons').'</option>
00318                 </select>';
00319                 if (t3lib_extMgm::isLoaded('taskcenter'))       {
00320                         $code[4][1] = $this->setLabel('startInTaskCenter','startInTaskCenter').':';
00321                         $code[4][2] = '<input type="checkbox" name="data[startInTaskCenter]"'.($BE_USER->uc['startInTaskCenter']?' checked="checked"':'').' />';
00322                 }
00323                 $code[5][1] = $this->setLabel('showThumbs','thumbnailsByDefault').':';
00324                 $code[5][2] = '<input type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
00325                 $code[6][1] = $this->setLabel('helpText').':';
00326                 $code[6][2] = '<input type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
00327                 $code[7][1] = $this->setLabel('maxTitleLen','titleLen').':';
00328                 $code[7][2] = '<input type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
00329 
00330                 $this->content.=$this->doc->section($LANG->getLL('opening').':',$this->doc->table($code),0,1);
00331 
00332 
00333                         // Advanced Operations:
00334                 $code = Array();
00335                 $code[1][1] = $this->setLabel('copyLevels').':';
00336                 $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');
00337                 $code[2][1] = $this->setLabel('recursiveDelete').':';
00338                 $code[2][2] = '<input type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
00339 
00340                 $this->content.=$this->doc->section($LANG->getLL('functions').":",$this->doc->table($code),0,1);
00341 
00342 
00343                         // Edit
00344                 $code = Array();
00345                 $code[2][1] = $this->setLabel('edit_wideDocument').':';
00346                 $code[2][2] = '<input type="checkbox" name="data[edit_wideDocument]"'.($BE_USER->uc['edit_wideDocument']?' checked="checked"':'').' />';
00347                 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])    {
00348                         $code[3][1] = $this->setLabel('edit_RTE').':';
00349                         $code[3][2] = '<input type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
00350                 }
00351                 $code[4][1] = $this->setLabel('edit_docModuleUpload').':';
00352                 $code[4][2] = '<input type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
00353 
00354                 $code[6][1] = $this->setLabel('edit_showFieldHelp').':';
00355                 $code[6][2] = '<select name="data[edit_showFieldHelp]">
00356                         <option value=""></option>
00357                         <option value="icon"'.($BE_USER->uc['edit_showFieldHelp']=='icon'?' selected="selected"':'').'>'.$this->setLabel('edit_showFieldHelp_icon').'</option>
00358                         <option value="text"'.($BE_USER->uc['edit_showFieldHelp']=='text'?' selected="selected"':'').'>'.$this->setLabel('edit_showFieldHelp_message').'</option>
00359                 </select>';
00360 
00361                 $code[7][1] = $this->setLabel('disableCMlayers').':';
00362                 $code[7][2] = '<input type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
00363 
00364                 $this->content.=$this->doc->section($LANG->getLL('edit_functions').":",$this->doc->table($code),0,1);
00365 
00366 
00367                         // Personal data
00368                 $code = Array();
00369                 $code[1][1] = $this->setLabel('beUser_realName').':';
00370                 $code[1][2] = '<input type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
00371                 $code[2][1] = $this->setLabel('beUser_email').':';
00372                 $code[2][2] = '<input type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
00373                 $code[3][1] = $this->setLabel('emailMeAtLogin').' ('.$GLOBALS['BE_USER']->user['email'].'):';
00374                 $code[3][2] = '<input type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
00375                 $code[4][1] = $this->setLabel('newPassword').':';
00376                 $code[4][2] = '<input type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />';
00377                 $code[5][1] = $this->setLabel('newPasswordAgain').':';
00378                 $code[5][2] = '<input type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />';
00379 
00380                 $this->content.=$this->doc->section($LANG->getLL('personal_data').":",$this->doc->table($code),0,1);
00381 
00382 
00383                         // Submit:
00384                 $this->content.=$this->doc->spacer(20);
00385                 $this->content.=$this->doc->section('','
00386                         <input type="submit" name="submit" value="'.$LANG->getLL('save').'" />
00387                          &nbsp; <b>'.$LANG->getLL('setToStandard').': </b><input type="checkbox" name="data[setValuesToDefault]" />'.
00388                          t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $GLOBALS['BACK_PATH'],'|').'
00389                         <input type="hidden" name="simUser" value="'.$this->simUser.'" />');
00390 
00391 
00392                         // Notice
00393                 $this->content.=$this->doc->spacer(5);
00394                 $this->content.=$this->doc->section('',$LANG->getLL('activateChanges'));
00395         }
00396 
00402         function printContent() {
00403                 $this->content.= $this->doc->endPage();
00404                 echo $this->content;
00405                 exit;
00406         }
00407 
00408 
00409 
00410 
00411 
00412 
00413 
00414 
00415 
00416 
00417 
00418 
00419         /******************************
00420          *
00421          * Helper functions
00422          *
00423          ******************************/
00424 
00431         function getRealScriptUserObj() {
00432                 return is_object($this->OLD_BE_USER) ? $this->OLD_BE_USER : $GLOBALS['BE_USER'];
00433         }
00434 
00441         function simulateUser() {
00442                 global $BE_USER,$LANG,$BACK_PATH;
00443 
00444                 // *******************************************************************************
00445                 // If admin, allow simulation of another user
00446                 // *******************************************************************************
00447                 $this->simUser = 0;
00448                 $this->simulateSelector = '';
00449                 unset($this->OLD_BE_USER);
00450                 if ($BE_USER->isAdmin())        {
00451                         $this->simUser = t3lib_div::_GP('simUser');
00452 
00453                                 // Make user-selector:
00454                         $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
00455                         $opt = array();
00456                         reset($users);
00457                         $opt[] = '<option></option>';
00458                         while(list(,$rr)=each($users))  {
00459                                 if ($rr['uid']!=$BE_USER->user['uid'])  {
00460                                         $opt[] = '<option value="'.$rr['uid'].'"'.($this->simUser==$rr['uid']?' selected="selected"':'').'>'.htmlspecialchars($rr['username'].' ('.$rr['realName'].')').'</option>';
00461                                 }
00462                         }
00463                         $this->simulateSelector = '<select name="simulateUser" onchange="document.location=\'index.php?simUser=\'+this.options[this.selectedIndex].value;">'.implode('',$opt).'</select>';
00464                 }
00465 
00466                 if ($this->simUser>0)   {       // This can only be set if the previous code was executed.
00467                         $this->OLD_BE_USER = $BE_USER;  // Save old user...
00468                         unset($BE_USER);        // Unset current
00469 
00470                         $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth'); // New backend user object
00471                         $BE_USER->OS = TYPO3_OS;
00472                         $BE_USER->setBeUserByUid($this->simUser);
00473                         $BE_USER->fetchGroupData();
00474                         $BE_USER->backendSetUC();
00475                         $GLOBALS['BE_USER'] = $BE_USER; // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
00476                 }
00477         }
00478 
00487         function setLabel($str,$key='') {
00488                 $out = $GLOBALS['LANG']->getLL($str);
00489                 if (isset($this->overrideConf[($key?$key:$str)]))       {
00490                         $out = '<span style="color:#999999">'.$out.'</span>';
00491                 }
00492 
00493                         // CSH:
00494                 $out.= t3lib_BEfunc::cshItem('_MOD_user_setup', 'option_'.$str, $GLOBALS['BACK_PATH'],'|',FALSE,'margin-bottom:0px;');
00495 
00496                         // Return value:
00497                 return $out;
00498         }
00499 }
00500 
00501 // Include extension?
00502 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']) {
00503         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/setup/mod/index.php']);
00504 }
00505 
00506 
00507 
00508 
00509 
00510 
00511 
00512 
00513 
00514 
00515 
00516 
00517 // Make instance:
00518 $SOBE = t3lib_div::makeInstance('SC_mod_user_setup_index');
00519 $SOBE->simulateUser();
00520 $SOBE->storeIncomingData();
00521 
00522 // These includes MUST be afterwards the settings are saved...!
00523 require ($BACK_PATH.'template.php');
00524 $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
00525 
00526 $SOBE->init();
00527 $SOBE->main();
00528 $SOBE->printContent();
00529 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6