524f9f2c2e8db3890fcaa7f14c45c5e82c34b71e
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsfebeuserauth.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Class for TYPO3 backend user authentication in the TSFE frontend
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 103: class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth
42 * 129: function extInitFeAdmin()
43 * 154: function extPrintFeAdminDialog()
44 *
45 * SECTION: Creating sections of the Admin Panel
46 * 249: function extGetCategory_preview($out='')
47 * 282: function extGetCategory_cache($out='')
48 * 320: function extGetCategory_publish($out='')
49 * 355: function extGetCategory_edit($out='')
50 * 399: function extGetCategory_tsdebug($out='')
51 * 429: function extGetCategory_info($out='')
52 *
53 * SECTION: Admin Panel Layout Helper functions
54 * 502: function extGetHead($pre)
55 * 522: function extItemLink($pre,$str)
56 * 538: function extGetItem($pre,$element)
57 * 555: function extFw($str)
58 * 564: function ext_makeToolBar()
59 *
60 * SECTION: TSFE BE user Access Functions
61 * 622: function checkBackendAccessSettingsFromInitPhp()
62 * 667: function extPageReadAccess($pageRec)
63 * 678: function extAdmModuleEnabled($key)
64 * 694: function extSaveFeAdminConfig()
65 * 726: function extGetFeAdminValue($pre,$val='')
66 * 759: function extIsAdmMenuOpen($pre)
67 *
68 * SECTION: TSFE BE user Access Functions
69 * 794: function extGetTreeList($id,$depth,$begin=0,$perms_clause)
70 * 825: function extGetNumberOfCachedPages($page_id)
71 *
72 * SECTION: Localization handling
73 * 864: function extGetLL($key)
74 *
75 * SECTION: Frontend Editing
76 * 908: function extIsEditAction()
77 * 926: function extIsFormShown()
78 * 942: function extEditAction()
79 *
80 * TOTAL FUNCTIONS: 25
81 * (This index is automatically created/updated by the extension "extdeveval")
82 *
83 */
84
85
86
87
88
89
90
91
92
93
94
95 /**
96 * TYPO3 backend user authentication in the TSFE frontend.
97 * This includes mainly functions related to the Admin Panel
98 *
99 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
100 * @package TYPO3
101 * @subpackage t3lib
102 */
103 class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
104 var $formfield_uname = ''; // formfield with login-name
105 var $formfield_uident = ''; // formfield with password
106 var $formfield_chalvalue = ''; // formfield with a unique value which is used to encrypt the password and username
107 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.
108 var $writeStdLog = 0; // Decides if the writelog() function is called at login and logout
109 var $writeAttemptLog = 0; // If the writelog() functions is called if a login-attempt has be tried without success
110 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.
111
112 var $extNeedUpdate=0;
113 var $extPublishList='';
114 var $extPageInTreeInfo=array();
115 var $ext_forcePreview=0;
116 var $langSplitIndex=0;
117 var $extAdmEnabled = 0; // General flag which is set if the adminpanel should be displayed at all..
118
119
120
121
122 /**
123 * Initialize the usage of Admin Panel.
124 * Called from index_ts.php if a backend users is correctly logged in.
125 * Sets $this->extAdminConfig to the "admPanel" config for the user and $this->extAdmEnabled = 1 IF access is enabled.
126 *
127 * @return void
128 */
129 function extInitFeAdmin() {
130 $this->extAdminConfig = $this->getTSConfigProp('admPanel');
131 if (is_array($this->extAdminConfig['enable.'])) {
132 reset($this->extAdminConfig['enable.']);
133 while(list($k,$v)=each($this->extAdminConfig['enable.'])) {
134 if ($v) {
135 $this->extAdmEnabled=1; // Enable panel
136 break;
137 }
138 }
139 }
140
141 // Init TSFE_EDIT variables if either the admPanel is enabled or if forceDisplayIcons is set
142 if($this->extAdmEnabled || $this->extGetFeAdminValue('edit', 'displayIcons')) {
143 $this->TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
144 }
145 }
146
147 /**
148 * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
149 * Called from index_ts.php - in the end of the script
150 *
151 * @return string HTML for the Admin Panel
152 * @see index_ts.php
153 */
154 function extPrintFeAdminDialog() {
155
156 if ($this->uc['TSFE_adminConfig']['display_top']) {
157 if ($this->extAdmModuleEnabled('preview')) $out.= $this->extGetCategory_preview();
158 if ($this->extAdmModuleEnabled('cache')) $out.= $this->extGetCategory_cache();
159 if ($this->extAdmModuleEnabled('publish')) $out.= $this->extGetCategory_publish();
160 if ($this->extAdmModuleEnabled('edit')) $out.= $this->extGetCategory_edit();
161 if ($this->extAdmModuleEnabled('tsdebug')) $out.= $this->extGetCategory_tsdebug();
162 if ($this->extAdmModuleEnabled('info')) $out.= $this->extGetCategory_info();
163 }
164
165 $header.='
166 <tr class="typo3-adminPanel-hRow" bgcolor="#9BA1A8">
167 <td colspan="4" nowrap="nowrap">'.
168 $this->extItemLink('top','<img src="t3lib/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>').
169 $this->extFw(': '.$this->user['username']).'
170 <img src="clear.gif" width="40" height="1" alt="" />
171 <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>
172 </tr>';
173
174 $out='
175 <!--
176 ADMIN PANEL
177 -->
178 <a name="TSFE_ADMIN"></a>
179 <form name="TSFE_ADMIN_PANEL_FORM" action="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'#TSFE_ADMIN" method="post" style="margin: 0 0 0 0;">
180 <table border="0" cellpadding="0" cellspacing="0" class="typo3-adminPanel" bgcolor="#F6F2E6" style="border: 1px solid black; z-index:0; position:absolute;">'.
181 $header.$out.'
182 </table>
183 </form>';
184
185 if ($this->uc['TSFE_adminConfig']['display_top']) {
186 $out.='<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
187 $out.='
188 <script type="text/javascript">
189 /*<![CDATA[*/
190 var evalFunc = new evalFunc();
191 // TSFEtypo3FormFieldSet()
192 function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) { //
193 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
194 var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
195 if (checkbox && theValue==checkboxValue) {
196 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
197 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
198 } else {
199 document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
200 document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
201 }
202 }
203 // TSFEtypo3FormFieldGet()
204 function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) { //
205 var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
206 if (checkbox_off) {
207 document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
208 }else{
209 document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
210 }
211 TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
212 }
213 /*]]>*/
214 </script>
215 <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
216 }
217 return "\n\n\n\n".$out.'<br />';
218 }
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235 /*****************************************************
236 *
237 * Creating sections of the Admin Panel
238 *
239 ****************************************************/
240
241 /**
242 * Creates the content for the "preview" section ("module") of the Admin Panel
243 *
244 * @param string Optional start-value; The generated content is added to this variable.
245 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
246 * @see extPrintFeAdminDialog()
247 */
248 function extGetCategory_preview($out='') {
249 $out.=$this->extGetHead('preview');
250 if ($this->uc['TSFE_adminConfig']['display_preview']) {
251 $this->extNeedUpdate = 1;
252 $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"':'').' />');
253 $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"':'').' />');
254
255 // Simulate date
256 $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'].'" />');
257 $this->extJSCODE.= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
258
259 // Simulate fe_user:
260 $options = '<option value="0"></option>';
261 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
262 'fe_groups.uid, fe_groups.title',
263 'fe_groups,pages',
264 'pages.uid=fe_groups.pid AND pages.deleted=0 '.t3lib_BEfunc::deleteClause('fe_groups').' AND '.$this->getPagePermsClause(1)
265 );
266 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
267 $options.= '<option value="'.$row['uid'].'"'.($this->uc['TSFE_adminConfig']['preview_simulateUserGroup']==$row['uid']?' selected="selected"':'').'>'.htmlspecialchars('['.$row['uid'].'] '.$row['title']).'</option>';
268 }
269 $out.= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">'.$options.'</select>');
270 }
271 return $out;
272 }
273
274 /**
275 * Creates the content for the "cache" section ("module") of the Admin Panel
276 *
277 * @param string Optional start-value; The generated content is added to this variable.
278 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
279 * @see extPrintFeAdminDialog()
280 */
281 function extGetCategory_cache($out='') {
282 $out.=$this->extGetHead('cache');
283 if ($this->uc['TSFE_adminConfig']['display_cache']) {
284 $this->extNeedUpdate=1;
285 $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"':'').' />');
286
287 $options='';
288 $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
289 $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
290 $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
291 $out.=$this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">'.$options.'</select>'.
292 '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
293
294 // Generating tree:
295 $depth=$this->extGetFeAdminValue('cache','clearCacheLevels');
296 $outTable='';
297 $this->extPageInTreeInfo=array();
298 $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
299 $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
300 reset($this->extPageInTreeInfo);
301 while(list(,$row)=each($this->extPageInTreeInfo)) {
302 $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="t3lib/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>';
303 }
304 $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
305 $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="'.$this->extGetLL('cache_doit').'" />';
306 $out.=$this->extGetItem('cache_cacheEntries', $outTable);
307
308 }
309 return $out;
310 }
311
312 /**
313 * Creates the content for the "publish" section ("module") of the Admin Panel
314 *
315 * @param string Optional start-value; The generated content is added to this variable.
316 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
317 * @see extPrintFeAdminDialog()
318 */
319 function extGetCategory_publish($out='') {
320 $out.=$this->extGetHead('publish');
321 if ($this->uc['TSFE_adminConfig']['display_publish']) {
322 $this->extNeedUpdate=1;
323 $options='';
324 $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['publish_levels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
325 $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['publish_levels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
326 $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['publish_levels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
327 $out.=$this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">'.$options.'</select>'.
328 '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
329
330 // Generating tree:
331 $depth=$this->extGetFeAdminValue('publish','levels');
332 $outTable='';
333 $this->extPageInTreeInfo=array();
334 $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
335 $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
336 reset($this->extPageInTreeInfo);
337 while(list(,$row)=each($this->extPageInTreeInfo)) {
338 $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="t3lib/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>';
339 }
340 $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
341 $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="'.$this->extGetLL('publish_doit').'" />';
342 $out.=$this->extGetItem('publish_tree', $outTable);
343 }
344 return $out;
345 }
346
347 /**
348 * Creates the content for the "edit" section ("module") of the Admin Panel
349 *
350 * @param string Optional start-value; The generated content is added to this variable.
351 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
352 * @see extPrintFeAdminDialog()
353 */
354 function extGetCategory_edit($out='') {
355 $out.=$this->extGetHead('edit');
356 if ($this->uc['TSFE_adminConfig']['display_edit']) {
357
358 // If another page module was specified, replace the default Page module with the new one
359 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
360 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
361
362 $this->extNeedUpdate=1;
363 $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"':'').' />');
364 $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"':'').' />');
365 $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"':'').' />');
366 $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"':'').' />');
367
368 $out.=$this->extGetItem('', $this->ext_makeToolBar());
369 if (!t3lib_div::_GP('ADMCMD_view')) {
370 $out.=$this->extGetItem('', '<a href="#" onclick="'.
371 htmlspecialchars('
372 if (parent.opener && parent.opener.top && parent.opener.top.TS) {
373 parent.opener.top.fsMod.recentIds["web"]='.intval($GLOBALS['TSFE']->page['uid']).';
374 if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
375 parent.opener.top.content.nav_frame.refresh_nav();
376 }
377 parent.opener.top.goToModule("'.$pageModule.'");
378 parent.opener.top.focus();
379 } else {
380 vHWin=window.open(\''.TYPO3_mainDir.'alt_main.php\',\''.md5('Typo3Backend-'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
381 vHWin.focus();
382 }
383 return false;
384 ').
385 '">'.$this->extFw($this->extGetLL('edit_openAB')).'</a>');
386 }
387 }
388 return $out;
389 }
390
391 /**
392 * Creates the content for the "tsdebug" section ("module") of the Admin Panel
393 *
394 * @param string Optional start-value; The generated content is added to this variable.
395 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
396 * @see extPrintFeAdminDialog()
397 */
398 function extGetCategory_tsdebug($out='') {
399 $out.=$this->extGetHead('tsdebug');
400 if ($this->uc['TSFE_adminConfig']['display_tsdebug']) {
401 $this->extNeedUpdate=1;
402
403 $content='';
404 $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"':'').' />');
405 $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"':'').' />');
406 $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"':'').' />');
407 $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"':'').' />');
408 $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"':'').' />');
409 $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"':'').' />');
410 $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"':'').' />');
411
412 $out.='<tr><td colspan="4" nowrap="nowrap"><table border="0" cellpadding="0" cellspacing="0">'.$content.'</table></td></tr>';
413
414 $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug','tree');
415 $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug','displayTimes');
416 $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug','displayMessages');
417 $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug','displayContent');
418 $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug','displayQueries');
419 $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$GLOBALS['TT']->printTSlog().'</td></tr>';
420 }
421 return $out;
422 }
423
424 /**
425 * Creates the content for the "info" section ("module") of the Admin Panel
426 *
427 * @param string Optional start-value; The generated content is added to this variable.
428 * @return string HTML content for the section. Consists of a string with table-rows with four columns.
429 * @see extPrintFeAdminDialog()
430 */
431 function extGetCategory_info($out='') {
432 $out.=$this->extGetHead('info');
433 if ($this->uc['TSFE_adminConfig']['display_info']) {
434
435 if (is_array($GLOBALS['TSFE']->imagesOnPage) && $this->extGetFeAdminValue('cache','noCache')) {
436 reset($GLOBALS['TSFE']->imagesOnPage);
437 $theBytes=0;
438 $count=0;
439 $fileTable='';
440 while(list(,$file)=each($GLOBALS['TSFE']->imagesOnPage)) {
441 $fs=@filesize($file);
442 $fileTable.='<tr><td>'.$this->extFw($file).'</td><td align="right">'.$this->extFw(t3lib_div::formatSize($fs)).'</td></tr>';
443 $theBytes+=$fs;
444 $count++;
445 }
446 $fileTable.='<tr><td><strong>'.$this->extFw('Total number of images:').'</strong></td><td>'.$this->extFw($count).'</td></tr>';
447 $fileTable.='<tr><td><strong>'.$this->extFw('Total image file sizes:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize($theBytes)).'</td></tr>';
448 $fileTable.='<tr><td><strong>'.$this->extFw('Document size:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content))).'</td></tr>';
449 $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>';
450 $fileTable.='<tr><td>&nbsp;</td></tr>';
451 }
452
453 $fileTable.='<tr><td>'.$this->extFw('id:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->id).'</td></tr>';
454 $fileTable.='<tr><td>'.$this->extFw('type:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->type).'</td></tr>';
455 $fileTable.='<tr><td>'.$this->extFw('gr_list:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->gr_list).'</td></tr>';
456 $fileTable.='<tr><td>'.$this->extFw('no_cache:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->no_cache).'</td></tr>';
457 $fileTable.='<tr><td>'.$this->extFw('fe_user, name:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['username']).'</td></tr>';
458 $fileTable.='<tr><td>'.$this->extFw('fe_user, uid:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['uid']).'</td></tr>';
459 $fileTable.='<tr><td>&nbsp;</td></tr>';
460
461 // parsetime:
462 $fileTable.='<tr><td>'.$this->extFw('Total parsetime:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->scriptParseTime.' ms').'</td></tr>';
463
464 $fileTable='<table border="0" cellpadding="0" cellspacing="0">'.$fileTable.'</table>';
465
466 $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$fileTable.'</td></tr>';
467 }
468 return $out;
469 }
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488 /*****************************************************
489 *
490 * Admin Panel Layout Helper functions
491 *
492 ****************************************************/
493
494 /**
495 * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
496 * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_'.$pre.'] value
497 * See the functions extGetCategory_*
498 *
499 * @param string The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
500 * @return string HTML table row.
501 * @access private
502 * @see extGetItem()
503 */
504 function extGetHead($pre) {
505 $out.='<img src="t3lib/gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
506 $out.='<img src="t3lib/gfx/ol/'.($this->uc['TSFE_adminConfig']['display_'.$pre]?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
507 $out.=$this->extFw($this->extGetLL($pre));
508 $out=$this->extItemLink($pre,$out);
509 return '
510 <tr class="typo3-adminPanel-itemHRow" bgcolor="#ABBBB4">
511 <td colspan="4" nowrap="nowrap">'.$out.'<input type="hidden" name="TSFE_ADMIN_PANEL[display_'.$pre.']" value="'.$this->uc['TSFE_adminConfig']['display_'.$pre].'" /></td>
512 </tr>';
513 }
514
515 /**
516 * Wraps a string in a link which will open/close a certain part of the Admin Panel
517 *
518 * @param string The code for the display_ label/key
519 * @param string Input string
520 * @return string Linked input string
521 * @access private
522 * @see extGetHead()
523 */
524 function extItemLink($pre,$str) {
525 return '<a href="#" onclick="'.
526 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;').
527 '">'.$str.'</a>';
528 }
529
530 /**
531 * Returns a row (with 4 columns) for content in a section of the Admin Panel.
532 * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
533 *
534 * @param string Key to label
535 * @param string The HTML content for the forth table cell.
536 * @return string HTML table row.
537 * @access private
538 * @see extGetHead()
539 */
540 function extGetItem($pre,$element) {
541 return '
542 <tr class="typo3-adminPanel-itemRow">
543 <td><img src="clear.gif" width="50" height="1" alt="" /></td>
544 <td nowrap="nowrap">'.($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;').'</td>
545 <td><img src="clear.gif" width="40" height="1" alt="" /></td>
546 <td>'.$element.'</td>
547 </tr>';
548
549 }
550
551 /**
552 * Wraps a string in a font-tag with verdana, size 1 and black
553 *
554 * @param string The string to wrap
555 * @return string
556 */
557 function extFw($str) {
558 return '<font face="verdana,arial" size="1" color="black">'.$str.'</font>';
559 }
560
561 /**
562 * Creates the tool bar links for the "edit" section of the Admin Panel.
563 *
564 * @return string A string containing images wrapped in <a>-tags linking them to proper functions.
565 */
566 function ext_makeToolBar() {
567 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
568 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
569 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
570 $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');
571
572
573 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
574
575 $toolBar='';
576 $id = $GLOBALS['TSFE']->id;
577 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'show_rechis.php?element='.rawurlencode('pages:'.$id).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'#latest">'.
578 '<img src="t3lib/gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_recordHistory').'" alt="" /></a>';
579
580 if ($perms&16) {
581 $toolBar.='<a href="'.htmlspecialchars($newContentWizScriptPath.'?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
582 '<img src="t3lib/gfx/new_record.gif" width="16" height="12" hspace="1" border="0" align="top" title="'.$this->extGetLL('edit_newContentElement').'" alt="" /></a>';
583 }
584 if ($perms&2) {
585 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'move_el.php?table=pages&uid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
586 '<img src="t3lib/gfx/move_page.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_move_page').'" alt="" /></a>';
587 }
588 if ($perms&8) {
589 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_new.php?id='.$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
590 '<img src="t3lib/gfx/new_page.gif" width="13" height="12" hspace="0" border="0" align="top" title="'.$this->extGetLL('edit_newPage').'" alt="" /></a>';
591 }
592 if ($perms&2) {
593 $params='&edit[pages]['.$id.']=edit';
594 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
595 '<img src="t3lib/gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageProperties').'" alt="" /></a>';
596 }
597 if ($this->check('modules','web_list')) {
598 $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
599 '<img src="t3lib/gfx/list.gif" width="11" height="11" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_db_list').'" alt="" /></a>';
600 }
601 return $toolBar;
602 }
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622 /*****************************************************
623 *
624 * TSFE BE user Access Functions
625 *
626 ****************************************************/
627
628 /**
629 * Implementing the access checks that the typo3/init.php script does before a user is ever logged in.
630 * Used in the frontend.
631 *
632 * @return boolean Returns true if access is OK
633 * @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
634 */
635 function checkBackendAccessSettingsFromInitPhp() {
636 global $TYPO3_CONF_VARS;
637
638 // **********************
639 // Check Hardcoded lock on BE:
640 // **********************
641 if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0) {
642 return FALSE;
643 }
644
645 // **********************
646 // Check IP
647 // **********************
648 if (trim($TYPO3_CONF_VARS['BE']['IPmaskList'])) {
649 if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['BE']['IPmaskList'])) {
650 return FALSE;
651 }
652 }
653
654
655 // **********************
656 // Check SSL (https)
657 // **********************
658 if (intval($TYPO3_CONF_VARS['BE']['lockSSL']) && $TYPO3_CONF_VARS['BE']['lockSSL'] != 3) {
659 if (!t3lib_div::getIndpEnv('TYPO3_SSL')) {
660 return FALSE;
661 }
662 }
663
664 // Finally a check from t3lib_beuserauth::backendCheckLogin()
665 if (!$TYPO3_CONF_VARS['BE']['adminOnly'] || $this->isAdmin()) {
666 return TRUE;
667 } else return FALSE;
668 }
669
670
671 /**
672 * Evaluates if the Backend User has read access to the input page record.
673 * The evaluation is based on both read-permission and whether the page is found in one of the users webmounts. Only if both conditions are true will the function return true.
674 * Read access means that previewing is allowed etc.
675 * Used in index_ts.php
676 *
677 * @param array The page record to evaluate for
678 * @return boolean True if read access
679 */
680 function extPageReadAccess($pageRec) {
681 return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec,1);
682 }
683
684 /**
685 * Checks if a Admin Panel section ("module") is available for the user. If so, true is returned.
686 *
687 * @param string The module key, eg. "edit", "preview", "info" etc.
688 * @return boolean
689 * @see extPrintFeAdminDialog()
690 */
691 function extAdmModuleEnabled($key) {
692 // Returns true if the module checked is "preview" and the forcePreview flag is set.
693 if ($key=="preview" && $this->ext_forcePreview) return true;
694 // If key is not set, only "all" is checked
695 if ($this->extAdminConfig['enable.']['all']) return true;
696 if ($this->extAdminConfig['enable.'][$key]) {
697 return true;
698 }
699 }
700
701 /**
702 * Saves any change in settings made in the Admin Panel.
703 * Called from index_ts.php right after access check for the Admin Panel
704 *
705 * @return void
706 */
707 function extSaveFeAdminConfig() {
708 $input = t3lib_div::_POST('TSFE_ADMIN_PANEL');
709 if (is_array($input)) {
710 // Setting
711 $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...
712 unset($this->uc['TSFE_adminConfig']['action']);
713
714 // Actions:
715 if ($input['action']['clearCache'] && $this->extAdmModuleEnabled('cache')) {
716 $this->extPageInTreeInfo=array();
717 $theStartId = intval($input['cache_clearCacheId']);
718 $GLOBALS['TSFE']->clearPageCacheContent_pidList($this->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache','clearCacheLevels'),0,$this->getPagePermsClause(1)).$theStartId);
719 }
720 if ($input['action']['publish'] && $this->extAdmModuleEnabled('publish')) {
721 $theStartId = intval($input['publish_id']);
722 $this->extPublishList = $this->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish','levels'),0,$this->getPagePermsClause(1)).$theStartId;
723 }
724
725 // Saving
726 $this->writeUC();
727 }
728 $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug','LR');
729 if ($this->extGetFeAdminValue('cache','noCache')) {$GLOBALS['TSFE']->set_no_cache();}
730 }
731
732 /**
733 * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
734 *
735 * @param string Module key
736 * @param string Setting key
737 * @return string The setting value
738 */
739 function extGetFeAdminValue($pre,$val='') {
740 if ($this->extAdmModuleEnabled($pre)) { // Check if module is enabled.
741 // Exceptions where the values can be overridden from backend:
742 if ($pre.'_'.$val == 'edit_displayIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayIcons']) {
743 return true;
744 }
745 if ($pre.'_'.$val == 'edit_displayFieldIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons']) {
746 return true;
747 }
748
749 // override all settings with user TSconfig
750 if ($this->extAdminConfig['module.'][$pre.'.'][$val] && $val) {
751 return $this->extAdminConfig['module.'][$pre.'.'][$val];
752 }
753 if ($this->extAdminConfig['module.'][$pre]) {
754 return $this->extAdminConfig['module.'][$pre];
755 }
756
757 $retVal = $val ? $this->uc['TSFE_adminConfig'][$pre.'_'.$val] : 1;
758
759 if ($pre=='preview' && $this->ext_forcePreview) {
760 if (!$val) {
761 return true;
762 } else {
763 return $retVal;
764 }
765 }
766
767 // regular check:
768 if ($this->extIsAdmMenuOpen($pre)) { // See if the menu is expanded!
769 return $retVal;
770 }
771 }
772 }
773
774 /**
775 * Returns true if admin panel module is open
776 *
777 * @param string Module key
778 * @return boolean True, if the admin panel is open for the specified admin panel module key.
779 */
780 function extIsAdmMenuOpen($pre) {
781 return $this->uc['TSFE_adminConfig']['display_top'] && $this->uc['TSFE_adminConfig']['display_'.$pre];
782 }
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799 /*****************************************************
800 *
801 * TSFE BE user Access Functions
802 *
803 ****************************************************/
804
805 /**
806 * Generates a list of Page-uid's from $id. List does not include $id itself
807 * The only pages excluded from the list are deleted pages.
808 *
809 * @param integer Start page id
810 * @param integer Depth to traverse down the page tree.
811 * @param integer $begin is an optional integer that determines at which level in the tree to start collecting uid's. Zero means 'start right away', 1 = 'next level and out'
812 * @param string Perms clause
813 * @return string Returns the list with a comma in the end (if any pages selected!)
814 */
815 function extGetTreeList($id,$depth,$begin=0,$perms_clause) {
816 $depth=intval($depth);
817 $begin=intval($begin);
818 $id=intval($id);
819 $theList='';
820
821 if ($id && $depth>0) {
822 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
823 'uid,title',
824 'pages',
825 'pid='.$id.' AND doktype IN ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].') AND deleted=0 AND '.$perms_clause
826 );
827 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
828 if ($begin<=0) {
829 $theList.=$row['uid'].',';
830 $this->extPageInTreeInfo[]=array($row['uid'],$row['title'],$depth);
831 }
832 if ($depth>1) {
833 $theList.=$this->extGetTreeList($row['uid'], $depth-1,$begin-1,$perms_clause);
834 }
835 }
836 }
837 return $theList;
838 }
839
840 /**
841 * Returns the number of cached pages for a page id.
842 *
843 * @param integer The page id.
844 * @return integer The number of pages for this page in the table "cache_pages"
845 */
846 function extGetNumberOfCachedPages($page_id) {
847 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', 'page_id='.intval($page_id));
848 list($num) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
849 return $num;
850 }
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872 /*****************************************************
873 *
874 * Localization handling
875 *
876 ****************************************************/
877
878 /**
879 * Returns the label for key, $key. If a translation for the language set in $this->uc['lang'] is found that is returned, otherwise the default value.
880 * IF the global variable $LOCAL_LANG is NOT an array (yet) then this function loads the global $LOCAL_LANG array with the content of "sysext/lang/locallang_tsfe.php" so that the values therein can be used for labels in the Admin Panel
881 *
882 * @param string Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
883 * @return string The value for the $key
884 */
885 function extGetLL($key) {
886 global $LOCAL_LANG;
887 if (!is_array($LOCAL_LANG)) {
888 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
889 #include('./'.TYPO3_mainDir.'sysext/lang/locallang_tsfe.php');
890 if (!is_array($LOCAL_LANG)) $LOCAL_LANG=array();
891 }
892
893 $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key)); // Label string in the default backend output charset.
894
895 // Convert to utf-8, then to entities:
896 if ($GLOBALS['LANG']->charSet!='utf-8') {
897 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
898 }
899 $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
900
901 // Return the result:
902 return $labelStr;
903 }
904
905
906
907
908
909
910
911
912
913
914
915
916
917 /*****************************************************
918 *
919 * Frontend Editing
920 *
921 ****************************************************/
922
923 /**
924 * Returns true in an edit-action is sent from the Admin Panel
925 *
926 * @return boolean
927 * @see index_ts.php
928 */
929 function extIsEditAction() {
930 if (is_array($this->TSFE_EDIT)) {
931 if ($this->TSFE_EDIT['cancel']) {
932 unset($this->TSFE_EDIT['cmd']);
933 } elseif (($cmd!='edit' || (is_array($this->TSFE_EDIT['data']) && ($this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']))) && $cmd!='new') {
934 // $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.
935 return true;
936 }
937 }
938 }
939
940 /**
941 * Returns true if an edit form is shown on the page.
942 * Used from index_ts.php where a true return-value will result in classes etc. being included.
943 *
944 * @return boolean
945 * @see index_ts.php
946 */
947 function extIsFormShown() {
948 if (is_array($this->TSFE_EDIT)) {
949 $cmd=(string)$this->TSFE_EDIT['cmd'];
950 if ($cmd=='edit' || $cmd=='new') {
951 return true;
952 }
953 }
954 }
955
956 /**
957 * Management of the on-page frontend editing forms and edit panels.
958 * Basically taking in the data and commands and passes them on to the proper classes as they should be.
959 *
960 * @return void
961 * @see index_ts.php
962 */
963 function extEditAction() {
964 global $TCA, $TYPO3_CONF_VARS;
965 // Commands:
966 list($table,$uid) = explode(':',$this->TSFE_EDIT['record']);
967 if ($this->TSFE_EDIT['cmd'] && $table && $uid && isset($TCA[$table])) {
968 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
969 $tce->stripslashes_values=0;
970 $recData=array();
971 $cmdData=array();
972 $cmd=$this->TSFE_EDIT['cmd'];
973
974 // ****************
975 // extEditAction HOOK
976 // ****************
977 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'])) {
978 $_params = array();
979 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'] as $_funcRef) {
980 t3lib_div::callUserFunction($_funcRef,$_params,$this);
981 }
982 }
983
984 switch($cmd) {
985 case 'hide':
986 case 'unhide':
987 $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
988 if ($hideField) {
989 $recData[$table][$uid][$hideField]=($cmd=='hide'?1:0);
990 $tce->start($recData,Array());
991 $tce->process_datamap();
992 }
993 break;
994 case 'up':
995 case 'down':
996 $sortField = $TCA[$table]['ctrl']['sortby'];
997 if ($sortField) {
998 if ($cmd=='up') {
999 $op= '<';
1000 $desc=' DESC';
1001 } else {
1002 $op= '>';
1003 $desc='';
1004 }
1005 // Get self:
1006 $fields = array_unique(t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'].',uid,pid,'.$sortField,1));
1007 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',$fields), $table, 'uid='.$uid);
1008 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1009 // record before or after
1010 $preview = $this->extGetFeAdminValue('preview');
1011 $copyAfterFieldsQuery = '';
1012 if ($preview) {$ignore = array('starttime'=>1, 'endtime'=>1, 'disabled'=>1, 'fe_group'=>1);}
1013 if ($TCA[$table]['ctrl']['copyAfterDuplFields']) {
1014 $cAFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'],1);
1015 while(list(,$fN)=each($cAFields)) {
1016 $copyAfterFieldsQuery.=' AND '.$fN.'="'.$row[$fN].'"';
1017 }
1018 }
1019
1020 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1021 'uid,pid',
1022 $table,
1023 'pid='.intval($row['pid']).
1024 ' AND '.$sortField.$op.intval($row[$sortField]).
1025 $copyAfterFieldsQuery.
1026 t3lib_pageSelect::enableFields($table,'',$ignore),
1027 '',
1028 $sortField.$desc,
1029 '2'
1030 );
1031 if ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1032 if($cmd=='down') {
1033 $cmdData[$table][$uid]['move']= -$row2['uid'];
1034 } elseif ($row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Must take the second record above...
1035 $cmdData[$table][$uid]['move']= -$row3['uid'];
1036 } else { // ... and if that does not exist, use pid
1037 $cmdData[$table][$uid]['move']= $row['pid'];
1038 }
1039 } elseif ($cmd=='up') {
1040 $cmdData[$table][$uid]['move']= $row['pid'];
1041 }
1042 }
1043 if (count($cmdData)) {
1044 $tce->start(Array(),$cmdData);
1045 $tce->process_cmdmap();
1046 }
1047 }
1048 break;
1049 case 'delete':
1050 $cmdData[$table][$uid]['delete']= 1;
1051 if (count($cmdData)) {
1052 $tce->start(Array(),$cmdData);
1053 $tce->process_cmdmap();
1054 }
1055 break;
1056 }
1057 }
1058 // Data:
1059 if (($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']) && is_array($this->TSFE_EDIT['data'])) {
1060 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1061 $tce->stripslashes_values=0;
1062 $tce->start($this->TSFE_EDIT['data'],Array());
1063 $tce->process_uploads($_FILES);
1064 $tce->process_datamap();
1065 }
1066 }
1067 }
1068
1069
1070 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']) {
1071 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']);
1072 }
1073 ?>