"TYPO3 4.0.1: typo3_src-4.0.1/t3lib/class.t3lib_tsfebeuserauth.php Source File", "datetime" => "Sat Dec 2 19:22:19 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

class.t3lib_tsfebeuserauth.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2006 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 ***************************************************************/
00103 class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
00104         var $formfield_uname = '';                      // formfield with login-name
00105         var $formfield_uident = '';             // formfield with password
00106         var $formfield_chalvalue = '';          // formfield with a unique value which is used to encrypt the password and username
00107         var $security_level = '';                               // sets the level of security. *'normal' = clear-text. 'challenged' = hashed password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
00108         var $writeStdLog = 0;                                   // Decides if the writelog() function is called at login and logout
00109         var $writeAttemptLog = 0;                               // If the writelog() functions is called if a login-attempt has be tried without success
00110         var $auth_include = '';                                         // this is the name of the include-file containing the login form. If not set, login CAN be anonymous. If set login IS needed.
00111 
00112         var $extNeedUpdate=0;
00113         var $extPublishList='';
00114         var $extPageInTreeInfo=array();
00115         var $ext_forcePreview=0;
00116         var $langSplitIndex=0;
00117         var $extAdmEnabled = 0; // General flag which is set if the adminpanel should be displayed at all..
00118 
00119 
00120 
00121 
00129         function extInitFeAdmin()       {
00130                 $this->extAdminConfig = $this->getTSConfigProp('admPanel');
00131                 if (is_array($this->extAdminConfig['enable.'])) {
00132                         reset($this->extAdminConfig['enable.']);
00133                         while(list($k,$v)=each($this->extAdminConfig['enable.']))       {
00134                                 if ($v) {
00135                                         $this->extAdmEnabled=1; // Enable panel
00136                                         break;
00137                                 }
00138                         }
00139                 }
00140 
00141                         // Init TSFE_EDIT variables if either the admPanel is enabled or if forceDisplayIcons is set
00142                 if($this->extAdmEnabled || $this->extGetFeAdminValue('edit', 'displayIcons'))   {
00143                         $this->TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
00144                 }
00145         }
00146 
00154         function extPrintFeAdminDialog()        {
00155                 $out='';
00156                 if ($this->uc['TSFE_adminConfig']['display_top'])       {
00157                         if ($this->extAdmModuleEnabled('preview'))      $out.= $this->extGetCategory_preview();
00158                         if ($this->extAdmModuleEnabled('cache'))        $out.= $this->extGetCategory_cache();
00159                         if ($this->extAdmModuleEnabled('publish'))      $out.= $this->extGetCategory_publish();
00160                         if ($this->extAdmModuleEnabled('edit'))         $out.= $this->extGetCategory_edit();
00161                         if ($this->extAdmModuleEnabled('tsdebug'))      $out.= $this->extGetCategory_tsdebug();
00162                         if ($this->extAdmModuleEnabled('info'))         $out.= $this->extGetCategory_info();
00163                 }
00164 
00165                 $header='
00166                         <tr class="typo3-adminPanel-hRow" style="background-color:#9ba1a8;">
00167                                 <td colspan="4" nowrap="nowrap">'.
00168                                         $this->extItemLink('top','<img src="'.TYPO3_mainDir.'gfx/ol/'.($this->uc['TSFE_adminConfig']['display_top']?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" /><strong>'.$this->extFw($this->extGetLL('adminOptions')).'</strong>').
00169                                         $this->extFw(': '.$this->user['username']).'
00170                                         <img src="clear.gif" width="40" height="1" alt="" />
00171                                         <input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="'.$this->uc['TSFE_adminConfig']['display_top'].'" />'.($this->extNeedUpdate?'<input type="submit" value="'.$this->extGetLL('update').'" />':'').'</td>
00172                         </tr>';
00173 
00174                 $query = !t3lib_div::_GET('id') ? ('<input type="hidden" name="id" value="'.$GLOBALS['TSFE']->id.'" />'.chr(10)) : '';
00175                         // the dummy field is needed for Firefox: to force a page reload on submit with must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
00176                 $query.= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="">';
00177                 foreach (t3lib_div::_GET() as $k => $v) {
00178                         if ($k != 'TSFE_ADMIN_PANEL')   {
00179                                 if (is_array($v))       {
00180                                         $query.=$this->extPrintFeAdminDialogHiddenFields($k,$v);
00181                                 } else {
00182                                         $query.='<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'">'.chr(10);
00183                                 }
00184                         }
00185                 }
00186 
00187                 $out='
00188 <!--
00189         ADMIN PANEL
00190 -->
00191 <a name="TSFE_ADMIN"></a>
00192 <form name="TSFE_ADMIN_PANEL_FORM" action="'.htmlspecialchars(t3lib_div::getIndpEnv('SCRIPT_NAME')).'#TSFE_ADMIN" method="get" style="margin:0;" onsubmit="document.forms.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[DUMMY]\'].value=Math.random().toString().substring(2,8)">'.
00193 $query.
00194 '       <table border="0" cellpadding="0" cellspacing="0" class="typo3-adminPanel" style="background-color:#f6f2e6; border: 1px solid black; z-index:0; position:absolute;">'.$header.$out.'
00195         </table>
00196 </form>';
00197 
00198                 if ($this->uc['TSFE_adminConfig']['display_top'])       {
00199                         $out.='<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
00200                         $out.='
00201                         <script type="text/javascript">
00202                                         /*<![CDATA[*/
00203                                 var evalFunc = new evalFunc();
00204                                         // TSFEtypo3FormFieldSet()
00205                                 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)      {       //
00206                                         var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
00207                                         var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
00208                                         if (checkbox && theValue==checkboxValue)        {
00209                                                 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
00210                                                 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
00211                                         } else {
00212                                                 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
00213                                                 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
00214                                         }
00215                                 }
00216                                         // TSFEtypo3FormFieldGet()
00217                                 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)        {       //
00218                                         var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
00219                                         if (checkbox_off)       {
00220                                                 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
00221                                         }else{
00222                                                 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
00223                                         }
00224                                         TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
00225                                 }
00226                                         /*]]>*/
00227                         </script>
00228                         <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
00229                 }
00230                 return "\n\n\n\n".$out.'<br />';
00231         }
00232 
00242         function extPrintFeAdminDialogHiddenFields($key,&$val)  {
00243                 $out='';
00244                 foreach($val as $k => $v)       {
00245                         if (is_array($v))       {
00246                                 $out.=$this->extPrintFeAdminDialogHiddenFields($key.'['.$k.']',$v);
00247                         } else {
00248                                 $out.='<input type="hidden" name="'.$key.'['.$k.']" value="'.htmlspecialchars($v).'">'.chr(10);
00249                         }
00250                 }
00251                 return $out;
00252         }
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 
00269         /*****************************************************
00270          *
00271          * Creating sections of the Admin Panel
00272          *
00273          ****************************************************/
00274 
00282         function extGetCategory_preview($out='')        {
00283                 $out.=$this->extGetHead('preview');
00284                 if ($this->uc['TSFE_adminConfig']['display_preview'])   {
00285                         $this->extNeedUpdate = 1;
00286                         $out.= $this->extGetItem('preview_showHiddenPages', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="1"'.($this->uc['TSFE_adminConfig']['preview_showHiddenPages']?' checked="checked"':'').' />');
00287                         $out.= $this->extGetItem('preview_showHiddenRecords', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="1"'.($this->uc['TSFE_adminConfig']['preview_showHiddenRecords']?' checked="checked"':'').' />');
00288 
00289                                 // Simulate date
00290                         $out.= $this->extGetItem('preview_simulateDate', '<input type="checkbox" name="TSFE_ADMIN_PANEL[preview_simulateDate]_cb" onclick="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\',1,0,1);" /><input type="text" name="TSFE_ADMIN_PANEL[preview_simulateDate]_hr" onchange="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\', 1,0);" /><input type="hidden" name="TSFE_ADMIN_PANEL[preview_simulateDate]" value="'.$this->uc['TSFE_adminConfig']['preview_simulateDate'].'" />');
00291                         $this->extJSCODE.= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
00292 
00293                                 // Simulate fe_user:
00294                         $options = '<option value="0"></option>';
00295                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00296                                                 'fe_groups.uid, fe_groups.title',
00297                                                 'fe_groups,pages',
00298                                                 'pages.uid=fe_groups.pid AND pages.deleted=0 '.t3lib_BEfunc::deleteClause('fe_groups').' AND '.$this->getPagePermsClause(1)
00299                                         );
00300                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00301                                 $options.= '<option value="'.$row['uid'].'"'.($this->uc['TSFE_adminConfig']['preview_simulateUserGroup']==$row['uid']?' selected="selected"':'').'>'.htmlspecialchars('['.$row['uid'].'] '.$row['title']).'</option>';
00302                         }
00303                         $out.= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">'.$options.'</select>');
00304                 }
00305                 return $out;
00306         }
00307 
00315         function extGetCategory_cache($out='')  {
00316                 $out.=$this->extGetHead('cache');
00317                 if ($this->uc['TSFE_adminConfig']['display_cache'])     {
00318                         $this->extNeedUpdate=1;
00319                         $out.=$this->extGetItem('cache_noCache', '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_noCache]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[cache_noCache]" value="1"'.($this->uc['TSFE_adminConfig']['cache_noCache']?' checked="checked"':'').' />');
00320 
00321                         $options='';
00322                         $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
00323                         $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
00324                         $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
00325                         $out.=$this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">'.$options.'</select>'.
00326                                         '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
00327 
00328                                 // Generating tree:
00329                         $depth=$this->extGetFeAdminValue('cache','clearCacheLevels');
00330                         $outTable='';
00331                         $this->extPageInTreeInfo=array();
00332                         $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
00333                         $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
00334                         reset($this->extPageInTreeInfo);
00335                         while(list(,$row)=each($this->extPageInTreeInfo))       {
00336                                 $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="'.TYPO3_mainDir.'gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td><td><img src="clear.gif" width="10" height="1" alt="" /></td><td>'.$this->extFw($this->extGetNumberOfCachedPages($row[0])).'</td></tr>';
00337                         }
00338                         $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
00339                         $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="'.$this->extGetLL('cache_doit').'" />';
00340                         $out.=$this->extGetItem('cache_cacheEntries', $outTable);
00341 
00342                 }
00343                 return $out;
00344         }
00345 
00353         function extGetCategory_publish($out='')        {
00354                 $out.=$this->extGetHead('publish');
00355                 if ($this->uc['TSFE_adminConfig']['display_publish'])   {
00356                         $this->extNeedUpdate=1;
00357                         $options='';
00358                         $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['publish_levels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
00359                         $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['publish_levels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
00360                         $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['publish_levels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
00361                         $out.=$this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">'.$options.'</select>'.
00362                                         '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
00363 
00364                                 // Generating tree:
00365                         $depth=$this->extGetFeAdminValue('publish','levels');
00366                         $outTable='';
00367                         $this->extPageInTreeInfo=array();
00368                         $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
00369                         $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
00370                         reset($this->extPageInTreeInfo);
00371                         while(list(,$row)=each($this->extPageInTreeInfo))       {
00372                                 $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="'.TYPO3_mainDir.'gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td><td><img src="clear.gif" width="10" height="1" alt="" /></td><td>'.$this->extFw('...').'</td></tr>';
00373                         }
00374                         $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
00375                         $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="'.$this->extGetLL('publish_doit').'" />';
00376                         $out.=$this->extGetItem('publish_tree', $outTable);
00377                 }
00378                 return $out;
00379         }
00380 
00388         function extGetCategory_edit($out='')   {
00389                 $out.=$this->extGetHead('edit');
00390                 if ($this->uc['TSFE_adminConfig']['display_edit'])      {
00391 
00392                                 // If another page module was specified, replace the default Page module with the new one
00393                         $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
00394                         $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00395 
00396                         $this->extNeedUpdate=1;
00397                         $out.=$this->extGetItem('edit_displayFieldIcons', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="1"'.($this->uc['TSFE_adminConfig']['edit_displayFieldIcons']?' checked="checked"':'').' />');
00398                         $out.=$this->extGetItem('edit_displayIcons', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="1"'.($this->uc['TSFE_adminConfig']['edit_displayIcons']?' checked="checked"':'').' />');
00399                         $out.=$this->extGetItem('edit_editFormsOnPage', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="1"'.($this->uc['TSFE_adminConfig']['edit_editFormsOnPage']?' checked="checked"':'').' />');
00400                         $out.=$this->extGetItem('edit_editNoPopup', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="1"'.($this->uc['TSFE_adminConfig']['edit_editNoPopup']?' checked="checked"':'').' />');
00401 
00402                         $out.=$this->extGetItem('', $this->ext_makeToolBar());
00403                         if (!t3lib_div::_GP('ADMCMD_view'))     {
00404                                 $out.=$this->extGetItem('', '<a href="#" onclick="'.
00405                                         htmlspecialchars('
00406                                                 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
00407                                                         parent.opener.top.fsMod.recentIds["web"]='.intval($GLOBALS['TSFE']->page['uid']).';
00408                                                         if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav)        {
00409                                                                 parent.opener.top.content.nav_frame.refresh_nav();
00410                                                         }
00411                                                         parent.opener.top.goToModule("'.$pageModule.'");
00412                                                         parent.opener.top.focus();
00413                                                 } else {
00414                                                         vHWin=window.open(\''.TYPO3_mainDir.'alt_main.php\',\''.md5('Typo3Backend-'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
00415                                                         vHWin.focus();
00416                                                 }
00417                                                 return false;
00418                                                 ').
00419                                         '">'.$this->extFw($this->extGetLL('edit_openAB')).'</a>');
00420                         }
00421                 }
00422                 return $out;
00423         }
00424 
00432         function extGetCategory_tsdebug($out='')        {
00433                 $out.=$this->extGetHead('tsdebug');
00434                 if ($this->uc['TSFE_adminConfig']['display_tsdebug'])   {
00435                         $this->extNeedUpdate=1;
00436 
00437                         $content='';
00438                         $content.=$this->extGetItem('tsdebug_tree', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_tree']?' checked="checked"':'').' />');
00439                         $content.=$this->extGetItem('tsdebug_displayTimes', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayTimes']?' checked="checked"':'').' />');
00440                         $content.=$this->extGetItem('tsdebug_displayMessages', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayMessages']?' checked="checked"':'').' />');
00441                         $content.=$this->extGetItem('tsdebug_LR', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_LR']?' checked="checked"':'').' />');
00442                         $content.=$this->extGetItem('tsdebug_displayContent', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayContent']?' checked="checked"':'').' />');
00443                         $content.=$this->extGetItem('tsdebug_displayQueries', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayQueries']?' checked="checked"':'').' />');
00444                         $content.=$this->extGetItem('tsdebug_forceTemplateParsing', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing']?' checked="checked"':'').' />');
00445 
00446                         $out.='<tr><td colspan="4" nowrap="nowrap"><table border="0" cellpadding="0" cellspacing="0">'.$content.'</table></td></tr>';
00447 
00448                         $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug','tree');
00449                         $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug','displayTimes');
00450                         $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug','displayMessages');
00451                         $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug','displayContent');
00452                         $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug','displayQueries');
00453                         $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$GLOBALS['TT']->printTSlog().'</td></tr>';
00454                 }
00455                 return $out;
00456         }
00457 
00465         function extGetCategory_info($out='')   {
00466                 $out.=$this->extGetHead('info');
00467                 if ($this->uc['TSFE_adminConfig']['display_info'])      {
00468 
00469                         if (is_array($GLOBALS['TSFE']->imagesOnPage) && $this->extGetFeAdminValue('cache','noCache'))   {
00470                                 reset($GLOBALS['TSFE']->imagesOnPage);
00471                                 $theBytes=0;
00472                                 $count=0;
00473                                 $fileTable='';
00474                                 while(list(,$file)=each($GLOBALS['TSFE']->imagesOnPage))        {
00475                                         $fs=@filesize($file);
00476                                         $fileTable.='<tr><td>'.$this->extFw($file).'</td><td align="right">'.$this->extFw(t3lib_div::formatSize($fs)).'</td></tr>';
00477                                         $theBytes+=$fs;
00478                                         $count++;
00479                                 }
00480                                 $fileTable.='<tr><td><strong>'.$this->extFw('Total number of images:').'</strong></td><td>'.$this->extFw($count).'</td></tr>';
00481                                 $fileTable.='<tr><td><strong>'.$this->extFw('Total image file sizes:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize($theBytes)).'</td></tr>';
00482                                 $fileTable.='<tr><td><strong>'.$this->extFw('Document size:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content))).'</td></tr>';
00483                                 $fileTable.='<tr><td><strong>'.$this->extFw('Total page load:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes)).'</td></tr>';
00484                                 $fileTable.='<tr><td>&nbsp;</td></tr>';
00485                         }
00486 
00487                         $fileTable.='<tr><td>'.$this->extFw('id:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->id).'</td></tr>';
00488                         $fileTable.='<tr><td>'.$this->extFw('type:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->type).'</td></tr>';
00489                         $fileTable.='<tr><td>'.$this->extFw('gr_list:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->gr_list).'</td></tr>';
00490                         $fileTable.='<tr><td>'.$this->extFw('no_cache:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->no_cache).'</td></tr>';
00491                         $fileTable.='<tr><td>'.$this->extFw('fe_user, name:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['username']).'</td></tr>';
00492                         $fileTable.='<tr><td>'.$this->extFw('fe_user, uid:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['uid']).'</td></tr>';
00493                         $fileTable.='<tr><td>&nbsp;</td></tr>';
00494 
00495                                 // parsetime:
00496                         $fileTable.='<tr><td>'.$this->extFw('Total parsetime:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->scriptParseTime.' ms').'</td></tr>';
00497 
00498                         $fileTable='<table border="0" cellpadding="0" cellspacing="0">'.$fileTable.'</table>';
00499 
00500                         $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$fileTable.'</td></tr>';
00501                 }
00502                 return $out;
00503         }
00504 
00505 
00506 
00507 
00508 
00509 
00510 
00511 
00512 
00513 
00514 
00515 
00516 
00517 
00518 
00519 
00520 
00521 
00522         /*****************************************************
00523          *
00524          * Admin Panel Layout Helper functions
00525          *
00526          ****************************************************/
00527 
00538         function extGetHead($pre)       {
00539                 $out.='<img src="'.TYPO3_mainDir.'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
00540                 $out.='<img src="'.TYPO3_mainDir.'gfx/ol/'.($this->uc['TSFE_adminConfig']['display_'.$pre]?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
00541                 $out.=$this->extFw($this->extGetLL($pre));
00542                 $out=$this->extItemLink($pre,$out);
00543                 return '
00544                                 <tr class="typo3-adminPanel-itemHRow" style="background-color:#abbbb4;">
00545                                         <td colspan="4" nowrap="nowrap" style="border-top:dashed 1px #007a8c;">'.$out.'<input type="hidden" name="TSFE_ADMIN_PANEL[display_'.$pre.']" value="'.$this->uc['TSFE_adminConfig']['display_'.$pre].'" /></td>
00546                                 </tr>';
00547         }
00548 
00558         function extItemLink($pre,$str) {
00559                 return '<a href="#" style="text-decoration:none;" onclick="'.
00560                         htmlspecialchars('document.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[display_'.$pre.']\'].value='.($this->uc['TSFE_adminConfig']['display_'.$pre]?'0':'1').'; document.TSFE_ADMIN_PANEL_FORM.submit(); return false;').
00561                         '">'.$str.'</a>';
00562         }
00563 
00574         function extGetItem($pre,$element)      {
00575                 return '
00576                                         <tr class="typo3-adminPanel-itemRow">
00577                                                 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
00578                                                 <td nowrap="nowrap">'.($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;').'</td>
00579                                                 <td><img src="clear.gif" width="40" height="1" alt="" /></td>
00580                                                 <td>'.$element.'</td>
00581                                         </tr>';
00582 
00583         }
00584 
00591         function extFw($str)    {
00592                 return '<font face="verdana,arial" size="1" color="black">'.$str.'</font>';
00593         }
00594 
00600         function ext_makeToolBar()      {
00601                         //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
00602                 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00603                 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
00604                 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : (TYPO3_mainDir.'sysext/cms/layout/db_new_content_el.php');
00605 
00606 
00607                 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
00608                 $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
00609 
00610                 $toolBar='';
00611                 $id = $GLOBALS['TSFE']->id;
00612                 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'show_rechis.php?element='.rawurlencode('pages:'.$id).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'#latest">'.
00613                                         '<img src="'.TYPO3_mainDir.'gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_recordHistory').'" alt="" /></a>';
00614 
00615                 if ($perms&16 && $langAllowed)  {
00616                         $params = '';
00617                         if ($GLOBALS['TSFE']->sys_language_uid) $params = '&sys_language_uid='.$GLOBALS['TSFE']->sys_language_uid;
00618                         $toolBar.='<a href="'.htmlspecialchars($newContentWizScriptPath.'?id='.$id.$params.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00619                                                 '<img src="'.TYPO3_mainDir.'gfx/new_record.gif" width="16" height="12" hspace="1" border="0" align="top" title="'.$this->extGetLL('edit_newContentElement').'" alt="" /></a>';
00620                 }
00621                 if ($perms&2)   {
00622                         $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'move_el.php?table=pages&uid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00623                                         '<img src="'.TYPO3_mainDir.'gfx/move_page.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_move_page').'" alt="" /></a>';
00624                 }
00625                 if ($perms&8)   {
00626                         $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_new.php?id='.$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00627                                         '<img src="'.TYPO3_mainDir.'gfx/new_page.gif" width="13" height="12" hspace="0" border="0" align="top" title="'.$this->extGetLL('edit_newPage').'" alt="" /></a>';
00628                 }
00629                 if ($perms&2)   {
00630                         $params='&edit[pages]['.$id.']=edit';
00631                         $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00632                                         '<img src="'.TYPO3_mainDir.'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageProperties').'" alt="" /></a>';
00633                 }
00634                 if ($this->check('modules','web_list')) {
00635                         $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00636                                         '<img src="'.TYPO3_mainDir.'gfx/list.gif" width="11" height="11" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_db_list').'" alt="" /></a>';
00637                 }
00638                 return $toolBar;
00639         }
00640 
00641 
00642 
00643 
00644 
00645 
00646 
00647 
00648 
00649 
00650 
00651 
00652 
00653 
00654 
00655 
00656 
00657 
00658 
00659         /*****************************************************
00660          *
00661          * TSFE BE user Access Functions
00662          *
00663          ****************************************************/
00664 
00672         function checkBackendAccessSettingsFromInitPhp()        {
00673                 global $TYPO3_CONF_VARS;
00674 
00675                 // **********************
00676                 // Check Hardcoded lock on BE:
00677                 // **********************
00678                 if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0)    {
00679                         return FALSE;
00680                 }
00681 
00682                 // **********************
00683                 // Check IP
00684                 // **********************
00685                 if (trim($TYPO3_CONF_VARS['BE']['IPmaskList'])) {
00686                         if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['BE']['IPmaskList']))      {
00687                                 return FALSE;
00688                         }
00689                 }
00690 
00691 
00692                 // **********************
00693                 // Check SSL (https)
00694                 // **********************
00695                 if (intval($TYPO3_CONF_VARS['BE']['lockSSL']) && $TYPO3_CONF_VARS['BE']['lockSSL'] != 3)        {
00696                         if (!t3lib_div::getIndpEnv('TYPO3_SSL'))        {
00697                                 return FALSE;
00698                         }
00699                 }
00700 
00701                         // Finally a check from t3lib_beuserauth::backendCheckLogin()
00702                 if (!$TYPO3_CONF_VARS['BE']['adminOnly'] || $this->isAdmin())   {
00703                         return TRUE;
00704                 } else return FALSE;
00705          }
00706 
00707 
00717         function extPageReadAccess($pageRec)    {
00718                 return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec,1);
00719         }
00720 
00728         function extAdmModuleEnabled($key)      {
00729                         // Returns true if the module checked is "preview" and the forcePreview flag is set.
00730                 if ($key=="preview" && $this->ext_forcePreview) return true;
00731                         // If key is not set, only "all" is checked
00732                 if ($this->extAdminConfig['enable.']['all'])    return true;
00733                 if ($this->extAdminConfig['enable.'][$key])     {
00734                         return true;
00735                 }
00736         }
00737 
00744         function extSaveFeAdminConfig() {
00745                 $input = t3lib_div::_GET('TSFE_ADMIN_PANEL');
00746                 if (is_array($input))   {
00747                                 // Setting
00748                         $this->uc['TSFE_adminConfig'] = array_merge(!is_array($this->uc['TSFE_adminConfig'])?array():$this->uc['TSFE_adminConfig'], $input);                    // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
00749                         unset($this->uc['TSFE_adminConfig']['action']);
00750 
00751                                 // Actions:
00752                         if ($input['action']['clearCache'] && $this->extAdmModuleEnabled('cache'))      {
00753                                 $this->extPageInTreeInfo=array();
00754                                 $theStartId = intval($input['cache_clearCacheId']);
00755                                 $GLOBALS['TSFE']->clearPageCacheContent_pidList($this->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache','clearCacheLevels'),0,$this->getPagePermsClause(1)).$theStartId);
00756                         }
00757                         if ($input['action']['publish'] && $this->extAdmModuleEnabled('publish'))       {
00758                                 $theStartId = intval($input['publish_id']);
00759                                 $this->extPublishList = $this->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish','levels'),0,$this->getPagePermsClause(1)).$theStartId;
00760                         }
00761 
00762                                 // Saving
00763                         $this->writeUC();
00764                 }
00765                 $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug','LR');
00766                 if ($this->extGetFeAdminValue('cache','noCache'))       {$GLOBALS['TSFE']->set_no_cache();}
00767         }
00768 
00776         function extGetFeAdminValue($pre,$val='')       {
00777                 if ($this->extAdmModuleEnabled($pre))   {       // Check if module is enabled.
00778                                 // Exceptions where the values can be overridden from backend:
00779                                 // deprecated
00780                         if ($pre.'_'.$val == 'edit_displayIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayIcons'])     {
00781                                 return true;
00782                         }
00783                         if ($pre.'_'.$val == 'edit_displayFieldIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons'])   {
00784                                 return true;
00785                         }
00786 
00787                                 // override all settings with user TSconfig
00788                         if ($this->extAdminConfig['override.'][$pre.'.'][$val] && $val) {
00789                                 return $this->extAdminConfig['override.'][$pre.'.'][$val];
00790                         }
00791                         if ($this->extAdminConfig['override.'][$pre])   {
00792                                 return $this->extAdminConfig['override.'][$pre];
00793                         }
00794 
00795                         $retVal = $val ? $this->uc['TSFE_adminConfig'][$pre.'_'.$val] : 1;
00796 
00797                         if ($pre=='preview' && $this->ext_forcePreview) {
00798                                 if (!$val)      {
00799                                         return true;
00800                                 } else {
00801                                         return $retVal;
00802                                 }
00803                         }
00804 
00805                                 // regular check:
00806                         if ($this->extIsAdmMenuOpen($pre))      {       // See if the menu is expanded!
00807                                 return $retVal;
00808                         }
00809                 }
00810         }
00811 
00818         function extIsAdmMenuOpen($pre) {
00819                 return $this->uc['TSFE_adminConfig']['display_top'] && $this->uc['TSFE_adminConfig']['display_'.$pre];
00820         }
00821 
00822 
00823 
00824 
00825 
00826 
00827 
00828 
00829 
00830 
00831 
00832 
00833 
00834 
00835 
00836 
00837         /*****************************************************
00838          *
00839          * TSFE BE user Access Functions
00840          *
00841          ****************************************************/
00842 
00853         function extGetTreeList($id,$depth,$begin=0,$perms_clause)      {
00854                 $depth=intval($depth);
00855                 $begin=intval($begin);
00856                 $id=intval($id);
00857                 $theList='';
00858 
00859                 if ($id && $depth>0)    {
00860                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00861                                                 'uid,title',
00862                                                 'pages',
00863                                                 'pid='.$id.' AND doktype IN ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].') AND deleted=0 AND '.$perms_clause
00864                                         );
00865                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
00866                                 if ($begin<=0)  {
00867                                         $theList.=$row['uid'].',';
00868                                         $this->extPageInTreeInfo[]=array($row['uid'],$row['title'],$depth);
00869                                 }
00870                                 if ($depth>1)   {
00871                                         $theList.=$this->extGetTreeList($row['uid'], $depth-1,$begin-1,$perms_clause);
00872                                 }
00873                         }
00874                 }
00875                 return $theList;
00876         }
00877 
00884         function extGetNumberOfCachedPages($page_id)    {
00885                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', 'page_id='.intval($page_id));
00886                 list($num) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00887                 return $num;
00888         }
00889 
00890 
00891 
00892 
00893 
00894 
00895 
00896 
00897 
00898 
00899 
00900 
00901 
00902 
00903 
00904 
00905 
00906 
00907 
00908 
00909 
00910         /*****************************************************
00911          *
00912          * Localization handling
00913          *
00914          ****************************************************/
00915 
00923         function extGetLL($key) {
00924                 global $LOCAL_LANG;
00925                 if (!is_array($LOCAL_LANG))     {
00926                         $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
00927                         #include('./'.TYPO3_mainDir.'sysext/lang/locallang_tsfe.php');
00928                         if (!is_array($LOCAL_LANG))             $LOCAL_LANG=array();
00929                 }
00930 
00931                 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key));    // Label string in the default backend output charset.
00932 
00933                         // Convert to utf-8, then to entities:
00934                 if ($GLOBALS['LANG']->charSet!='utf-8') {
00935                         $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
00936                 }
00937                 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
00938 
00939                         // Return the result:
00940                 return $labelStr;
00941         }
00942 
00943 
00944 
00945 
00946 
00947 
00948 
00949 
00950 
00951 
00952 
00953 
00954 
00955         /*****************************************************
00956          *
00957          * Frontend Editing
00958          *
00959          ****************************************************/
00960 
00967         function extIsEditAction()      {
00968                 if (is_array($this->TSFE_EDIT)) {
00969                         if ($this->TSFE_EDIT['cancel']) {
00970                                 unset($this->TSFE_EDIT['cmd']);
00971                         } else {
00972                                 $cmd = (string)$this->TSFE_EDIT['cmd'];
00973                                 if (($cmd!='edit' || (is_array($this->TSFE_EDIT['data']) && ($this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']))) && $cmd!='new')  {
00974                                                 // $cmd can be a command like "hide" or "move". If $cmd is "edit" or "new" it's an indication to show the formfields. But if data is sent with update-flag then $cmd = edit is accepted because edit may be sendt because of .keepGoing flag.
00975                                         return true;
00976                                 }
00977                         }
00978                 }
00979                 return false;
00980         }
00981 
00989         function extIsFormShown()       {
00990                 if (is_array($this->TSFE_EDIT)) {
00991                         $cmd=(string)$this->TSFE_EDIT['cmd'];
00992                         if ($cmd=='edit' || $cmd=='new')        {
00993                                 return true;
00994                         }
00995                 }
00996         }
00997 
01005         function extEditAction()        {
01006                 global $TCA, $TYPO3_CONF_VARS;
01007                         // Commands:
01008                 list($table,$uid) = explode(':',$this->TSFE_EDIT['record']);
01009                 if ($this->TSFE_EDIT['cmd'] && $table && $uid && isset($TCA[$table]))   {
01010                         $tce = t3lib_div::makeInstance('t3lib_TCEmain');
01011                         $tce->stripslashes_values=0;
01012                         $recData=array();
01013                         $cmdData=array();
01014                         $cmd=$this->TSFE_EDIT['cmd'];
01015 
01016                         // ****************
01017                         // extEditAction HOOK
01018                         // ****************
01019                         if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'])) {
01020                                 $_params = array();
01021                                 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'] as $_funcRef) {
01022                                                                 t3lib_div::callUserFunction($_funcRef,$_params,$this);
01023                                 }
01024                         }
01025 
01026                         switch($cmd)    {
01027                                 case 'hide':
01028                                 case 'unhide':
01029                                         $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
01030                                         if ($hideField) {
01031                                                 $recData[$table][$uid][$hideField]=($cmd=='hide'?1:0);
01032                                                 $tce->start($recData,Array());
01033                                                 $tce->process_datamap();
01034                                         }
01035                                 break;
01036                                 case 'up':
01037                                 case 'down':
01038                                         $sortField = $TCA[$table]['ctrl']['sortby'];
01039                                         if ($sortField) {
01040                                                 if ($cmd=='up') {
01041                                                         $op= '<';
01042                                                         $desc=' DESC';
01043                                                 } else {
01044                                                         $op= '>';
01045                                                         $desc='';
01046                                                 }
01047                                                         // Get self:
01048                                                 $fields = array_unique(t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'].',uid,pid,'.$sortField,1));
01049                                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',$fields), $table, 'uid='.$uid);
01050                                                 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01051                                                                 // record before or after
01052                                                         $preview = $this->extGetFeAdminValue('preview');
01053                                                         $copyAfterFieldsQuery = '';
01054                                                         if ($preview)   {$ignore = array('starttime'=>1, 'endtime'=>1, 'disabled'=>1, 'fe_group'=>1);}
01055                                                         if ($TCA[$table]['ctrl']['copyAfterDuplFields'])        {
01056                                                                 $cAFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'],1);
01057                                                                 while(list(,$fN)=each($cAFields))       {
01058                                                                         $copyAfterFieldsQuery.=' AND '.$fN.'="'.$row[$fN].'"';
01059                                                                 }
01060                                                         }
01061 
01062                                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01063                                                                                 'uid,pid',
01064                                                                                 $table,
01065                                                                                 'pid='.intval($row['pid']).
01066                                                                                         ' AND '.$sortField.$op.intval($row[$sortField]).
01067                                                                                         $copyAfterFieldsQuery.
01068                                                                                         $GLOBALS['TSFE']->sys_page->enableFields($table,'',$ignore),
01069                                                                                 '',
01070                                                                                 $sortField.$desc,
01071                                                                                 '2'
01072                                                                         );
01073                                                         if ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))        {
01074                                                                 if($cmd=='down')        {
01075                                                                         $cmdData[$table][$uid]['move']= -$row2['uid'];
01076                                                                 } elseif ($row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {        // Must take the second record above...
01077                                                                         $cmdData[$table][$uid]['move']= -$row3['uid'];
01078                                                                 } else {        // ... and if that does not exist, use pid
01079                                                                         $cmdData[$table][$uid]['move']= $row['pid'];
01080                                                                 }
01081                                                         } elseif ($cmd=='up') {
01082                                                                 $cmdData[$table][$uid]['move']= $row['pid'];
01083                                                         }
01084                                                 }
01085                                                 if (count($cmdData))    {
01086                                                         $tce->start(Array(),$cmdData);
01087                                                         $tce->process_cmdmap();
01088                                                 }
01089                                         }
01090                                 break;
01091                                 case 'delete':
01092                                         $cmdData[$table][$uid]['delete']= 1;
01093                                         if (count($cmdData))    {
01094                                                 $tce->start(Array(),$cmdData);
01095                                                 $tce->process_cmdmap();
01096                                         }
01097                                 break;
01098                         }
01099                 }
01100                         // Data:
01101                 if (($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']) && is_array($this->TSFE_EDIT['data']))       {
01102                         $tce = t3lib_div::makeInstance('t3lib_TCEmain');
01103                         $tce->stripslashes_values=0;
01104                         $tce->start($this->TSFE_EDIT['data'],Array());
01105                         $tce->process_uploads($_FILES);
01106                         $tce->process_datamap();
01107                 }
01108         }
01109 }
01110 
01111 
01112 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php'])    {
01113         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']);
01114 }
01115 ?>