Best of today...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_userauthgroup.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 * Contains an extension class specifically for authentication/initialization of backend users in TYPO3
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 134: class t3lib_userAuthGroup extends t3lib_userAuth
41 *
42 * SECTION: Permission checking functions:
43 * 198: function isAdmin()
44 * 210: function isMemberOfGroup($groupId)
45 * 232: function doesUserHaveAccess($row,$perms)
46 * 249: function isInWebMount($id,$readPerms='',$exitOnError=0)
47 * 276: function modAccess($conf,$exitOnError)
48 * 327: function getPagePermsClause($perms)
49 * 366: function calcPerms($row)
50 * 404: function isRTE()
51 * 438: function check($type,$value)
52 * 455: function checkAuthMode($table,$field,$value,$authMode)
53 * 521: function checkLanguageAccess($langValue)
54 * 542: function recordEditAccessInternals($table,$idOrRow)
55 * 607: function isPSet($lCP,$table,$type='')
56 * 624: function mayMakeShortcut()
57 * 638: function workspaceCannotEditRecord($table,$recData)
58 * 676: function workspaceCannotEditOfflineVersion($table,$recData)
59 * 699: function workspaceAllowLiveRecordsInPID($pid, $table)
60 * 720: function workspaceCreateNewRecord($pid, $table)
61 * 739: function workspaceAllowAutoCreation($table,$id,$recpid)
62 * 759: function workspaceCheckStageForCurrent($stage)
63 * 782: function workspacePublishAccess($wsid)
64 * 806: function workspaceSwapAccess()
65 * 818: function workspaceVersioningTypeAccess($type)
66 * 845: function workspaceVersioningTypeGetClosest($type)
67 *
68 * SECTION: Miscellaneous functions
69 * 886: function getTSConfig($objectString,$config='')
70 * 912: function getTSConfigVal($objectString)
71 * 924: function getTSConfigProp($objectString)
72 * 936: function inList($in_list,$item)
73 * 947: function returnWebmounts()
74 * 957: function returnFilemounts()
75 *
76 * SECTION: Authentication methods
77 * 988: function fetchGroupData()
78 * 1121: function fetchGroups($grList,$idList='')
79 * 1208: function setCachedList($cList)
80 * 1228: function addFileMount($title, $altTitle, $path, $webspace, $type)
81 * 1275: function addTScomment($str)
82 *
83 * SECTION: Workspaces
84 * 1311: function workspaceInit()
85 * 1354: function checkWorkspace($wsRec,$fields='uid,title,adminusers,members,reviewers,publish_access,stagechg_notification')
86 * 1428: function checkWorkspaceCurrent()
87 * 1441: function setWorkspace($workspaceId)
88 * 1469: function setWorkspacePreview($previewState)
89 * 1479: function getDefaultWorkspace()
90 *
91 * SECTION: Logging
92 * 1530: function writelog($type,$action,$error,$details_nr,$details,$data,$tablename='',$recuid='',$recpid='',$event_pid=-1,$NEWid='',$userId=0)
93 * 1562: function simplelog($message, $extKey='', $error=0)
94 * 1583: function checkLogFailures($email, $secondsBack=3600, $max=3)
95 *
96 * TOTAL FUNCTIONS: 44
97 * (This index is automatically created/updated by the extension "extdeveval")
98 *
99 */
100
101 // Need this for parsing User TSconfig
102 require_once (PATH_t3lib.'class.t3lib_tsparser.php');
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 /**
125 * Extension to class.t3lib_userauth.php; Authentication of users in TYPO3 Backend
126 *
127 * Actually this class is extended again by t3lib_beuserauth which is the actual backend user class that will be instantiated.
128 * In fact the two classes t3lib_beuserauth and this class could just as well be one, single class since t3lib_userauthgroup is not - to my knowledge - used separately elsewhere. But for historical reasons they are two separate classes.
129 *
130 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
131 * @package TYPO3
132 * @subpackage t3lib
133 */
134 class t3lib_userAuthGroup extends t3lib_userAuth {
135 var $usergroup_column = 'usergroup'; // Should be set to the usergroup-column (id-list) in the user-record
136 var $usergroup_table = 'be_groups'; // The name of the group-table
137
138 // internal
139 var $groupData = Array( // This array holds lists of eg. tables, fields and other values related to the permission-system. See fetchGroupData
140 'filemounts' => Array() // Filemounts are loaded here
141 );
142 var $workspace = -99; // User workspace. -99 is ERROR (none available), -1 is offline, 0 is online, >0 is custom workspaces.
143 var $workspaceRec = array(); // Custom workspace record if any
144
145 var $userGroups = Array(); // This array will hold the groups that the user is a member of
146 var $userGroupsUID = Array(); // This array holds the uid's of the groups in the listed order
147 var $groupList =''; // This is $this->userGroupsUID imploded to a comma list... Will correspond to the 'usergroup_cached_list'
148 var $dataLists=array( // Used internally to accumulate data for the user-group. DONT USE THIS EXTERNALLY! Use $this->groupData instead
149 'webmount_list'=>'',
150 'filemount_list'=>'',
151 'modList'=>'',
152 'tables_select'=>'',
153 'tables_modify'=>'',
154 'pagetypes_select'=>'',
155 'non_exclude_fields'=>'',
156 'explicit_allowdeny'=>'',
157 'allowed_languages' => '',
158 'workspace_perms' => '',
159 'custom_options' => '',
160 );
161 var $includeHierarchy=array(); // For debugging/display of order in which subgroups are included.
162 var $includeGroupArray=array(); // List of group_id's in the order they are processed.
163
164 var $OS=''; // Set to 'WIN', if windows
165 var $TSdataArray=array(); // Used to accumulate the TSconfig data of the user
166 var $userTS_text = ''; // Contains the non-parsed user TSconfig
167 var $userTS = array(); // Contains the parsed user TSconfig
168 var $userTSUpdated=0; // Set internally if the user TSconfig was parsed and needs to be cached.
169 var $userTS_dontGetCached=0; // Set this from outside if you want the user TSconfig to ALWAYS be parsed and not fetched from cache.
170
171 var $RTE_errors = array(); // RTE availability errors collected.
172 var $errorMsg = ''; // Contains last error message
173
174 var $checkWorkspaceCurrent_cache=NULL; // Cache for checkWorkspaceCurrent()
175
176
177
178
179
180
181
182
183
184
185
186 /************************************
187 *
188 * Permission checking functions:
189 *
190 ************************************/
191
192 /**
193 * Returns true if user is admin
194 * Basically this function evaluates if the ->user[admin] field has bit 0 set. If so, user is admin.
195 *
196 * @return boolean
197 */
198 function isAdmin() {
199 return (($this->user['admin']&1) ==1);
200 }
201
202 /**
203 * Returns true if the current user is a member of group $groupId
204 * $groupId must be set. $this->groupList must contain groups
205 * Will return true also if the user is a member of a group through subgroups.
206 *
207 * @param integer Group ID to look for in $this->groupList
208 * @return boolean
209 */
210 function isMemberOfGroup($groupId) {
211 $groupId = intval($groupId);
212 if ($this->groupList && $groupId) {
213 return $this->inList($this->groupList, $groupId);
214 }
215 }
216
217 /**
218 * Checks if the permissions is granted based on a page-record ($row) and $perms (binary and'ed)
219 *
220 * Bits for permissions, see $perms variable:
221 *
222 * 1 - Show: See/Copy page and the pagecontent.
223 * 16- Edit pagecontent: Change/Add/Delete/Move pagecontent.
224 * 2- Edit page: Change/Move the page, eg. change title, startdate, hidden.
225 * 4- Delete page: Delete the page and pagecontent.
226 * 8- New pages: Create new pages under the page.
227 *
228 * @param array $row is the pagerow for which the permissions is checked
229 * @param integer $perms is the binary representation of the permission we are going to check. Every bit in this number represents a permission that must be set. See function explanation.
230 * @return boolean True or False upon evaluation
231 */
232 function doesUserHaveAccess($row,$perms) {
233 $userPerms = $this->calcPerms($row);
234 return ($userPerms & $perms)==$perms;
235 }
236
237 /**
238 * Checks if the page id, $id, is found within the webmounts set up for the user.
239 * This should ALWAYS be checked for any page id a user works with, whether it's about reading, writing or whatever.
240 * The point is that this will add the security that a user can NEVER touch parts outside his mounted pages in the page tree. This is otherwise possible if the raw page permissions allows for it. So this security check just makes it easier to make safe user configurations.
241 * If the user is admin OR if this feature is disabled (fx. by setting TYPO3_CONF_VARS['BE']['lockBeUserToDBmounts']=0) then it returns "1" right away
242 * Otherwise the function will return the uid of the webmount which was first found in the rootline of the input page $id
243 *
244 * @param integer Page ID to check
245 * @param string Content of "->getPagePermsClause(1)" (read-permissions). If not set, they will be internally calculated (but if you have the correct value right away you can save that database lookup!)
246 * @param boolean If set, then the function will exit with an error message.
247 * @return integer The page UID of a page in the rootline that matched a mount point
248 */
249 function isInWebMount($id,$readPerms='',$exitOnError=0) {
250 if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'] || $this->isAdmin()) return 1;
251 $id = intval($id);
252 if (!$readPerms) $readPerms = $this->getPagePermsClause(1);
253 if ($id>0) {
254 $wM = $this->returnWebmounts();
255 $rL = t3lib_BEfunc::BEgetRootLine($id,' AND '.$readPerms);
256
257 foreach($rL as $v) {
258 if ($v['uid'] && in_array($v['uid'],$wM)) {
259 return $v['uid'];
260 }
261 }
262 }
263 if ($exitOnError) {
264 t3lib_BEfunc::typo3PrintError ('Access Error','This page is not within your DB-mounts',0);
265 exit;
266 }
267 }
268
269 /**
270 * Checks access to a backend module with the $MCONF passed as first argument
271 *
272 * @param array $MCONF array of a backend module!
273 * @param boolean If set, an array will issue an error message and exit.
274 * @return boolean Will return true if $MCONF['access'] is not set at all, if the BE_USER is admin or if the module is enabled in the be_users/be_groups records of the user (specifically enabled). Will return false if the module name is not even found in $TBE_MODULES
275 */
276 function modAccess($conf,$exitOnError) {
277 if (!t3lib_BEfunc::isModuleSetInTBE_MODULES($conf['name'])) {
278 if ($exitOnError) {
279 t3lib_BEfunc::typo3PrintError ('Fatal Error','This module "'.$conf['name'].'" is not enabled in TBE_MODULES',0);
280 exit;
281 }
282 return FALSE;
283 }
284
285 // Workspaces check:
286 if ($conf['workspaces']) {
287 if (($this->workspace===0 && t3lib_div::inList($conf['workspaces'],'online')) ||
288 ($this->workspace===-1 && t3lib_div::inList($conf['workspaces'],'offline')) ||
289 ($this->workspace>0 && t3lib_div::inList($conf['workspaces'],'custom'))) {
290 // ok, go on...
291 } else {
292 if ($exitOnError) {
293 t3lib_BEfunc::typo3PrintError ('Workspace Error','This module "'.$conf['name'].'" is not available under the current workspace',0);
294 exit;
295 }
296 return FALSE;
297 }
298 }
299
300 // Returns true if conf[access] is not set at all or if the user is admin
301 if (!$conf['access'] || $this->isAdmin()) return TRUE;
302
303 // If $conf['access'] is set but not with 'admin' then we return true, if the module is found in the modList
304 if (!strstr($conf['access'],'admin') && $conf['name']) {
305 $acs = $this->check('modules',$conf['name']);
306 }
307 if (!$acs && $exitOnError) {
308 t3lib_BEfunc::typo3PrintError ('Access Error','You don\'t have access to this module.',0);
309 exit;
310 } else return $acs;
311 }
312
313 /**
314 * Returns a WHERE-clause for the pages-table where user permissions according to input argument, $perms, is validated.
315 * $perms is the 'mask' used to select. Fx. if $perms is 1 then you'll get all pages that a user can actually see!
316 * 2^0 = show (1)
317 * 2^1 = edit (2)
318 * 2^2 = delete (4)
319 * 2^3 = new (8)
320 * If the user is 'admin' " 1=1" is returned (no effect)
321 * If the user is not set at all (->user is not an array), then " 1=0" is returned (will cause no selection results at all)
322 * The 95% use of this function is "->getPagePermsClause(1)" which will return WHERE clauses for *selecting* pages in backend listings - in other words will this check read permissions.
323 *
324 * @param integer Permission mask to use, see function description
325 * @return string Part of where clause. Prefix " AND " to this.
326 */
327 function getPagePermsClause($perms) {
328 global $TYPO3_CONF_VARS;
329 if (is_array($this->user)) {
330 if ($this->isAdmin()) {
331 return ' 1=1';
332 }
333
334 $perms = intval($perms); // Make sure it's integer.
335 $str= ' ('.
336 '(pages.perms_everybody & '.$perms.' = '.$perms.')'. // Everybody
337 'OR(pages.perms_userid = '.$this->user['uid'].' AND pages.perms_user & '.$perms.' = '.$perms.')'; // User
338 if ($this->groupList){$str.='OR(pages.perms_groupid in ('.$this->groupList.') AND pages.perms_group & '.$perms.' = '.$perms.')';} // Group (if any is set)
339 $str.=')';
340
341 // ****************
342 // getPagePermsClause-HOOK
343 // ****************
344 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getPagePermsClause'])) {
345
346 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getPagePermsClause'] as $_funcRef) {
347 $_params = array('currentClause' => $str, 'perms' => $perms);
348 $str = t3lib_div::callUserFunction($_funcRef, $_params, $this);
349 }
350 }
351
352 return $str;
353 } else {
354 return ' 1=0';
355 }
356 }
357
358 /**
359 * Returns a combined binary representation of the current users permissions for the page-record, $row.
360 * The perms for user, group and everybody is OR'ed together (provided that the page-owner is the user and for the groups that the user is a member of the group
361 * If the user is admin, 31 is returned (full permissions for all five flags)
362 *
363 * @param array Input page row with all perms_* fields available.
364 * @return integer Bitwise representation of the users permissions in relation to input page row, $row
365 */
366 function calcPerms($row) {
367 global $TYPO3_CONF_VARS;
368 if ($this->isAdmin()) {return 31;} // Return 31 for admin users.
369
370 $out=0;
371 if (isset($row['perms_userid']) && isset($row['perms_user']) && isset($row['perms_groupid']) && isset($row['perms_group']) && isset($row['perms_everybody']) && isset($this->groupList)) {
372 if ($this->user['uid']==$row['perms_userid']) {
373 $out|=$row['perms_user'];
374 }
375 if ($this->isMemberOfGroup($row['perms_groupid'])) {
376 $out|=$row['perms_group'];
377 }
378 $out|=$row['perms_everybody'];
379 }
380
381 // ****************
382 // CALCPERMS hook
383 // ****************
384 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['calcPerms'])) {
385 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['calcPerms'] as $_funcRef) {
386 $_params = array(
387 'row' => $row,
388 'outputPermissions' => $out
389 );
390 $out = t3lib_div::callUserFunction($_funcRef, $_params, $this);
391 }
392 }
393
394 return $out;
395 }
396
397 /**
398 * Returns true if the RTE (Rich Text Editor) can be enabled for the user
399 * Strictly this is not permissions being checked but rather a series of settings like a loaded extension, browser/client type and a configuration option in ->uc[edit_RTE]
400 * The reasons for a FALSE return can be found in $this->RTE_errors
401 *
402 * @return boolean
403 */
404 function isRTE() {
405 global $CLIENT;
406
407 // Start:
408 $this->RTE_errors = array();
409 if (!$this->uc['edit_RTE'])
410 $this->RTE_errors[] = 'RTE is not enabled for user!';
411 if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])
412 $this->RTE_errors[] = 'RTE is not enabled in $TYPO3_CONF_VARS["BE"]["RTEenabled"]';
413
414
415 // Acquire RTE object:
416 $RTE = &t3lib_BEfunc::RTEgetObj();
417 if (!is_object($RTE)) {
418 $this->RTE_errors = array_merge($this->RTE_errors, $RTE);
419 }
420
421 if (!count($this->RTE_errors)) {
422 return TRUE;
423 } else {
424 return FALSE;
425 }
426 }
427
428 /**
429 * Returns true if the $value is found in the list in a $this->groupData[] index pointed to by $type (array key).
430 * Can thus be users to check for modules, exclude-fields, select/modify permissions for tables etc.
431 * If user is admin true is also returned
432 * Please see the document Inside TYPO3 for examples.
433 *
434 * @param string The type value; "webmounts", "filemounts", "pagetypes_select", "tables_select", "tables_modify", "non_exclude_fields", "modules"
435 * @param string String to search for in the groupData-list
436 * @return boolean True if permission is granted (that is, the value was found in the groupData list - or the BE_USER is "admin")
437 */
438 function check($type,$value) {
439 if (isset($this->groupData[$type])) {
440 if ($this->isAdmin() || $this->inList($this->groupData[$type],$value)) {
441 return 1;
442 }
443 }
444 }
445
446 /**
447 * Checking the authMode of a select field with authMode set
448 *
449 * @param string Table name
450 * @param string Field name (must be configured in TCA and of type "select" with authMode set!)
451 * @param string Value to evaluation (single value, must not contain any of the chars ":,|")
452 * @param string Auth mode keyword (explicitAllow, explicitDeny, individual)
453 * @return boolean True or false whether access is granted or not.
454 */
455 function checkAuthMode($table,$field,$value,$authMode) {
456 global $TCA;
457
458 // Admin users can do anything:
459 if ($this->isAdmin()) return TRUE;
460
461 // Allow all blank values:
462 if (!strcmp($value,'')) return TRUE;
463
464 // Certain characters are not allowed in the value
465 if (ereg('[:|,]',$value)) {
466 return FALSE;
467 }
468
469 // Initialize:
470 $testValue = $table.':'.$field.':'.$value;
471 $out = TRUE;
472
473 // Checking value:
474 switch((string)$authMode) {
475 case 'explicitAllow':
476 if (!$this->inList($this->groupData['explicit_allowdeny'],$testValue.':ALLOW')) {
477 $out = FALSE;
478 }
479 break;
480 case 'explicitDeny':
481 if ($this->inList($this->groupData['explicit_allowdeny'],$testValue.':DENY')) {
482 $out = FALSE;
483 }
484 break;
485 case 'individual':
486 t3lib_div::loadTCA($table);
487 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$field])) {
488 $items = $TCA[$table]['columns'][$field]['config']['items'];
489 if (is_array($items)) {
490 foreach($items as $iCfg) {
491 if (!strcmp($iCfg[1],$value) && $iCfg[4]) {
492 switch((string)$iCfg[4]) {
493 case 'EXPL_ALLOW':
494 if (!$this->inList($this->groupData['explicit_allowdeny'],$testValue.':ALLOW')) {
495 $out = FALSE;
496 }
497 break;
498 case 'EXPL_DENY':
499 if ($this->inList($this->groupData['explicit_allowdeny'],$testValue.':DENY')) {
500 $out = FALSE;
501 }
502 break;
503 }
504 break;
505 }
506 }
507 }
508 }
509 break;
510 }
511
512 return $out;
513 }
514
515 /**
516 * Checking if a language value (-1, 0 and >0 for sys_language records) is allowed to be edited by the user.
517 *
518 * @param integer Language value to evaluate
519 * @return boolean Returns true if the language value is allowed, otherwise false.
520 */
521 function checkLanguageAccess($langValue) {
522 if (strcmp($this->groupData['allowed_languages'],'')) { // The users language list must be non-blank - otherwise all languages are allowed.
523 $langValue = intval($langValue);
524 if ($langValue != -1 && !$this->check('allowed_languages',$langValue)) { // Language must either be explicitly allowed OR the lang Value be "-1" (all languages)
525 return FALSE;
526 }
527 }
528 return TRUE;
529 }
530
531 /**
532 * Checking if a user has editing access to a record from a $TCA table.
533 * The checks does not take page permissions and other "environmental" things into account. It only deal with record internals; If any values in the record fields disallows it.
534 * For instance languages settings, authMode selector boxes are evaluated (and maybe more in the future).
535 * It will check for workspace dependent access.
536 * The function takes an ID (integer) or row (array) as second argument.
537 *
538 * @param string Table name
539 * @param mixed If integer, then this is the ID of the record. If Array this just represents fields in the record.
540 * @return boolean True if OK, otherwise false
541 */
542 function recordEditAccessInternals($table,$idOrRow) {
543 global $TCA;
544
545 if (isset($TCA[$table])) {
546 t3lib_div::loadTCA($table);
547
548 // Always return true for Admin users.
549 if ($this->isAdmin()) return TRUE;
550
551 // Fetching the record if the $idOrRow variable was not an array on input:
552 if (!is_array($idOrRow)) {
553 $idOrRow = t3lib_BEfunc::getRecord($table, $idOrRow);
554 if (!is_array($idOrRow)) {
555 $this->errorMsg = 'ERROR: Record could not be fetched.';
556 return FALSE;
557 }
558 }
559
560 // Checking languages:
561 if ($TCA[$table]['ctrl']['languageField']) {
562 if (isset($idOrRow[$TCA[$table]['ctrl']['languageField']])) { // Language field must be found in input row - otherwise it does not make sense.
563 if (!$this->checkLanguageAccess($idOrRow[$TCA[$table]['ctrl']['languageField']])) {
564 $this->errorMsg = 'ERROR: Language was not allowed.';
565 return FALSE;
566 }
567 }
568 }
569
570 // Checking authMode fields:
571 if (is_array($TCA[$table]['columns'])) {
572 foreach($TCA[$table]['columns'] as $fN => $fV) {
573 if (isset($idOrRow[$fN])) { //
574 if ($fV['config']['type']=='select' && $fV['config']['authMode'] && !strcmp($fV['config']['authMode_enforce'],'strict')) {
575 if (!$this->checkAuthMode($table,$fN,$idOrRow[$fN],$fV['config']['authMode'])) {
576 $this->errorMsg = 'ERROR: authMode "'.$fV['config']['authMode'].'" failed for field "'.$fN.'" with value "'.$idOrRow[$fN].'" evaluated';
577 return FALSE;
578 }
579 }
580 }
581 }
582 }
583
584 // Checking "editlock" feature
585 if ($TCA[$table]['ctrl']['editlock'] && $idOrRow[$TCA[$table]['ctrl']['editlock']]) {
586 $this->errorMsg = 'ERROR: Record was locked for editing. Only admin users can change this state.';
587 return FALSE;
588 }
589
590 // Checking record permissions
591 // THIS is where we can include a check for "perms_" fields for other records than pages...
592
593 // Finally, return true if all is well.
594 return TRUE;
595 }
596 }
597
598 /**
599 * Will check a type of permission against the compiled permission integer, $lCP, and in relation to table, $table
600 *
601 * @param integer $lCP could typically be the "compiled permissions" integer returned by ->calcPerms
602 * @param string $table is the tablename to check: If "pages" table then edit,new,delete and editcontent permissions can be checked. Other tables will be checked for "editcontent" only (and $type will be ignored)
603 * @param string For $table='pages' this can be 'edit' (2), 'new' (8 or 16), 'delete' (4), 'editcontent' (16). For all other tables this is ignored. (16 is used)
604 * @return boolean
605 * @access private
606 */
607 function isPSet($lCP,$table,$type='') {
608 if ($this->isAdmin()) return true;
609 if ($table=='pages') {
610 if ($type=='edit') return $lCP & 2;
611 if ($type=='new') return ($lCP & 8) || ($lCP & 16); // Create new page OR pagecontent
612 if ($type=='delete') return $lCP & 4;
613 if ($type=='editcontent') return $lCP & 16;
614 } else {
615 return $lCP & 16;
616 }
617 }
618
619 /**
620 * Returns true if the BE_USER is allowed to *create* shortcuts in the backend modules
621 *
622 * @return boolean
623 */
624 function mayMakeShortcut() {
625 return $this->getTSConfigVal('options.shortcutFrame') && !$this->getTSConfigVal('options.mayNotCreateEditShortcuts');
626 }
627
628 /**
629 * Checking if editing of an existing record is allowed in current workspace if that is offline.
630 * Rules for editing in offline mode:
631 * - record supports versioning and is an offline version from workspace and has the corrent stage
632 * - or record (any) is in a branch where there is a page which is a version from the workspace and where the stage is not preventing records
633 *
634 * @param string Table of record
635 * @param array Integer (record uid) or array where fields are at least: pid, t3ver_wsid, t3ver_stage (if versioningWS is set)
636 * @return string String error code, telling the failure state. FALSE=All ok
637 */
638 function workspaceCannotEditRecord($table,$recData) {
639
640 if ($this->workspace!==0) { // Only test offline spaces:
641
642 if (!is_array($recData)) {
643 $recData = t3lib_BEfunc::getRecord($table,$recData,'pid'.($GLOBALS['TCA'][$table]['ctrl']['versioningWS']?',t3ver_wsid,t3ver_stage':''));
644 }
645
646 if (is_array($recData)) {
647 if ((int)$recData['pid']===-1) { // We are testing a "version" (identified by a pid of -1): it can be edited provided that workspace matches and versioning is enabled for the table.
648 if (!$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { // No versioning, basic error, inconsistency even! Such records should not have a pid of -1!
649 return 'Versioning disabled for table';
650 } elseif ((int)$recData['t3ver_wsid']!==$this->workspace) { // So does workspace match?
651 return 'Workspace ID of record didn\'t match current workspace';
652 } else { // So what about the stage of the version, does that allow editing for this user?
653 return $this->workspaceCheckStageForCurrent($recData['t3ver_stage']) ? FALSE : 'Record stage "'.$recData['t3ver_stage'].'" and users access level did not allow for editing';
654 }
655 } else { // We are testing a "live" record:
656 if ($res = $this->workspaceAllowLiveRecordsInPID($recData['pid'], $table)) { // For "Live" records, check that PID for table allows editing
657 // Live records are OK in this branch, but what about the stage of branch point, if any:
658 return $res>0 ? FALSE : 'Stage for versioning root point and users access level did not allow for editing'; // OK
659 } else { // If not offline and not in versionized branch, output error:
660 return 'Online record was not in versionized branch!';
661 }
662 }
663 } else return 'No record';
664 } else {
665 return FALSE; // OK because workspace is 0
666 }
667 }
668
669 /**
670 * Evaluates if a user is allowed to edit the offline version
671 *
672 * @param string Table of record
673 * @param array Integer (record uid) or array where fields are at least: pid, t3ver_wsid, t3ver_stage (if versioningWS is set)
674 * @return string String error code, telling the failure state. FALSE=All ok
675 * @see workspaceCannotEditRecord()
676 */
677 function workspaceCannotEditOfflineVersion($table,$recData) {
678 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
679
680 if (!is_array($recData)) {
681 $recData = t3lib_BEfunc::getRecord($table,$recData,'uid,pid,t3ver_wsid,t3ver_stage');
682 }
683 if (is_array($recData)) {
684 if ((int)$recData['pid']===-1) {
685 return $this->workspaceCannotEditRecord($table,$recData);
686 } else return 'Not an offline version';
687 } else return 'No record';
688 } else return 'Table does not support versioning.';
689 }
690
691 /**
692 * Check if "live" records from $table may be created or edited in this PID.
693 * If the answer is FALSE it means the only valid way to create or edit records in the PID is by versioning
694 * If the answer is 1 or 2 it means it is OK to create a record, if -1 it means that it is OK in terms of versioning because the element was within a versionized branch but NOT ok in terms of the state the root point had!
695 *
696 * @param integer PID value to check for.
697 * @param string Table name
698 * @return mixed Returns FALSE if a live record cannot be created and must be versionized in order to do so. 2 means a) Workspace is "Live" or workspace allows "live edit" of records from non-versionized tables (and the $table is not versionizable). 1 and -1 means the pid is inside a versionized branch where -1 means that the branch-point did NOT allow a new record according to its state.
699 */
700 function workspaceAllowLiveRecordsInPID($pid, $table) {
701
702 // Always for Live workspace AND if live-edit is enabled and tables are completely without versioning it is ok as well.
703 if ($this->workspace===0 || ($this->workspaceRec['live_edit'] && !$GLOBALS['TCA'][$table]['ctrl']['versioningWS'])) {
704 return 2; // OK to create for this table.
705 } elseif (t3lib_BEfunc::isPidInVersionizedBranch($pid, $table)) { // Check if records from $table can be created with this PID: Either if inside "branch" versioning type or a "versioning_followPages" table on a "page" versioning type.
706 // Now, check what the stage of that "page" or "branch" version type is:
707 $stage = t3lib_BEfunc::isPidInVersionizedBranch($pid, $table, TRUE);
708 return $this->workspaceCheckStageForCurrent($stage) ? 1 : -1;
709 } else {
710 return FALSE; // If the answer is FALSE it means the only valid way to create or edit records in the PID is by versioning
711 }
712 }
713
714 /**
715 * Evaluates if a record from $table can be created in $pid
716 *
717 * @param integer Page id. This value must be the _ORIG_uid if available: So when you have pages versionized as "page" or "element" you must supply the id of the page version in the workspace!
718 * @param string Table name
719 * @return boolean TRUE if OK.
720 */
721 function workspaceCreateNewRecord($pid, $table) {
722 if ($res = $this->workspaceAllowLiveRecordsInPID($pid,$table)) { // If LIVE records cannot be created in the current PID due to workspace restrictions, prepare creation of placeholder-record
723 if ($res<0) {
724 return FALSE; // Stage for versioning root point and users access level did not allow for editing
725 }
726 } elseif (!$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { // So, if no live records were allowed, we have to create a new version of this record:
727 return FALSE;
728 }
729 return TRUE;
730 }
731
732 /**
733 * Evaluates if auto creation of a version of a record is allowed.
734 *
735 * @param string Table of the record
736 * @param integer UID of record
737 * @param integer PID of record
738 * @return boolean TRUE if ok.
739 */
740 function workspaceAllowAutoCreation($table,$id,$recpid) {
741 // Auto-creation of version: In offline workspace, test if versioning is enabled and look for workspace version of input record. If there is no versionized record found we will create one and save to that.
742 if ($this->workspace!==0 // Only in draft workspaces
743 && !$this->workspaceRec['disable_autocreate'] // Auto-creation must not be disabled.
744 && $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] // Table must be versionizable
745 && $recpid >= 0 // The PID of the record must NOT be -1 or less (would indicate that it already was a version!)
746 && !t3lib_BEfunc::getWorkspaceVersionOfRecord($this->workspace, $table, $id, 'uid') // There must be no existing version of this record in workspace.
747 && !t3lib_BEfunc::isPidInVersionizedBranch($recpid, $table)) { // PID must NOT be in a versionized branch either
748 return TRUE;
749 }
750 }
751
752 /**
753 * Checks if an element stage allows access for the user in the current workspace
754 * In workspaces 0 (Live) and -1 (Default draft) access is always granted for any stage.
755 * Admins are always allowed.
756 *
757 * @param integer Stage id from an element: -1,0 = editing, 1 = reviewer, >1 = owner
758 * @return boolean TRUE if user is allowed access
759 */
760 function workspaceCheckStageForCurrent($stage) {
761 if ($this->isAdmin()) return TRUE;
762
763 if ($this->workspace>0) {
764 $stat = $this->checkWorkspaceCurrent();
765 if (($stage<=0 && $stat['_ACCESS']==='member') ||
766 ($stage<=1 && $stat['_ACCESS']==='reviewer') ||
767 ($stat['_ACCESS']==='owner')) {
768 return TRUE; // OK for these criteria
769 }
770 } else return TRUE; // Always OK for live and draft workspaces.
771 }
772
773 /**
774 * Returns TRUE if the user has access to publish content from the workspace ID given.
775 * Admin-users are always granted access to do this
776 * If the workspace ID is 0 (live) all users have access also
777 * If -1 (draft workspace) TRUE is returned if the user has access to the Live workspace
778 * For custom workspaces it depends on whether the user is owner OR like with draft workspace if the user has access to Live workspace.
779 *
780 * @param integer Workspace UID; -1,0,1+
781 * @return boolean Returns TRUE if the user has access to publish content from the workspace ID given.
782 */
783 function workspacePublishAccess($wsid) {
784 if ($this->isAdmin()) return TRUE;
785
786 $wsAccess = $this->checkWorkspace($wsid);
787 if ($wsAccess) {
788 switch($wsAccess['uid']) {
789 case 0: // Live workspace
790 return TRUE; // If access to Live workspace, no problem.
791 break;
792 case -1: // Default draft workspace
793 return $this->checkWorkspace(0) ? TRUE : FALSE; // If access to Live workspace, no problem.
794 break;
795 default: // Custom workspace
796 return $wsAccess['_ACCESS'] === 'owner' || ($this->checkWorkspace(0) && !($wsAccess['publish_access']&2)); // Either be an adminuser OR have access to online workspace which is OK as well as long as publishing access is not limited by workspace option.
797 break;
798 }
799 } else return FALSE; // If no access to workspace, of course you cannot publish!
800 }
801
802 /**
803 * Workspace swap-mode access?
804 *
805 * @return boolean Returns TRUE if records can be swapped in the current workspace, otherwise false
806 */
807 function workspaceSwapAccess() {
808 if ($this->workspace>0 && (int)$this->workspaceRec['swap_modes']===2) {
809 return FALSE;
810 } else return TRUE;
811 }
812
813 /**
814 * Workspace Versioning type access?
815 *
816 * @param integer Versioning type to evaluation: -1, 0, >1
817 * @return boolean TRUE if OK
818 */
819 function workspaceVersioningTypeAccess($type) {
820 if ($this->workspace>0 && !$this->isAdmin()) {
821 $stat = $this->checkWorkspaceCurrent();
822 if ($stat['_ACCESS']!=='owner') {
823
824 $type = t3lib_div::intInRange($type,-1);
825 switch((int)$type) {
826 case -1:
827 return $this->workspaceRec['vtypes']&1 ? FALSE : TRUE;
828 break;
829 case 0:
830 return $this->workspaceRec['vtypes']&2 ? FALSE : TRUE;
831 break;
832 default:
833 return $this->workspaceRec['vtypes']&4 ? FALSE : TRUE;
834 break;
835 }
836 } else return TRUE;
837 } else return TRUE;
838 }
839
840 /**
841 * Finding "closest" versioning type, used for creation of new records.
842 *
843 * @param integer Versioning type to evaluation: -1, 0, >1
844 * @return integer Returning versioning type
845 */
846 function workspaceVersioningTypeGetClosest($type) {
847 if ($this->workspace>0) {
848 $type = t3lib_div::intInRange($type,-1);
849 switch((int)$type) {
850 case -1:
851 return -1;
852 break;
853 case 0:
854 return $this->workspaceVersioningTypeAccess($type) ? $type : -1;
855 break;
856 default:
857 return $this->workspaceVersioningTypeAccess($type) ? $type : ($this->workspaceVersioningTypeAccess(0) ? 0 : -1);
858 break;
859 }
860 } else return $type;
861 }
862
863
864
865
866
867
868
869
870
871
872 /*************************************
873 *
874 * Miscellaneous functions
875 *
876 *************************************/
877
878 /**
879 * Returns the value/properties of a TS-object as given by $objectString, eg. 'options.dontMountAdminMounts'
880 * Nice (general!) function for returning a part of a TypoScript array!
881 *
882 * @param string Pointer to an "object" in the TypoScript array, fx. 'options.dontMountAdminMounts'
883 * @param array Optional TSconfig array: If array, then this is used and not $this->userTS. If not array, $this->userTS is used.
884 * @return array An array with two keys, "value" and "properties" where "value" is a string with the value of the objectsting and "properties" is an array with the properties of the objectstring.
885 * @params array An array with the TypoScript where the $objectString is located. If this argument is not an array, then internal ->userTS (User TSconfig for the current BE_USER) will be used instead.
886 */
887 function getTSConfig($objectString,$config='') {
888 if (!is_array($config)) {
889 $config=$this->userTS; // Getting Root-ts if not sent
890 }
891 $TSConf=array();
892 $parts = explode('.',$objectString,2);
893 $key = $parts[0];
894 if (trim($key)) {
895 if (count($parts)>1 && trim($parts[1])) {
896 // Go on, get the next level
897 if (is_array($config[$key.'.'])) $TSConf = $this->getTSConfig($parts[1],$config[$key.'.']);
898 } else {
899 $TSConf['value']=$config[$key];
900 $TSConf['properties']=$config[$key.'.'];
901 }
902 }
903 return $TSConf;
904 }
905
906 /**
907 * Returns the "value" of the $objectString from the BE_USERS "User TSconfig" array
908 *
909 * @param string Object string, eg. "somestring.someproperty.somesubproperty"
910 * @return string The value for that object string (object path)
911 * @see getTSConfig()
912 */
913 function getTSConfigVal($objectString) {
914 $TSConf = $this->getTSConfig($objectString);
915 return $TSConf['value'];
916 }
917
918 /**
919 * Returns the "properties" of the $objectString from the BE_USERS "User TSconfig" array
920 *
921 * @param string Object string, eg. "somestring.someproperty.somesubproperty"
922 * @return array The properties for that object string (object path) - if any
923 * @see getTSConfig()
924 */
925 function getTSConfigProp($objectString) {
926 $TSConf = $this->getTSConfig($objectString);
927 return $TSConf['properties'];
928 }
929
930 /**
931 * Returns true if $item is in $in_list
932 *
933 * @param string Comma list with items, no spaces between items!
934 * @param string The string to find in the list of items
935 * @return string Boolean
936 */
937 function inList($in_list,$item) {
938 return strstr(','.$in_list.',', ','.$item.',');
939 }
940
941 /**
942 * Returns an array with the webmounts.
943 * If no webmounts, and empty array is returned.
944 * NOTICE: Deleted pages WILL NOT be filtered out! So if a mounted page has been deleted it is STILL coming out as a webmount. This is not checked due to performance.
945 *
946 * @return array
947 */
948 function returnWebmounts() {
949 return (string)($this->groupData['webmounts'])!='' ? explode(',',$this->groupData['webmounts']) : Array();
950 }
951
952 /**
953 * Returns an array with the filemounts for the user. Each filemount is represented with an array of a "name", "path" and "type".
954 * If no filemounts an empty array is returned.
955 *
956 * @return array
957 */
958 function returnFilemounts() {
959 return $this->groupData['filemounts'];
960 }
961
962
963
964
965
966
967
968
969
970
971
972
973 /*************************************
974 *
975 * Authentication methods
976 *
977 *************************************/
978
979
980 /**
981 * Initializes a lot of stuff like the access-lists, database-mountpoints and filemountpoints
982 * This method is called by ->backendCheckLogin() (from extending class t3lib_beuserauth) if the backend user login has verified OK.
983 * Generally this is required initialization of a backend user.
984 *
985 * @return void
986 * @access private
987 * @see t3lib_TSparser
988 */
989 function fetchGroupData() {
990 if ($this->user['uid']) {
991
992 // Get lists for the be_user record and set them as default/primary values.
993 $this->dataLists['modList'] = $this->user['userMods']; // Enabled Backend Modules
994 $this->dataLists['allowed_languages'] = $this->user['allowed_languages']; // Add Allowed Languages
995 $this->dataLists['workspace_perms'] = $this->user['workspace_perms']; // Set user value for workspace permissions.
996 $this->dataLists['webmount_list'] = $this->user['db_mountpoints']; // Database mountpoints
997 $this->dataLists['filemount_list'] = $this->user['file_mountpoints']; // File mountpoints
998
999 // Setting default User TSconfig:
1000 $this->TSdataArray[]=$this->addTScomment('From $GLOBALS["TYPO3_CONF_VARS"]["BE"]["defaultUserTSconfig"]:').
1001 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'];
1002
1003 // Default TSconfig for admin-users
1004 if ($this->isAdmin()) {
1005 $this->TSdataArray[]=$this->addTScomment('"admin" user presets:').'
1006 admPanel.enable.all = 1
1007 options.shortcutFrame = 1
1008 ';
1009 if (t3lib_extMgm::isLoaded('sys_note')) {
1010 $this->TSdataArray[]='
1011 // Setting defaults for sys_note author / email...
1012 TCAdefaults.sys_note.author = '.$this->user['realName'].'
1013 TCAdefaults.sys_note.email = '.$this->user['email'].'
1014 ';
1015 }
1016 }
1017
1018 // FILE MOUNTS:
1019 // Admin users has the base fileadmin dir mounted
1020 if ($this->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) {
1021 $this->addFileMount($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '', PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], 0, '');
1022 }
1023
1024 // If userHomePath is set, we attempt to mount it
1025 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath']) {
1026 // First try and mount with [uid]_[username]
1027 $didMount=$this->addFileMount($this->user['username'], '',$GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'].$this->user['uid'].'_'.$this->user['username'].$GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'], 0, 'user');
1028 if (!$didMount) {
1029 // If that failed, try and mount with only [uid]
1030 $this->addFileMount($this->user['username'], '', $GLOBALS['TYPO3_CONF_VARS']['BE']['userHomePath'].$this->user['uid'].$GLOBALS['TYPO3_CONF_VARS']['BE']['userUploadDir'], 0, 'user');
1031 }
1032 }
1033
1034 // BE_GROUPS:
1035 // Get the groups...
1036 # $grList = t3lib_BEfunc::getSQLselectableList($this->user[$this->usergroup_column],$this->usergroup_table,$this->usergroup_table);
1037 $grList = $GLOBALS['TYPO3_DB']->cleanIntList($this->user[$this->usergroup_column]); // 240203: Since the group-field never contains any references to groups with a prepended table name we think it's safe to just intExplode and re-implode - which should be much faster than the other function call.
1038 if ($grList) {
1039 // Fetch groups will add a lot of information to the internal arrays: modules, accesslists, TSconfig etc. Refer to fetchGroups() function.
1040 $this->fetchGroups($grList);
1041 }
1042
1043 // Add the TSconfig for this specific user:
1044 $this->TSdataArray[] = $this->addTScomment('USER TSconfig field').$this->user['TSconfig'];
1045 // Check include lines.
1046 $this->TSdataArray = t3lib_TSparser::checkIncludeLines_array($this->TSdataArray);
1047
1048 // Parsing the user TSconfig (or getting from cache)
1049 $this->userTS_text = implode(chr(10).'[GLOBAL]'.chr(10),$this->TSdataArray); // Imploding with "[global]" will make sure that non-ended confinements with braces are ignored.
1050 $hash = md5('userTS:'.$this->userTS_text);
1051 $cachedContent = t3lib_BEfunc::getHash($hash,0);
1052 if (isset($cachedContent) && !$this->userTS_dontGetCached) {
1053 $this->userTS = unserialize($cachedContent);
1054 } else {
1055 $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
1056 $parseObj->parse($this->userTS_text);
1057 $this->userTS = $parseObj->setup;
1058 t3lib_BEfunc::storeHash($hash,serialize($this->userTS),'BE_USER_TSconfig');
1059 // Update UC:
1060 $this->userTSUpdated=1;
1061 }
1062
1063 // Processing webmounts
1064 if ($this->isAdmin() && !$this->getTSConfigVal('options.dontMountAdminMounts')) { // Admin's always have the root mounted
1065 $this->dataLists['webmount_list']='0,'.$this->dataLists['webmount_list'];
1066 }
1067
1068 // Processing filemounts
1069 $this->dataLists['filemount_list'] = t3lib_div::uniqueList($this->dataLists['filemount_list']);
1070 if ($this->dataLists['filemount_list']) {
1071 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted=0 AND hidden=0 AND pid=0 AND uid IN ('.$this->dataLists['filemount_list'].')');
1072 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1073 $this->addFileMount($row['title'], $row['path'], $row['path'], $row['base']?1:0, '');
1074 }
1075 }
1076
1077 // The lists are cleaned for duplicates
1078 $this->groupData['webmounts'] = t3lib_div::uniqueList($this->dataLists['webmount_list']);
1079 $this->groupData['pagetypes_select'] = t3lib_div::uniqueList($this->dataLists['pagetypes_select']);
1080 $this->groupData['tables_select'] = t3lib_div::uniqueList($this->dataLists['tables_modify'].','.$this->dataLists['tables_select']);
1081 $this->groupData['tables_modify'] = t3lib_div::uniqueList($this->dataLists['tables_modify']);
1082 $this->groupData['non_exclude_fields'] = t3lib_div::uniqueList($this->dataLists['non_exclude_fields']);
1083 $this->groupData['explicit_allowdeny'] = t3lib_div::uniqueList($this->dataLists['explicit_allowdeny']);
1084 $this->groupData['allowed_languages'] = t3lib_div::uniqueList($this->dataLists['allowed_languages']);
1085 $this->groupData['custom_options'] = t3lib_div::uniqueList($this->dataLists['custom_options']);
1086 $this->groupData['modules'] = t3lib_div::uniqueList($this->dataLists['modList']);
1087 $this->groupData['workspace_perms'] = $this->dataLists['workspace_perms'];
1088
1089 // populating the $this->userGroupsUID -array with the groups in the order in which they were LAST included.!!
1090 $this->userGroupsUID = array_reverse(array_unique(array_reverse($this->includeGroupArray)));
1091
1092 // Finally this is the list of group_uid's in the order they are parsed (including subgroups!) and without duplicates (duplicates are presented with their last entrance in the list, which thus reflects the order of the TypoScript in TSconfig)
1093 $this->groupList = implode(',',$this->userGroupsUID);
1094 $this->setCachedList($this->groupList);
1095
1096 // Checking read access to webmounts:
1097 if (trim($this->groupData['webmounts'])!=='') {
1098 $webmounts = explode(',',$this->groupData['webmounts']); // Explode mounts
1099 $MProws = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', 'deleted=0 AND uid IN ('.$this->groupData['webmounts'].') AND '.$this->getPagePermsClause(1),'','','','uid'); // Selecting all webmounts with permission clause for reading
1100 foreach($webmounts as $idx => $mountPointUid) {
1101 if ($mountPointUid>0 && !isset($MProws[$mountPointUid])) { // If the mount ID is NOT found among selected pages, unset it:
1102 unset($webmounts[$idx]);
1103 }
1104 }
1105 $this->groupData['webmounts'] = implode(',',$webmounts); // Implode mounts in the end.
1106 }
1107
1108 // Setting up workspace situation (after webmounts are processed!):
1109 $this->workspaceInit();
1110 }
1111 }
1112
1113 /**
1114 * Fetches the group records, subgroups and fills internal arrays.
1115 * Function is called recursively to fetch subgroups
1116 *
1117 * @param string Commalist of be_groups uid numbers
1118 * @param string List of already processed be_groups-uids so the function will not fall into a eternal recursion.
1119 * @return void
1120 * @access private
1121 */
1122 function fetchGroups($grList,$idList='') {
1123
1124 // Fetching records of the groups in $grList (which are not blocked by lockedToDomain either):
1125 $lockToDomain_SQL = ' AND (lockToDomain=\'\' OR lockToDomain=\''.t3lib_div::getIndpEnv('HTTP_HOST').'\')';
1126 $whereSQL = 'deleted=0 AND hidden=0 AND pid=0 AND uid IN ('.$grList.')'.$lockToDomain_SQL;
1127
1128 // Hook for manipulation of the WHERE sql sentence which controls which BE-groups are included
1129 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['fetchGroupQuery'])) {
1130 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['fetchGroupQuery'] as $classRef) {
1131 $hookObj = &t3lib_div::getUserObj($classRef);
1132 if(method_exists($hookObj,'fetchGroupQuery_processQuery')){
1133 $whereSQL = $hookObj->fetchGroupQuery_processQuery($this, $grList, $idList, $whereSQL);
1134 }
1135 }
1136 }
1137
1138 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->usergroup_table, $whereSQL);
1139
1140 // The userGroups array is filled
1141 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1142 $this->userGroups[$row['uid']] = $row;
1143 }
1144
1145 // Traversing records in the correct order
1146 $include_staticArr = t3lib_div::intExplode(',',$grList);
1147 reset($include_staticArr);
1148 while(list(,$uid)=each($include_staticArr)) { // traversing list
1149
1150 // Get row:
1151 $row=$this->userGroups[$uid];
1152 if (is_array($row) && !t3lib_div::inList($idList,$uid)) { // Must be an array and $uid should not be in the idList, because then it is somewhere previously in the grouplist
1153
1154 // Include sub groups
1155 if (trim($row['subgroup'])) {
1156 $theList = implode(',',t3lib_div::intExplode(',',$row['subgroup'])); // Make integer list
1157 $this->fetchGroups($theList, $idList.','.$uid); // Call recursively, pass along list of already processed groups so they are not recursed again.
1158 }
1159 // Add the group uid, current list, TSconfig to the internal arrays.
1160 $this->includeGroupArray[]=$uid;
1161 $this->includeHierarchy[]=$idList;
1162 $this->TSdataArray[] = $this->addTScomment('Group "'.$row['title'].'" ['.$row['uid'].'] TSconfig field:').$row['TSconfig'];
1163
1164 // Mount group database-mounts
1165 if (($this->user['options']&1) == 1) { $this->dataLists['webmount_list'].= ','.$row['db_mountpoints']; }
1166
1167 // Mount group file-mounts
1168 if (($this->user['options']&2) == 2) { $this->dataLists['filemount_list'].= ','.$row['file_mountpoints']; }
1169
1170 // Mount group home-dirs
1171 if (($this->user['options']&2) == 2) {
1172 // If groupHomePath is set, we attempt to mount it
1173 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath']) {
1174 $this->addFileMount($row['title'], '', $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'].$row['uid'], 0, 'group');
1175 }
1176 }
1177
1178 // The lists are made: groupMods, tables_select, tables_modify, pagetypes_select, non_exclude_fields, explicit_allowdeny, allowed_languages, custom_options
1179 if ($row['inc_access_lists']==1) {
1180 $this->dataLists['modList'].= ','.$row['groupMods'];
1181 $this->dataLists['tables_select'].= ','.$row['tables_select'];
1182 $this->dataLists['tables_modify'].= ','.$row['tables_modify'];
1183 $this->dataLists['pagetypes_select'].= ','.$row['pagetypes_select'];
1184 $this->dataLists['non_exclude_fields'].= ','.$row['non_exclude_fields'];
1185 $this->dataLists['explicit_allowdeny'].= ','.$row['explicit_allowdeny'];
1186 $this->dataLists['allowed_languages'].= ','.$row['allowed_languages'];
1187 $this->dataLists['custom_options'].= ','.$row['custom_options'];
1188 }
1189
1190 // Setting workspace permissions:
1191 $this->dataLists['workspace_perms'] |= $row['workspace_perms'];
1192
1193 // If this function is processing the users OWN group-list (not subgroups) AND if the ->firstMainGroup is not set, then the ->firstMainGroup will be set.
1194 if (!strcmp($idList,'') && !$this->firstMainGroup) {
1195 $this->firstMainGroup=$uid;
1196 }
1197 }
1198 }
1199 }
1200
1201 /**
1202 * Updates the field be_users.usergroup_cached_list if the groupList of the user has changed/is different from the current list.
1203 * The field "usergroup_cached_list" contains the list of groups which the user is a member of. After authentication (where these functions are called...) one can depend on this list being a representation of the exact groups/subgroups which the BE_USER has membership with.
1204 *
1205 * @param string The newly compiled group-list which must be compared with the current list in the user record and possibly stored if a difference is detected.
1206 * @return void
1207 * @access private
1208 */
1209 function setCachedList($cList) {
1210 if ((string)$cList != (string)$this->user['usergroup_cached_list']) {
1211 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users', 'uid='.intval($this->user['uid']), array('usergroup_cached_list' => $cList));
1212 }
1213 }
1214
1215 /**
1216 * Adds a filemount to the users array of filemounts, $this->groupData['filemounts'][hash_key] = Array ('name'=>$name, 'path'=>$path, 'type'=>$type);
1217 * Is a part of the authentication proces of the user.
1218 * A final requirement for a path being mounted is that a) it MUST return true on is_dir(), b) must contain either PATH_site+'fileadminDir' OR 'lockRootPath' - if lockRootPath is set - as first part of string!
1219 * Paths in the mounted information will always be absolute and have a trailing slash.
1220 *
1221 * @param string $title will be the (root)name of the filemount in the folder tree
1222 * @param string $altTitle will be the (root)name of the filemount IF $title is not true (blank or zero)
1223 * @param string $path is the path which should be mounted. Will accept backslash in paths on windows servers (will substituted with forward slash). The path should be 1) relative to TYPO3_CONF_VARS[BE][fileadminDir] if $webspace is set, otherwise absolute.
1224 * @param boolean If $webspace is set, the $path is relative to 'fileadminDir' in TYPO3_CONF_VARS, otherwise $path is absolute. 'fileadminDir' must be set to allow mounting of relative paths.
1225 * @param string Type of filemount; Can be blank (regular) or "user" / "group" (for user and group filemounts presumably). Probably sets the icon first and foremost.
1226 * @return boolean Returns "1" if the requested filemount was mounted, otherwise no return value.
1227 * @access private
1228 */
1229 function addFileMount($title, $altTitle, $path, $webspace, $type) {
1230 // Return false if fileadminDir is not set and we try to mount a relative path
1231 if ($webspace && !$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) return false;
1232
1233 // Trimming and pre-processing
1234 $path=trim($path);
1235 if ($this->OS=='WIN') { // with WINDOWS convert backslash to slash!!
1236 $path=str_replace('\\','/',$path);
1237 }
1238 // If the path is true and validates as a valid path string:
1239 if ($path && t3lib_div::validPathStr($path)) {
1240 // these lines remove all slashes and dots before and after the path
1241 $path=ereg_replace('^[\/\. ]*','',$path);
1242 $path=trim(ereg_replace('[\/\. ]*$','',$path));
1243
1244
1245 if ($path) { // there must be some chars in the path
1246 $fdir=PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; // fileadmin dir, absolute
1247 if ($webspace) {
1248 $path=$fdir.$path; // PATH_site + fileadmin dir is prepended
1249 } else {
1250 if ($this->OS!='WIN') { // with WINDOWS no prepending!!
1251 $path='/'.$path; // root-level is the start...
1252 }
1253 }
1254 $path.='/';
1255
1256 // We now have a path with slash after and slash before (if unix)
1257 if (@is_dir($path) &&
1258 (($GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] && t3lib_div::isFirstPartOfStr($path,$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'])) || t3lib_div::isFirstPartOfStr($path,$fdir))) {
1259 // Alternative title?
1260 $name = $title ? $title : $altTitle;
1261 // Adds the filemount. The same filemount with same name, type and path cannot be set up twice because of the hash string used as key.
1262 $this->groupData['filemounts'][md5($name.'|'.$path.'|'.$type)] = Array('name'=>$name, 'path'=>$path, 'type'=>$type);
1263 // Return true - went well, success!
1264 return 1;
1265 }
1266 }
1267 }
1268 }
1269
1270 /**
1271 * Creates a TypoScript comment with the string text inside.
1272 *
1273 * @param string The text to wrap in comment prefixes and delimiters.
1274 * @return string TypoScript comment with the string text inside.
1275 */
1276 function addTScomment($str) {
1277 $delimiter = '# ***********************************************';
1278
1279 $out = $delimiter.chr(10);
1280 $lines = t3lib_div::trimExplode(chr(10),$str);
1281 foreach($lines as $v) {
1282 $out.= '# '.$v.chr(10);
1283 }
1284 $out.= $delimiter.chr(10);
1285 return $out;
1286 }
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299 /************************************
1300 *
1301 * Workspaces
1302 *
1303 ************************************/
1304
1305 /**
1306 * Initializing workspace.
1307 * Called from within this function, see fetchGroupData()
1308 *
1309 * @return void
1310 * @see fetchGroupData()
1311 */
1312 function workspaceInit() {
1313
1314 // Initializing workspace by evaluating and setting the workspace, possibly updating it in the user record!
1315 $this->setWorkspace($this->user['workspace_id']);
1316
1317 // Setting up the db mount points of the (custom) workspace, if any:
1318 if ($this->workspace>0 && $this->workspaceRec['db_mountpoints']!=='') {
1319
1320 // Initialize:
1321 $newMounts = array();
1322 $readPerms = '1=1'; // Notice: We cannot call $this->getPagePermsClause(1); as usual because the group-list is not available at this point. But bypassing is fine because all we want here is check if the workspace mounts are inside the current webmounts rootline. The actual permission checking on page level is done elsewhere as usual anyway before the page tree is rendered.
1323
1324 // Traverse mount points of the
1325 $mountPoints = t3lib_div::intExplode(',',$this->workspaceRec['db_mountpoints']);
1326 foreach($mountPoints as $mpId) {
1327 if ($this->isInWebMount($mpId,$readPerms)) {
1328 $newMounts[] = $mpId;
1329 }
1330 }
1331
1332 // Re-insert webmounts:
1333 $this->groupData['webmounts'] = implode(',',array_unique($newMounts));
1334 }
1335
1336 // Setting up the file mount points of the (custom) workspace, if any:
1337 if ($this->workspace!==0) $this->groupData['filemounts'] = array();
1338 if ($this->workspace>0 && $this->workspaceRec['file_mountpoints']!=='') {
1339
1340 // Processing filemounts
1341 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_filemounts', 'deleted=0 AND hidden=0 AND pid=0 AND uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->workspaceRec['file_mountpoints']).')');
1342 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1343 $this->addFileMount($row['title'], $row['path'], $row['path'], $row['base']?1:0, '');
1344 }
1345 }
1346 }
1347
1348 /**
1349 * Checking if a workspace is allowed for backend user
1350 *
1351 * @param mixed If integer, workspace record is looked up, if array it is seen as a Workspace record with at least uid, title, members and adminusers columns. Can be faked for workspaces uid 0 and -1 (online and offline)
1352 * @param string List of fields to select. Default fields are: uid,title,adminusers,members,reviewers,publish_access,stagechg_notification
1353 * @return array TRUE if access. Output will also show how access was granted. Admin users will have a true output regardless of input.
1354 */
1355 function checkWorkspace($wsRec,$fields='uid,title,adminusers,members,reviewers,publish_access,stagechg_notification') {
1356
1357 // If not array, look up workspace record:
1358 if (!is_array($wsRec)) {
1359 switch((string)$wsRec) {
1360 case '0':
1361 case '-1':
1362 $wsRec = array('uid' => $wsRec);
1363 break;
1364 default:
1365 list($wsRec) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
1366 $fields,
1367 'sys_workspace',
1368 'pid=0 AND uid='.intval($wsRec).
1369 t3lib_BEfunc::deleteClause('sys_workspace'),
1370 '',
1371 'title'
1372 );
1373 break;
1374 }
1375 }
1376
1377 // If wsRec is set to an array, evaluate it:
1378 if (is_array($wsRec)) {
1379 if ($this->isAdmin()) {
1380 return array_merge($wsRec,array('_ACCESS' => 'admin'));
1381 } else {
1382
1383 switch((string)$wsRec['uid']) {
1384 case '0':
1385 return ($this->groupData['workspace_perms']&1) ? array_merge($wsRec,array('_ACCESS' => 'online')) : FALSE;
1386 break;
1387 case '-1':
1388 return ($this->groupData['workspace_perms']&2) ? array_merge($wsRec,array('_ACCESS' => 'offline')) : FALSE;
1389 break;
1390 default:
1391 // Checking if the guy is admin:
1392 if (t3lib_div::inList($wsRec['adminusers'],$this->user['uid'])) {
1393 return array_merge($wsRec, array('_ACCESS' => 'owner'));
1394 }
1395 // Checking if he is reviewer user:
1396 if (t3lib_div::inList($wsRec['reviewers'],'be_users_'.$this->user['uid'])) {
1397 return array_merge($wsRec, array('_ACCESS' => 'reviewer'));
1398 }
1399 // Checking if he is reviewer through a user group of his:
1400 foreach($this->userGroupsUID as $groupUid) {
1401 if (t3lib_div::inList($wsRec['reviewers'],'be_groups_'.$groupUid)) {
1402 return array_merge($wsRec, array('_ACCESS' => 'reviewer'));
1403 }
1404 }
1405 // Checking if he is member as user:
1406 if (t3lib_div::inList($wsRec['members'],'be_users_'.$this->user['uid'])) {
1407 return array_merge($wsRec, array('_ACCESS' => 'member'));
1408 }
1409 // Checking if he is member through a user group of his:
1410 foreach($this->userGroupsUID as $groupUid) {
1411 if (t3lib_div::inList($wsRec['members'],'be_groups_'.$groupUid)) {
1412 return array_merge($wsRec, array('_ACCESS' => 'member'));
1413 }
1414 }
1415 break;
1416 }
1417 }
1418 }
1419
1420 return FALSE;
1421 }
1422
1423 /**
1424 * Uses checkWorkspace() to check if current workspace is available for user. This function caches the result and so can be called many times with no performance loss.
1425 *
1426 * @return array See checkWorkspace()
1427 * @see checkWorkspace()
1428 */
1429 function checkWorkspaceCurrent() {
1430 if (!isset($this->checkWorkspaceCurrent_cache)) {
1431 $this->checkWorkspaceCurrent_cache = $this->checkWorkspace($this->workspace);
1432 }
1433 return $this->checkWorkspaceCurrent_cache;
1434 }
1435
1436 /**
1437 * Setting workspace ID
1438 *
1439 * @param integer ID of workspace to set for backend user. If not valid the default workspace for BE user is found and set.
1440 * @return void
1441 */
1442 function setWorkspace($workspaceId) {
1443
1444 // Check workspace validity and if not found, revert to default workspace.
1445 if ($this->workspaceRec = $this->checkWorkspace($workspaceId,'*')) {
1446 // Set workspace ID internally
1447 $this->workspace = (int)$workspaceId;
1448 } else {
1449 $this->workspace = (int)$this->getDefaultWorkspace();
1450 $this->workspaceRec = $this->checkWorkspace($this->workspace,'*');
1451 }
1452
1453 // Unset access cache:
1454 unset($this->checkWorkspaceCurrent_cache);
1455
1456 // If ID is different from the stored one, change it:
1457 if (strcmp($this->workspace, $this->user['workspace_id'])) {
1458 $this->user['workspace_id'] = $this->workspace;
1459 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users','uid='.intval($this->user['uid']),array('workspace_id' => $this->user['workspace_id']));
1460 $this->simplelog('User changed workspace to "'.$this->workspace.'"');
1461 }
1462 }
1463
1464 /**
1465 * Setting workspace preview state for user:
1466 *
1467 * @param boolean State
1468 * @return void
1469 */
1470 function setWorkspacePreview($previewState) {
1471 $this->user['workspace_preview'] = $previewState;
1472 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users','uid='.intval($this->user['uid']),array('workspace_preview' => $this->user['workspace_preview']));
1473 }
1474
1475 /**
1476 * Return default workspace ID for user
1477 *
1478 * @return integer Default workspace id. If no workspace is available it will be "-99"
1479 */
1480 function getDefaultWorkspace() {
1481
1482 if ($this->checkWorkspace(0)) { // Check online
1483 return 0;
1484 } elseif ($this->checkWorkspace(-1)) { // Check offline
1485 return -1;
1486 } else { // Traverse custom workspaces:
1487 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
1488 foreach($workspaces as $rec) {
1489 if ($this->checkWorkspace($rec)) {
1490 return $rec['uid'];
1491 }
1492 }
1493 }
1494 return -99;
1495 }
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507 /************************************
1508 *
1509 * Logging
1510 *
1511 ************************************/
1512
1513 /**
1514 * Writes an entry in the logfile/table
1515 * Documentation in "TYPO3 Core API"
1516 *
1517 * @param integer Denotes which module that has submitted the entry. See "TYPO3 Core API". Use "4" for extensions.
1518 * @param integer Denotes which specific operation that wrote the entry. Use "0" when no sub-categorizing applies
1519 * @param integer Flag. 0 = message, 1 = error (user problem), 2 = System Error (which should not happen), 3 = security notice (admin)
1520 * @param integer The message number. Specific for each $type and $action. This will make it possible to translate errormessages to other languages
1521 * @param string Default text that follows the message (in english!). Possibly translated by identification through type/action/details_nr
1522 * @param array Data that follows the log. Might be used to carry special information. If an array the first 5 entries (0-4) will be sprintf'ed with the details-text
1523 * @param string Table name. Special field used by tce_main.php.
1524 * @param integer Record UID. Special field used by tce_main.php.
1525 * @param integer Record PID. Special field used by tce_main.php. OBSOLETE
1526 * @param integer The page_uid (pid) where the event occurred. Used to select log-content for specific pages.
1527 * @param string Special field used by tce_main.php. NEWid string of newly created records.
1528 * @param integer Alternative Backend User ID (used for logging login actions where this is not yet known).
1529 * @return integer Log entry ID.
1530 */
1531 function writelog($type,$action,$error,$details_nr,$details,$data,$tablename='',$recuid='',$recpid='',$event_pid=-1,$NEWid='',$userId=0) {
1532
1533 $fields_values = Array (
1534 'userid' => $userId ? $userId : intval($this->user['uid']),
1535 'type' => intval($type),
1536 'action' => intval($action),
1537 'error' => intval($error),
1538 'details_nr' => intval($details_nr),
1539 'details' => $details,
1540 'log_data' => serialize($data),
1541 'tablename' => $tablename,
1542 'recuid' => intval($recuid),
1543 # 'recpid' => intval($recpid),
1544 'IP' => t3lib_div::getIndpEnv('REMOTE_ADDR'),
1545 'tstamp' => $GLOBALS['EXEC_TIME'],
1546 'event_pid' => intval($event_pid),
1547 'NEWid' => $NEWid,
1548 'workspace' => $this->workspace
1549 );
1550
1551 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_log', $fields_values);
1552 return $GLOBALS['TYPO3_DB']->sql_insert_id();
1553 }
1554
1555 /**
1556 * Simple logging function
1557 *
1558 * @param string Log message
1559 * @param string Option extension key / module name
1560 * @param integer Error level. 0 = message, 1 = error (user problem), 2 = System Error (which should not happen), 3 = security notice (admin)
1561 * @return integer Log entry UID
1562 */
1563 function simplelog($message, $extKey='', $error=0) {
1564 return $this->writelog(
1565 4,
1566 0,
1567 $error,
1568 0,
1569 ($extKey?'['.$extKey.'] ':'').$message,
1570 array()
1571 );
1572 }
1573
1574 /**
1575 * Sends a warning to $email if there has been a certain amount of failed logins during a period.
1576 * If a login fails, this function is called. It will look up the sys_log to see if there has been more than $max failed logins the last $secondsBack seconds (default 3600). If so, an email with a warning is sent to $email.
1577 *
1578 * @param string Email address
1579 * @param integer Number of sections back in time to check. This is a kind of limit for how many failures an hour for instance.
1580 * @param integer Max allowed failures before a warning mail is sent
1581 * @return void
1582 * @access private
1583 */
1584 function checkLogFailures($email, $secondsBack=3600, $max=3) {
1585
1586 if ($email) {
1587
1588 // get last flag set in the log for sending
1589 $theTimeBack = time()-$secondsBack;
1590 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1591 'tstamp',
1592 'sys_log',
1593 'type=255 AND action=4 AND tstamp>'.intval($theTimeBack),
1594 '',
1595 'tstamp DESC',
1596 '1'
1597 );
1598 if ($testRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1599 $theTimeBack = $testRow['tstamp'];
1600 }
1601
1602 // Check for more than $max number of error failures with the last period.
1603 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1604 '*',
1605 'sys_log',
1606 'type=255 AND action=3 AND error!=0 AND tstamp>'.intval($theTimeBack),
1607 '',
1608 'tstamp'
1609 );
1610 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > $max) {
1611 // OK, so there were more than the max allowed number of login failures - so we will send an email then.
1612 $subject = 'TYPO3 Login Failure Warning (at '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].')';
1613 $email_body = '
1614 There has been numerous attempts ('.$GLOBALS['TYPO3_DB']->sql_num_rows($res).') to login at the TYPO3
1615 site "'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].'" ('.t3lib_div::getIndpEnv('HTTP_HOST').').
1616
1617 This is a dump of the failures:
1618
1619 ';
1620 while($testRows = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1621 $theData = unserialize($testRows['log_data']);
1622 $email_body.=date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' H:i',$testRows['tstamp']).': '.@sprintf($testRows['details'],''.$theData[0],''.$theData[1],''.$theData[2]);
1623 $email_body.=chr(10);
1624 }
1625 mail( $email,
1626 $subject,
1627 $email_body,
1628 'From: TYPO3 Login WARNING<>'
1629 );
1630 $this->writelog(255,4,0,3,'Failure warning (%s failures within %s seconds) sent by email to %s',Array($GLOBALS['TYPO3_DB']->sql_num_rows($res),$secondsBack,$email)); // Logout written to log
1631 }
1632 }
1633 }
1634 }
1635
1636
1637
1638 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_userauthgroup.php']) {
1639 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_userauthgroup.php']);
1640 }
1641 ?>