Fixed bug #10497: Mark t3lib_div::makeInstanceClassName() as deprecated
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / mod / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 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 * Backend User Administration Module
29 *
30 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
31 */
32 /**
33 * [CLASS/FUNCTION INDEX of SCRIPT]
34 *
35 *
36 *
37 * 129: class localPageTree extends t3lib_browseTree
38 * 140: function localPageTree($BE_USER,$WEBMOUNTS='')
39 * 154: function ext_permsC()
40 * 165: function wrapTitle($str,$row)
41 * 177: function PM_ATagWrap($icon,$cmd,$bMark='')
42 * 188: function wrapIcon($icon,$row)
43 * 201: function initializePositionSaving()
44 *
45 *
46 * 222: class printAllPageTree extends localPageTree
47 * 231: function ext_permsC()
48 * 243: function PM_ATagWrap($icon,$cmd,$bMark='')
49 * 254: function wrapIcon($icon,$row)
50 *
51 *
52 * 279: class printAllPageTree_perms extends printAllPageTree
53 * 288: function printTree($treeArr='',$printPath=0)
54 * 331: function ext_printPerms($int)
55 * 349: function ext_groupPerms($row,$firstGroup)
56 *
57 *
58 * 377: class localFolderTree extends t3lib_folderTree
59 * 388: function localFolderTree($BE_USER,$FILEMOUNTS='')
60 * 403: function wrapTitle($str,$row)
61 * 415: function PM_ATagWrap($icon,$cmd,$bMark='')
62 * 426: function wrapIcon($icon,$row)
63 * 439: function initializePositionSaving()
64 *
65 *
66 * 463: class printAllFolderTree extends localFolderTree
67 * 475: function PM_ATagWrap($icon,$cmd,$bMark='')
68 *
69 *
70 * 497: class local_beUserAuth extends t3lib_beUserAuth
71 * 509: function returnWebmounts($pClause='')
72 * 533: function ext_non_readAccessPages()
73 * 556: function user_where_clause()
74 * 568: function ext_printOverview($uInfo,$compareFlags,$printTrees=0)
75 * 838: function ext_getReadableButNonmounted()
76 * 873: function ext_printPerms($int)
77 * 891: function ext_groupPerms($row,$firstGroup)
78 * 907: function ext_compileUserInfoForHash($filter=NULL)
79 * 1007: function ext_uniqueAndSortList($list)
80 * 1021: function ext_ksortArrayRecursive(&$arr)
81 * 1034: function ext_workspaceMembership()
82 *
83 *
84 * 1088: class SC_mod_tools_be_user_index
85 * 1100: function init()
86 * 1128: function menuConfig()
87 * 1149: function main()
88 * 1185: function printContent()
89 *
90 * SECTION: OTHER FUNCTIONS:
91 * 1207: function compareUsers($compareFlags)
92 * 1394: function linkUser($str,$rec)
93 * 1405: function elementLinks($table,$row)
94 * 1436: function initUsers()
95 * 1456: function localPath($str)
96 * 1468: function switchUser($switchUser)
97 *
98 * TOTAL FUNCTIONS: 39
99 * (This index is automatically created/updated by the extension "extdeveval")
100 *
101 */
102
103 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
104 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
105 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
106 require_once (PATH_t3lib.'class.t3lib_tstemplate.php');
107 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
108 require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php');
109 require_once (PATH_typo3.'class.alt_menu_functions.inc');
110
111 $GLOBALS['LANG']->includeLLFile('EXT:beuser/mod/locallang.xml');
112
113 $BE_USER->modAccess($MCONF,1);
114
115
116
117
118
119
120 /**
121 * Base Extension class for printing a page tree (non-browsable though)
122 *
123 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
124 * @package TYPO3
125 * @subpackage tx_beuser
126 */
127 class localPageTree extends t3lib_browseTree {
128 var $expandFirst=0;
129 var $expandAll=0;
130
131 /**
132 * Local backend user (not the GLOBALS[] backend user!!)
133 *
134 * @var t3lib_beUserAuth
135 */
136 var $BE_USER;
137
138 /**
139 * Constructor for the local page tree.
140 *
141 * @param object Local backend user (not the GLOBALS[] backend user!!)
142 * @param array Webmounts for the backend user.
143 * @return void
144 */
145 function localPageTree($BE_USER,$WEBMOUNTS='') {
146 $this->init();
147
148 $this->BE_USER = $BE_USER;
149 $this->MOUNTS = $WEBMOUNTS;
150 $this->clause = $this->ext_permsC(); // Notice, this clause does NOT filter out un-readable pages. This is the POINT since this class is ONLY used for the main overview where ALL is shown! Otherwise "AND '.$this->BE_USER->getPagePermsClause(1).'" should be added.
151 $this->orderByFields = 'sorting';
152 }
153
154 /**
155 * Return select permissions.
156 *
157 * @return string WHERE query part.
158 */
159 function ext_permsC() {
160 return '';
161 }
162
163 /**
164 * Wraps the title.
165 *
166 * @param string [See parent]
167 * @param array [See parent]
168 * @return string
169 */
170 function wrapTitle($str,$row) {
171 return $str;
172 }
173
174 /**
175 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon!
176 *
177 * @param string [See parent]
178 * @param string [See parent]
179 * @param string [See parent]
180 * @return string
181 */
182 function PM_ATagWrap($icon,$cmd,$bMark='') {
183 return '';
184 }
185
186 /**
187 * Wrapping the icon of the element/page. Normally a click menu is wrapped around the icon, but in this case only a title parameter is set.
188 *
189 * @param string Icon image tag.
190 * @param array Row.
191 * @return string Icon with title attribute added.
192 */
193 function wrapIcon($icon,$row) {
194 // Add title attribute to input icon tag
195 $title = '['.$row['uid'].'] '.t3lib_BEfunc::getRecordPath($row['uid'],'',15);
196 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"');
197
198 return $theIcon;
199 }
200
201 /**
202 * This will make sure that no position data is acquired from the BE_USER uc variable.
203 *
204 * @return void
205 */
206 function initializePositionSaving() {
207 $this->stored=array();
208 }
209 }
210
211
212
213
214
215
216
217
218
219
220 /**
221 * Extension class for printing a page tree: All pages of a mount point.
222 *
223 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
224 * @package TYPO3
225 * @subpackage tx_beuser
226 */
227 class printAllPageTree extends localPageTree {
228 var $expandFirst=1;
229 var $expandAll=1;
230
231 /**
232 * Return select permissions.
233 *
234 * @return string WHERE query part.
235 */
236 function ext_permsC() {
237 return ' AND '.$this->BE_USER->getPagePermsClause(1);
238 }
239
240 /**
241 * Returns the plus/minus icon.
242 *
243 * @param string [See parent]
244 * @param string [See parent]
245 * @param string [See parent]
246 * @return string
247 */
248 function PM_ATagWrap($icon,$cmd,$bMark='') {
249 return $icon;
250 }
251
252 /**
253 * Wrapping the icon of the element/page. Normally a click menu is wrapped around the icon, but in this case only a title parameter is set.
254 *
255 * @param string Icon image tag.
256 * @param array Row.
257 * @return string Icon with title attribute added.
258 */
259 function wrapIcon($icon,$row) {
260 // Add title attribute to input icon tag
261 $title = '['.$row['uid'].']';
262 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : '').' border="0"');
263
264 return $theIcon;
265 }
266 }
267
268
269
270
271
272
273
274
275
276
277 /**
278 * Extension class for printing a page tree: Printing all pages, with permissions.
279 *
280 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
281 * @package TYPO3
282 * @subpackage tx_beuser
283 */
284 class printAllPageTree_perms extends printAllPageTree {
285
286 /**
287 * Print the tree of pages.
288 *
289 * @param array The tree items
290 * @param boolean If set, the path of the pages in the tree is printed (only done for pages outside of mounts).
291 * @return string HTML content.
292 */
293 function printTree($treeArr='',$printPath=0) {
294 $titleLen=intval($this->BE_USER->uc['titleLen']);
295
296 $be_user_Array = t3lib_BEfunc::getUserNames();
297 $be_group_Array = t3lib_BEfunc::getGroupNames();
298 $lines=array();
299 $lines[]='<tr class="bgColor5">
300 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('pageTitle', true) . '</strong></td>
301 ' . ($printPath?'<td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('path', true) . '</strong></td>':'') . '
302 <td nowrap="nowrap" colspan="2"><strong>' . $GLOBALS['LANG']->getLL('user', true) . '</strong></td>
303 <td nowrap="nowrap" colspan="2"><strong>' . $GLOBALS['LANG']->getLL('group', true) . ' &nbsp;</strong></td>
304 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('everybody', true) . ' &nbsp;</strong></td>
305 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('thisUser', true) . ' &nbsp;</strong></td>
306 <td nowrap="nowrap"><strong>' . $GLOBALS['LANG']->getLL('mainGroup', true) . '</strong></td>
307 </tr>';
308
309 if (!is_array($treeArr)) {
310 $treeArr = $this->tree;
311 }
312 foreach ($treeArr as $v) {
313 $col1 = ' bgcolor="'.t3lib_div::modifyHtmlColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"';
314 $row = $v['row'];
315 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$this->BE_USER->uc['titleLen']));
316 $lines[]='<tr class="bgColor4">
317 <td nowrap="nowrap">'.$v['HTML'].$title.' &nbsp;</td>
318 '.($printPath?'<td nowrap="nowrap">'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row['pid'],'',15)).' &nbsp;</td>':'').'
319 <td nowrap="nowrap"'.$col1.'>'.$be_user_Array[$row['perms_userid']]['username'].' &nbsp;</td>
320 <td nowrap="nowrap"'.$col1.'>'.$this->ext_printPerms($row['perms_user']).' &nbsp;</td>
321 <td nowrap="nowrap">'.$be_group_Array[$row['perms_groupid']]['title'].' &nbsp;</td>
322 <td nowrap="nowrap">'.$this->ext_printPerms($row['perms_group']).' &nbsp;</td>
323 <td nowrap="nowrap" align="center" '.$col1.'>'.$this->ext_printPerms($row['perms_everybody']).' &nbsp;</td>
324 <td nowrap="nowrap" align="center">' . ($row['editlock'] ? '<img ' . t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning2.gif') . ' title="' . $GLOBALS['LANG']->getLL('editLock', true) . '" alt="" />' : $this->ext_printPerms($this->BE_USER->calcPerms($row))) . ' &nbsp;</td>
325 <td nowrap="nowrap" align="center">'.$this->ext_printPerms($this->ext_groupPerms($row,$be_group_Array[$this->BE_USER->firstMainGroup])).' &nbsp;</td>
326 </tr>';
327 }
328 return '<table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table>';
329 }
330
331 /**
332 * Print a set of permissions
333 *
334 * @param integer The permissions integer.
335 * @return string HTML formatted.
336 */
337 function ext_printPerms($int) {
338 $str='';
339 $str.= (($int&1)?'*':'<font color="red">x</font>');
340 $str.= (($int&16)?'*':'<font color="red">x</font>');
341 $str.= (($int&2)?'*':'<font color="red">x</font>');
342 $str.= (($int&4)?'*':'<font color="red">x</font>');
343 $str.= (($int&8)?'*':'<font color="red">x</font>');
344
345 return '<b><font color="green">'.$str.'</font></b>';
346 }
347
348 /**
349 * returns the permissions for a group based of the perms_groupid of $row. If the $row[perms_groupid] equals the $firstGroup[uid] then the function returns perms_everybody OR'ed with perms_group, else just perms_everybody
350 *
351 * @param array Page record.
352 * @param array First-group record.
353 * @return integer Permissions.
354 */
355 function ext_groupPerms($row,$firstGroup) {
356 if (is_array($row)) {
357 $out=intval($row['perms_everybody']);
358 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
359 $out|= intval($row['perms_group']);
360 }
361 return $out;
362 }
363 }
364 }
365
366
367
368
369
370
371
372
373
374
375
376 /**
377 * Base Extension class for printing a folder tree (non-browsable though)
378 *
379 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
380 * @package TYPO3
381 * @subpackage tx_beuser
382 */
383 class localFolderTree extends t3lib_folderTree {
384 var $expandFirst=0;
385 var $expandAll=0;
386
387 /**
388 * Local backend user (not the GLOBALS[] backend user!!)
389 *
390 * @var t3lib_beUserAuth
391 */
392 var $BE_USER;
393
394 /**
395 * Constructor for the local folder tree.
396 *
397 * @param object Local backend user (not the GLOBALS[] backend user!!)
398 * @param array Filemounts for the backend user.
399 * @return void
400 */
401 function localFolderTree($BE_USER,$FILEMOUNTS='') {
402 $this->init();
403
404 $this->BE_USER = $BE_USER;
405 $this->MOUNTS = $FILEMOUNTS;
406 $this->clause = ''; // Notice, this clause does NOT filter out un-readable pages. This is the POINT since this class is ONLY used for the main overview where ALL is shown! Otherwise "AND '.$this->BE_USER->getPagePermsClause(1).'" should be added.
407 }
408
409 /**
410 * Wraps the title.
411 *
412 * @param string [See parent]
413 * @param array [See parent]
414 * @return string
415 */
416 function wrapTitle($str,$row) {
417 return $str;
418 }
419
420 /**
421 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon!
422 *
423 * @param string [See parent]
424 * @param string [See parent]
425 * @param string [See parent]
426 * @return string
427 */
428 function PM_ATagWrap($icon,$cmd,$bMark='') {
429 return '';
430 }
431
432 /**
433 * Wrapping the icon of the element/page. Normally a click menu is wrapped around the icon, but in this case only a title parameter is set.
434 *
435 * @param string Icon image tag.
436 * @param array Row.
437 * @return string Icon with title attribute added.
438 */
439 function wrapIcon($icon,$row) {
440 // Add title attribute to input icon tag
441 $title = $GLOBALS['SOBE']->localPath($row['path']);
442 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : ''));
443
444 return $theIcon;
445 }
446
447 /**
448 * This will make sure that no position data is acquired from the BE_USER uc variable.
449 *
450 * @return void
451 */
452 function initializePositionSaving() {
453 $this->stored=array();
454 }
455 }
456
457
458
459
460
461
462
463
464
465
466
467
468
469 /**
470 * Extension class for printing a folder tree: All folders
471 *
472 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
473 * @package TYPO3
474 * @subpackage tx_beuser
475 */
476 class printAllFolderTree extends localFolderTree {
477 var $expandFirst=1;
478 var $expandAll=1;
479
480 /**
481 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon!
482 *
483 * @param string [See parent]
484 * @param string [See parent]
485 * @param string [See parent]
486 * @return string
487 */
488 function PM_ATagWrap($icon,$cmd,$bMark='') {
489 return $icon;
490 }
491 }
492
493
494
495
496
497
498
499
500
501
502
503 /**
504 * Extension class of beuserauth class.
505 *
506 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
507 * @package TYPO3
508 * @subpackage tx_beuser
509 */
510 class local_beUserAuth extends t3lib_beUserAuth {
511 var $ext_pageIdsFromMounts=''; // List of mounted page ids (from browsetree class when selecting mountpoints)
512 var $ext_non_readAccessPageArray=array(); // Storage for non-readable webmounts, see returnWebmounts()
513
514 /**
515 * Returns an array of the webmounts for the user, with non-readable webmounts filtered out.
516 * If there are non-readable webmounts they are registered in $this->ext_non_readAccessPageArray
517 * (Extending function in parent class)
518 *
519 * @param string alternative select clause (default is getPagePermsClause(1)). For instance to make sure that ALL webmounts are selected regardless of whether the user has read access or not, you can set this to "1=1".
520 * @return array Webmounts id's
521 */
522 function returnWebmounts($pClause='') {
523
524 // Get array of webmounts:
525 $webmounts = (string)($this->groupData['webmounts'])!='' ? explode(',',$this->groupData['webmounts']) : Array();
526
527 // Get select clause:
528 $pClause=$pClause?$pClause:$this->getPagePermsClause(1);
529
530 // Traverse mounts, check if they are readable:
531 foreach ($webmounts as $k => $id) {
532 $rec=t3lib_BEfunc::getRecord('pages',$id,'*',' AND '.$pClause);
533 if (!is_array($rec)) {
534 $this->ext_non_readAccessPageArray[$id]=t3lib_BEfunc::getRecord('pages',$id);
535 unset($webmounts[$k]);
536 }
537 }
538 return $webmounts;
539 }
540
541 /**
542 * Based on the content of ->ext_non_readAccessPageArray (see returnWebmounts()) it generates visually formatted information about these non-readable mounts.
543 *
544 * @return string HTML content showing which DB-mounts were not accessible for the user
545 */
546 function ext_non_readAccessPages() {
547 $lines=array();
548
549 foreach ($this->ext_non_readAccessPageArray as $pA) {
550 if ($pA) {
551 $lines[] = t3lib_BEfunc::getRecordPath($pA['uid'],'',15);
552 }
553 }
554 if (count($lines)) {
555 return '<table bgcolor="red" border="0" cellpadding="0" cellspacing="0">
556 <tr>
557 <td align="center"><font color="white"><strong>' . $GLOBALS['LANG']->getLL('noReadAccess', true) . '</strong></font></td>
558 </tr>
559 <tr>
560 <td>'.implode('</td></tr><tr><td>',$lines).'</td>
561 </tr>
562 </table>';
563 }
564 }
565
566 /**
567 * This returns the where-clause needed to select the user with respect flags like deleted, hidden, starttime, endtime
568 *
569 * @return string
570 */
571 function user_where_clause() {
572 return 'AND pid=0 ';
573 }
574
575 /**
576 * Creates the overview information based on which analysis topics were selected.
577 *
578 * @param array Array of analysis topics
579 * @param array Array of the selected analysis topics (from session variable somewhere)
580 * @param boolean If set, the full trees of pages/folders are printed.
581 * @return array Array with accumulated HTML content.
582 */
583 function ext_printOverview($uInfo,$compareFlags,$printTrees=0) {
584 // Prepare for filemount and db-mount
585 if ($printTrees) { // ... this is if we see the detailed view for a user:
586 // Page tree object:
587 $pagetree = t3lib_div::makeInstance(!$this->isAdmin() ? 'printAllPageTree_perms' : 'printAllPageTree', $this, $this->returnWebmounts()); // Here, only readable webmounts are returned (1=1)
588 $pagetree->addField('perms_user',1);
589 $pagetree->addField('perms_group',1);
590 $pagetree->addField('perms_everybody',1);
591 $pagetree->addField('perms_userid',1);
592 $pagetree->addField('perms_groupid',1);
593 $pagetree->addField('editlock',1);
594
595 // Folder tree object:
596 $foldertree = t3lib_div::makeInstance('printAllFolderTree', $this, $this->returnFilemounts());
597 } else {
598 // Page tree object:
599 $pagetree = t3lib_div::makeInstance('localPageTree', $this, $this->returnWebmounts('1=1')); // Here, ALL webmounts are returned (1=1)
600
601 // Folder tree object:
602 $foldertree = t3lib_div::makeInstance('localFolderTree', $this, $this->returnFilemounts());
603 }
604
605 // Names for modules:
606 $modNames = array(
607 'web' => 'Web',
608 'web_layout' => 'Page',
609 'web_modules' => 'Modules',
610 'web_info' => 'Info',
611 'web_perms' => 'Access',
612 'web_func' => 'Func',
613 'web_list' => 'List',
614 'web_ts' => 'Template',
615 'file' => 'File',
616 'file_list' => 'List',
617 'file_images' => 'Images',
618 'doc' => 'Doc.',
619 'help' => 'Help',
620 'help_about' => 'About',
621 'help_quick' => 'User manual',
622 'help_welcome' => 'Welcome',
623 'user' => 'User',
624 'user_setup' => 'Setup',
625 'user_task' => 'Task center'
626 );
627
628 // Traverse the enabled analysis topics:
629 $out=array();
630 foreach ($uInfo as $k => $v) {
631 if ($compareFlags[$k]) {
632 switch($k) {
633 case 'filemounts':
634 $out[$k] = $foldertree->getBrowsableTree();
635 break;
636 case 'webmounts':
637 // Print webmounts:
638 $pagetree->addSelfId=1;
639 $out[$k] = $this->ext_non_readAccessPages(); // Add HTML for non-readable webmounts (only shown when viewing details of a user - in overview/comparison ALL mounts are shown)
640 $out[$k].= $pagetree->getBrowsableTree(); // Add HTML for readable webmounts.
641 $this->ext_pageIdsFromMounts=implode(',',array_unique($pagetree->ids)); // List of mounted page ids
642 break;
643 case 'tempPath':
644 $out[$k] = $GLOBALS['SOBE']->localPath($v);
645 break;
646 case 'pagetypes_select':
647 $pageTypes = explode(',',$v);
648 foreach ($pageTypes as &$vv) {
649 $vv = $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('pages','doktype',$vv));
650 }
651 $out[$k] = implode('<br />',$pageTypes);
652 break;
653 case 'tables_select':
654 case 'tables_modify':
655 $tables = explode(',',$v);
656 foreach ($tables as &$vv) {
657 if ($vv) {
658 $vv = '<span class="nobr">'.t3lib_iconWorks::getIconImage($vv,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>';
659 }
660 }
661 $out[$k] = implode('<br />',$tables);
662 break;
663 case 'non_exclude_fields':
664 $nef = explode(',',$v);
665 $table='';
666 $pout=array();
667 foreach ($nef as $vv) {
668 if ($vv) {
669 list($thisTable,$field) = explode(':',$vv);
670 if ($thisTable!=$table) {
671 $table=$thisTable;
672 t3lib_div::loadTCA($table);
673 $pout[]='<span class="nobr">'.t3lib_iconWorks::getIconImage($table,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']).'</span>';
674 }
675 if ($GLOBALS['TCA'][$table]['columns'][$field]) {
676 $pout[]='<span class="nobr"> - '.ereg_replace(':$','',$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label'])).'</span>';
677 }
678 }
679 }
680 $out[$k] = implode('<br />',$pout);
681 break;
682 case 'groupList':
683 case 'firstMainGroup':
684 $uGroups = explode(',',$v);
685 $table='';
686 $pout=array();
687 foreach ($uGroups as $vv) {
688 if ($vv) {
689 $uGRow = t3lib_BEfunc::getRecord('be_groups',$vv);
690 $pout[]='<tr><td nowrap="nowrap">'.t3lib_iconWorks::getIconImage('be_groups',$uGRow,$GLOBALS['BACK_PATH'],'align="top"').'&nbsp;'.htmlspecialchars($uGRow['title']).'&nbsp;&nbsp;</td><td width=1% nowrap="nowrap">'.$GLOBALS['SOBE']->elementLinks('be_groups',$uGRow).'</td></tr>';
691 }
692 }
693 $out[$k] = '<table border="0" cellpadding="0" cellspacing="0" width="100%">'.implode('',$pout).'</table>';
694 break;
695 case 'modules':
696 $mods = explode(',',$v);
697 $mainMod='';
698 $pout=array();
699 foreach ($mods as $vv) {
700 if ($vv) {
701 list($thisMod,$subMod) = explode('_',$vv);
702 if ($thisMod!=$mainMod) {
703 $mainMod=$thisMod;
704 $pout[]='<span class="nobr">'.($modNames[$mainMod]?$modNames[$mainMod]:$mainMod).'</span>';
705 }
706 if ($subMod) {
707 $pout[]='<span class="nobr"> - '.($modNames[$mainMod.'_'.$subMod]?$modNames[$mainMod.'_'.$subMod]:$mainMod.'_'.$subMod).'</span>';
708 }
709 }
710 }
711 $out[$k] = implode('<br />',$pout);
712 break;
713 case 'userTS':
714
715 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext'); // Defined global here!
716 $tmpl->tt_track = 0; // Do not log time-performance information
717
718 $tmpl->fixedLgd=0;
719 $tmpl->linkObjects=0;
720 $tmpl->bType='';
721 $tmpl->ext_expandAllNotes=1;
722 $tmpl->ext_noPMicons=1;
723 $out[$k] = $tmpl->ext_getObjTree($v,'','','','','1');
724 break;
725 case 'userTS_hl':
726 $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
727 $tsparser->lineNumberOffset=0;
728 $out[$k] = $tsparser->doSyntaxHighlight($v,0,1);
729 break;
730 case 'explicit_allowdeny':
731
732 // Explode and flip values:
733 $nef = array_flip(explode(',',$v));
734 $pout = array();
735
736 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
737
738 // Icons:
739 $icons = array(
740 'ALLOW' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_ok2.gif','').' class="absmiddle" alt="" />',
741 'DENY' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_fatalerror.gif','').' class="absmiddle" alt="" />',
742 );
743
744 // Traverse types:
745 foreach ($theTypes as $tableFieldKey => $theTypeArrays) {
746 if (is_array($theTypeArrays['items'])) {
747 $pout[] = '<b>'.$theTypeArrays['tableFieldLabel'].'</b>';
748 // Traverse options for this field:
749 foreach ($theTypeArrays['items'] as $itemValue => $itemContent) {
750 $v = $tableFieldKey.':'.$itemValue.':'.$itemContent[0];
751 if (isset($nef[$v])) {
752 unset($nef[$v]);
753 $pout[] = $icons[$itemContent[0]].'['.$itemContent[2].'] '.$itemContent[1];
754 } else {
755 $pout[] = '<em style="color: #666666;">'.$icons[($itemContent[0]=='ALLOW' ? 'DENY' : 'ALLOW')].'['.$itemContent[2].'] '.$itemContent[1].'</em>';
756 }
757 }
758 $pout[] = '';
759 }
760 }
761
762 // Add remaining:
763 if (count($nef)) {
764 $pout = array_merge($pout, array_keys($nef));
765 }
766
767 // Implode for display:
768 $out[$k] = implode('<br />',$pout);
769 break;
770 case 'allowed_languages':
771
772 // Explode and flip values:
773 $nef = array_flip(explode(',',$v));
774 $pout = array();
775
776 // Get languages:
777 $items = t3lib_BEfunc::getSystemLanguages();
778
779 // Traverse values:
780 foreach ($items as $iCfg) {
781 if (isset($nef[$iCfg[1]])) {
782 unset($nef[$iCfg[1]]);
783 if (strlen($iCfg[2])) {
784 $icon = '<img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$iCfg[2]).' class="absmiddle" style="margin-right: 5px;" alt="" />';
785 } else {
786 $icon = '';
787 }
788 $pout[] = $icon.$iCfg[0];
789 }
790 }
791
792 // Add remaining:
793 if (count($nef)) {
794 $pout = array_merge($pout, array_keys($nef));
795 }
796
797 // Implode for display:
798 $out[$k] = implode('<br />',$pout);
799 break;
800 case 'workspace_perms':
801 $out[$k] = implode('<br/>',explode(', ',t3lib_BEfunc::getProcessedValue('be_users','workspace_perms',$v)));
802 break;
803 case 'workspace_membership':
804 $out[$k] = implode('<br/>',$this->ext_workspaceMembership());
805 break;
806 case 'custom_options':
807
808 // Explode and flip values:
809 $nef = array_flip(explode(',',$v));
810 $pout = array();
811
812 // Initialize:
813 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
814 if (is_array($customOptions)) {
815 foreach ($customOptions as $coKey => $coValue) {
816 if (is_array($coValue['items'])) {
817 // Traverse items:
818 foreach ($coValue['items'] as $itemKey => $itemCfg) {
819 $v = $coKey.':'.$itemKey;
820 if (isset($nef[$v])) {
821 unset($nef[$v]);
822 $pout[] = $GLOBALS['LANG']->sl($coValue['header']).' / '.$GLOBALS['LANG']->sl($itemCfg[0]);
823 }
824 }
825 }
826 }
827 }
828
829 // Add remaining:
830 if (count($nef)) {
831 $pout = array_merge($pout, array_keys($nef));
832 }
833
834 // Implode for display:
835 $out[$k] = implode('<br />',$pout);
836 break;
837 }
838 }
839 }
840 return $out;
841 }
842
843 /**
844 * Get HTML code for the pages which were mounted, but NOT readable!
845 *
846 * @return string HTML code.
847 */
848 function ext_getReadableButNonmounted() {
849
850 // List of page id mounts which ARE mounted (and should therefore not be selected)
851 if (!$this->ext_pageIdsFromMounts) {
852 $this->ext_pageIdsFromMounts=0;
853 }
854
855 // User and group names:
856 $be_user_Array = t3lib_BEfunc::getUserNames();
857 $be_group_Array = t3lib_BEfunc::getGroupNames();
858
859 // Create query:
860 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
861 'pid,uid,title,doktype,perms_user,perms_group,perms_everybody,perms_userid,perms_groupid'.(t3lib_extMgm::isLoaded('cms')?',media,layout,hidden,starttime,endtime,fe_group,extendToSubpages':''),
862 'pages',
863 'uid NOT IN ('.$this->ext_pageIdsFromMounts.') AND '.$this->getPagePermsClause(1).t3lib_BEfunc::deleteClause('pages')
864 );
865 $dat = array();
866 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
867 $dat[] = array(
868 'row'=>$row,
869 'HTML'=>t3lib_iconWorks::getIconImage('pages',$row,$GLOBALS['BACK_PATH'],'align="top" title="['.$row['uid'].']"') // .htmlspecialchars($row['title'])
870 );
871 }
872 $pp = t3lib_div::makeInstance('printAllPageTree_perms', $this);
873 return $pp->printTree($dat,1);
874 }
875
876 /**
877 * Print a set of permissions
878 *
879 * @param integer The permissions integer.
880 * @return string HTML formatted.
881 */
882 function ext_printPerms($int) {
883 $str='';
884 $str.= (($int&1)?'*':'<font color="red">x</font>');
885 $str.= (($int&16)?'*':'<font color="red">x</font>');
886 $str.= (($int&2)?'*':'<font color="red">x</font>');
887 $str.= (($int&4)?'*':'<font color="red">x</font>');
888 $str.= (($int&8)?'*':'<font color="red">x</font>');
889
890 return '<b><font color="green">'.$str.'</font></b>';
891 }
892
893 /**
894 * returns the permissions for a group based of the perms_groupid of $row. If the $row[perms_groupid] equals the $firstGroup[uid] then the function returns perms_everybody OR'ed with perms_group, else just perms_everybody
895 *
896 * @param array Page record.
897 * @param array First-group record.
898 * @return integer Permissions.
899 */
900 function ext_groupPerms($row,$firstGroup) {
901 if (is_array($row)) {
902 $out=intval($row['perms_everybody']);
903 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
904 $out|= intval($row['perms_group']);
905 }
906 return $out;
907 }
908 }
909
910 /**
911 * Creates uInfo array for the user.
912 *
913 * @param array Might contain array where keys/values indicate whether to render a certain value
914 * @return array Array with the information of the user for each analysis topic.
915 */
916 function ext_compileUserInfoForHash($filter=NULL) {
917 $uInfo=array();
918 $renderAll = !is_array($filter);
919
920 // Filemounts:
921 if ($renderAll || $filter['filemounts']) {
922 $uInfo['filemounts'] = $this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts'])));
923 }
924
925 // DBmounts:
926 if ($renderAll || $filter['webmounts']) {
927 $uInfo['webmounts'] = $this->ext_uniqueAndSortList($this->groupData['webmounts']);
928 }
929
930 // Sharing Upload Folder
931 if ($renderAll || $filter['tempPath']) {
932 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
933 $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
934 $uInfo['tempPath'] = $fileProcessor->findTempFolder(); // The closest TEMP-path is found
935 }
936
937 // First Main Group:
938 if ($renderAll || $filter['firstMainGroup']) {
939 $uInfo['firstMainGroup'] = $this->firstMainGroup;
940 }
941
942 // Group List:
943 if ($renderAll || $filter['groupList']) {
944 $uInfo['groupList'] = $this->groupList; // This gives a list that shows in which order the groups are processed. This may result in a list of groups which is similar to that of another user regarding which group but not the order of groups. For now, I believe it's most usefull to let separate orders of groups appear as different group settings for a user.
945 }
946
947 // Page Types:
948 if ($renderAll || $filter['pagetypes_select']) {
949 $uInfo['pagetypes_select'] = $this->ext_uniqueAndSortList($this->groupData['pagetypes_select']);
950 }
951
952 // Tables select:
953 if ($renderAll || $filter['tables_select']) {
954 $uInfo['tables_select'] = $this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']);
955 }
956
957 // Tables modify:
958 if ($renderAll || $filter['tables_modify']) {
959 $uInfo['tables_modify'] = $this->ext_uniqueAndSortList($this->groupData['tables_modify']);
960 }
961
962 // Non-exclude fields:
963 if ($renderAll || $filter['non_exclude_fields']) {
964 $uInfo['non_exclude_fields'] = $this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']);
965 }
966
967 // Explicit Allow/Deny:
968 if ($renderAll || $filter['explicit_allowdeny']) {
969 $uInfo['explicit_allowdeny'] = $this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']);
970 }
971
972 // Limit to languages:
973 if ($renderAll || $filter['allowed_languages']) {
974 $uInfo['allowed_languages'] = $this->ext_uniqueAndSortList($this->groupData['allowed_languages']);
975 }
976
977 // Workspace permissions
978 if ($renderAll || $filter['workspace_perms']) {
979 $uInfo['workspace_perms'] = $this->ext_uniqueAndSortList($this->groupData['workspace_perms']);
980 }
981
982 // Workspace membership
983 if ($renderAll || $filter['workspace_membership']) {
984 $uInfo['workspace_membership'] = $this->ext_workspaceMembership();
985 }
986
987 // Custom options:
988 if ($renderAll || $filter['custom_options']) {
989 $uInfo['custom_options'] = $this->ext_uniqueAndSortList($this->groupData['custom_options']);
990 }
991
992 // Modules:
993 if ($renderAll || $filter['modules']) {
994 $uInfo['modules'] = $this->ext_uniqueAndSortList($this->groupData['modules']);
995 }
996
997 // User TS:
998 $this->ext_ksortArrayRecursive($this->userTS);
999 if ($renderAll || $filter['userTS']) {
1000 $uInfo['userTS'] = $this->userTS;
1001 }
1002
1003 if ($renderAll || $filter['userTS_hl']) {
1004 $uInfo['userTS_hl'] = $this->userTS_text;
1005 }
1006
1007 return $uInfo;
1008 }
1009
1010 /**
1011 * Sorts a commalist of values and removes duplicates.
1012 *
1013 * @param string Commalist.
1014 * @return string Sorted, unique commalist.
1015 */
1016 function ext_uniqueAndSortList($list) {
1017 $uList=t3lib_div::trimExplode(',',$list,1);
1018 sort($uList);
1019 $uList=array_unique($uList);
1020 $uList=implode(',',$uList);
1021 return $uList;
1022 }
1023
1024 /**
1025 * Key sort input array recursively.
1026 *
1027 * @param array Multidimensional array (value by reference!)
1028 * @return void
1029 */
1030 function ext_ksortArrayRecursive(&$arr) {
1031 krsort($arr);
1032 foreach ($arr as &$v) {
1033 if (is_array($v)) {
1034 $this->ext_ksortArrayRecursive($v);
1035 }
1036 }
1037 }
1038
1039 /**
1040 * Returns all workspaces that are accessible for the BE_USER
1041 *
1042 * @return array with key / value pairs of available workspaces (filtered by BE_USER check)
1043 */
1044 function ext_workspaceMembership() {
1045 // Create accessible workspace arrays:
1046 $options = array();
1047 if ($this->checkWorkspace(array('uid' => 0))) {
1048 $options[0] = '0: ' . $GLOBALS['LANG']->getLL('live', true);
1049 }
1050 if ($this->checkWorkspace(array('uid' => -1))) {
1051 $options[-1] = '-1: ' . $GLOBALS['LANG']->getLL('defaultDraft', true);
1052 }
1053
1054 // Add custom workspaces (selecting all, filtering by BE_USER check):
1055 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers,db_mountpoints','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
1056 if (count($workspaces)) {
1057 foreach ($workspaces as $rec) {
1058 if ($this->checkWorkspace($rec)) {
1059 $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
1060
1061 // Check if all mount points are accessible, otherwise show error:
1062 if (trim($rec['db_mountpoints'])!=='') {
1063 $mountPoints = t3lib_div::intExplode(',',$this->workspaceRec['db_mountpoints'],1);
1064 foreach ($mountPoints as $mpId) {
1065 if (!$this->isInWebMount($mpId,'1=1')) {
1066 $options[$rec['uid']].= '<br> \- ' . $GLOBALS['LANG']->getLL('notAccessible', true) . ' ' . $mpId;
1067 }
1068 }
1069 }
1070 }
1071 }
1072 }
1073
1074 return $options;
1075 }
1076 }
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089 /**
1090 * Main script class
1091 *
1092 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1093 * @package TYPO3
1094 * @subpackage tx_beuser
1095 */
1096 class SC_mod_tools_be_user_index {
1097 var $MCONF=array();
1098 var $MOD_MENU=array();
1099 var $MOD_SETTINGS=array();
1100
1101 /**
1102 * document emplate object
1103 *
1104 * @var noDoc
1105 */
1106 var $doc;
1107
1108 var $include_once=array();
1109 var $content;
1110
1111
1112 /**
1113 * Basic initialization of the class
1114 *
1115 * @return void
1116 */
1117 function init() {
1118 $this->MCONF = $GLOBALS['MCONF'];
1119
1120 $this->menuConfig();
1121 $this->switchUser(t3lib_div::_GP('SwitchUser'));
1122
1123
1124 // **************************
1125 // Initializing
1126 // **************************
1127 $this->doc = t3lib_div::makeInstance('template');
1128 $this->doc->backPath = $GLOBALS['BACK_PATH'];
1129 $this->doc->setModuleTemplate('templates/beuser.html');
1130 $this->doc->form='<form action="" method="POST">';
1131
1132 // JavaScript
1133 $this->doc->JScode = $this->doc->wrapScriptTags('
1134 script_ended = 0;
1135 function jumpToUrl(URL) { //
1136 window.location.href = URL;
1137 }
1138 ' . $this->doc->redirectUrls());
1139 }
1140
1141 /**
1142 * Initialization of the module menu configuration
1143 *
1144 * @return void
1145 */
1146 function menuConfig() {
1147 // MENU-ITEMS:
1148 // If array, then it's a selector box menu
1149 // If empty string it's just a variable, that'll be saved.
1150 // Values NOT in this array will not be saved in the settings-array for the module.
1151 $this->MOD_MENU = array(
1152 'function' => array(
1153 'compare' => $GLOBALS['LANG']->getLL('compareUserSettings', true),
1154 'whoisonline' => $GLOBALS['LANG']->getLL('listUsersOnline', true)
1155 )
1156 );
1157 // CLEAN SETTINGS
1158 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
1159 }
1160
1161 /**
1162 * This functions builds the content of the page
1163 *
1164 * @return void
1165 */
1166 function main() {
1167 $this->content='';
1168
1169 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('backendUserAdministration', true));
1170 $this->content.=$this->doc->spacer(5);
1171
1172 switch($this->MOD_SETTINGS['function']) {
1173 case 'compare':
1174 if (t3lib_div::_GP('ads')) {
1175 $compareFlags = t3lib_div::_GP('compareFlags');
1176 $GLOBALS['BE_USER']->pushModuleData('tools_beuser/index.php/compare',$compareFlags);
1177 } else {
1178 $compareFlags = $GLOBALS['BE_USER']->getModuleData('tools_beuser/index.php/compare','ses');
1179 }
1180 $this->content.=$this->compareUsers($compareFlags);
1181 break;
1182 case 'whoisonline':
1183 $this->content.=$this->whoIsOnline();
1184 break;
1185 }
1186 // Setting up the buttons and markers for docheader
1187 $docHeaderButtons = $this->getButtons();
1188 //$markers['CSH'] = $docHeaderButtons['csh'];
1189 $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
1190 $markers['CONTENT'] = $this->content;
1191
1192 // Build the <body> for the module
1193 $this->content = $this->doc->startPage('Backend User Administration');
1194 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
1195 $this->content.= $this->doc->endPage();
1196 $this->content = $this->doc->insertStylesAndJS($this->content);
1197 }
1198
1199 /**
1200 * Prints the content of the page
1201 *
1202 * @return void
1203 */
1204 function printContent() {
1205 echo $this->content;
1206 }
1207
1208 /**
1209 * Create the panel of buttons for submitting the form or otherwise perform operations.
1210 *
1211 * @return array all available buttons as an assoc. array
1212 */
1213 protected function getButtons() {
1214
1215 $buttons = array(
1216 'csh' => '',
1217 'shortcut' => '',
1218 'save' => ''
1219 );
1220 // CSH
1221 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
1222
1223 // Shortcut
1224 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1225 $buttons['shortcut'] = $this->doc->makeShortcutIcon('be_user_uid,compareFlags','function', $this->MCONF['name']);
1226 }
1227
1228 return $buttons;
1229 }
1230
1231
1232
1233
1234
1235 /***************************
1236 *
1237 * OTHER FUNCTIONS:
1238 *
1239 ***************************/
1240
1241 /**
1242 * Compares the users with the given flags
1243 *
1244 * @param array options that should be taking into account to compare the users
1245 * @return string the content
1246 */
1247 function compareUsers($compareFlags) {
1248 // Menu:
1249 $options = array(
1250 'filemounts' => $GLOBALS['LANG']->getLL('filemounts', true),
1251 'webmounts' => $GLOBALS['LANG']->getLL('webmounts', true),
1252 'tempPath' => $GLOBALS['LANG']->getLL('defaultUploadPath', true),
1253 'firstMainGroup' => $GLOBALS['LANG']->getLL('mainUserGroup', true),
1254 'groupList' => $GLOBALS['LANG']->getLL('memberOfGroups', true),
1255 'pagetypes_select' => $GLOBALS['LANG']->getLL('pageTypesAccess', true),
1256 'tables_select' => $GLOBALS['LANG']->getLL('selectTables', true),
1257 'tables_modify' => $GLOBALS['LANG']->getLL('modifyTables', true),
1258 'non_exclude_fields' => $GLOBALS['LANG']->getLL('nonExcludeFields', true),
1259 'explicit_allowdeny' => $GLOBALS['LANG']->getLL('explicitAllowDeny', true),
1260 'allowed_languages' => $GLOBALS['LANG']->getLL('limitToLanguages', true),
1261 'workspace_perms' => $GLOBALS['LANG']->getLL('workspacePermissions', true),
1262 'workspace_membership' => $GLOBALS['LANG']->getLL('workspaceMembership', true),
1263 'custom_options' => $GLOBALS['LANG']->getLL('customOptions', true),
1264 'modules' => $GLOBALS['LANG']->getLL('modules', true),
1265 'userTS' => $GLOBALS['LANG']->getLL('tsconfig', true),
1266 'userTS_hl' => $GLOBALS['LANG']->getLL('tsconfigHL', true),
1267 );
1268
1269 $be_user_uid = t3lib_div::_GP('be_user_uid');
1270 if ($be_user_uid) {
1271 // This is used to test with other users. Development ONLY!
1272 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1273 $tempBE_USER->userTS_dontGetCached=1;
1274 $tempBE_USER->OS = TYPO3_OS;
1275 $tempBE_USER->setBeUserByUid($be_user_uid);
1276 $tempBE_USER->fetchGroupData();
1277
1278 $uInfo = $tempBE_USER->ext_compileUserInfoForHash();
1279 $uInfo_dat = $tempBE_USER->ext_printOverview($uInfo,$options,1);
1280
1281 $lines=array();
1282 foreach ($options as $kk => $vv) {
1283 if ($kk=='modules') {
1284 $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
1285 $loadModules->load($GLOBALS['TBE_MODULES'],$tempBE_USER);
1286 $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
1287 $uInfo_dat[$kk] = $alt_menuObj->topMenu($loadModules->modules,1,$GLOBALS['BACK_PATH']);
1288 }
1289 $lines[]='<tr class="bgColor4">
1290 <td nowrap="nowrap" valign="top">'.$vv.':&nbsp;&nbsp;</td>
1291 <td>'.$uInfo_dat[$kk].'&nbsp;</td>
1292 </tr>';
1293
1294 if ($kk=='webmounts' && !$tempBE_USER->isAdmin()) {
1295 $lines[]='<tr class="bgColor4">
1296 <td nowrap="nowrap" valign="top">' . $GLOBALS['LANG']->getLL('nonMountedReadablePages', true) . '&nbsp;&nbsp;</td>
1297 <td>'.$tempBE_USER->ext_getReadableButNonmounted().'&nbsp;</td>
1298 </tr>';
1299 }
1300 }
1301
1302 $email = htmlspecialchars($tempBE_USER->user['email']);
1303 $realname = htmlspecialchars($tempBE_USER->user['realName']);
1304 $outTable = '<table border="0" cellpadding="1" cellspacing="1"><tr class="bgColor5"><td>'.t3lib_iconWorks::getIconImage('be_users',$tempBE_USER->user,$GLOBALS['BACK_PATH'],'class="absmiddle" title="'.$tempBE_USER->user['uid'].'"').htmlspecialchars($tempBE_USER->user['username']).'</td>';
1305 $outTable.= '<td>'.($realname?$realname.', ':'').($email ? '<a href="mailto:'.$email.'">'.$email.'</a>' : '').'</td>';
1306 $outTable.= '<td>'.$this->elementLinks('be_users',$tempBE_USER->user).'</td></tr></table>';
1307 $outTable.= '<strong><a href="'.htmlspecialchars($this->MCONF['_']).'">' . $GLOBALS['LANG']->getLL('backToOverview', true) . '</a></strong><br />';
1308
1309 $outTable.= '<br /><table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
1310 $content.= $this->doc->section($GLOBALS['LANG']->getLL('userInfo', true),$outTable,0,1);
1311 } else {
1312 $menu = array(0 => array());
1313 $rowCounter = 0;
1314 $columnCounter = 0;
1315 $itemsPerColumn = ceil(count($options) / 3);
1316 foreach ($options as $kk => $vv) {
1317 if ($rowCounter == $itemsPerColumn) {
1318 $rowCounter = 0;
1319 $columnCounter++;
1320 $menu[$columnCounter] = array();
1321 }
1322 $rowCounter++;
1323 $menu[$columnCounter][]='<input type="checkbox" class="checkbox" value="1" name="compareFlags['.$kk.']" id="checkCompare_'.$kk.'"'.($compareFlags[$kk]?' checked="checked"':'').'> <label for="checkCompare_'.$kk.'">'.htmlspecialchars($vv).'</label>';
1324 }
1325 $outCode = '<p>' . $GLOBALS['LANG']->getLL('groupBy', true) . '</p>';
1326 $outCode .= '<table border="0" cellpadding="3" cellspacing="1" class="compare-checklist valign-top"><tr>';
1327 foreach ($menu as $column) {
1328 $outCode .= '<td>' . implode('<br />', $column) . '</td>';
1329 }
1330 $outCode .= '</tr></table>';
1331 $outCode.='<br /><input type="submit" name="ads" value="' . $GLOBALS['LANG']->getLL('update', true) . '">';
1332 $content = $this->doc->section($GLOBALS['LANG']->getLL('groupAndCompareUsers', true),$outCode,0,1);
1333
1334
1335 // Traverse all users
1336 $users = t3lib_BEfunc::getUserNames();
1337 $comparation=array();
1338 $counter=0;
1339
1340
1341 $offset=0;
1342 $numberAtTime=1000;
1343 $tooManyUsers='';
1344
1345 foreach ($users as $r) {
1346 if ($counter>=$offset) {
1347 // This is used to test with other users. Development ONLY!
1348 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1349 /* @var $tempBE_USER local_beUserAuth */
1350 $tempBE_USER->OS = TYPO3_OS;
1351 $tempBE_USER->setBeUserByUid($r['uid']);
1352 $tempBE_USER->fetchGroupData();
1353
1354 // Making group data
1355 $md5pre='';
1356 $menu=array();
1357 $uInfo = $tempBE_USER->ext_compileUserInfoForHash((array)$compareFlags);
1358 foreach ($options as $kk => $vv) {
1359 if ($compareFlags[$kk]) {
1360 $md5pre.=serialize($uInfo[$kk]).'|';
1361 }
1362 }
1363 // setting md5:
1364 $md5=md5($md5pre);
1365 if (!isset($comparation[$md5])) {
1366 $comparation[$md5]=$tempBE_USER->ext_printOverview($uInfo,$compareFlags);
1367 $comparation[$md5]['users']=array();
1368 }
1369 $comparation[$md5]['users'][]=$tempBE_USER->user;
1370 unset($tempBE_USER);
1371 }
1372 $counter++;
1373 if ($counter>=($numberAtTime+$offset)) {
1374 $tooManyUsers=$GLOBALS['LANG']->getLL('tooManyUsers', true) . ' ' . count($users) . '. ' . $GLOBALS['LANG']->getLL('canOnlyDisplay', true) . ' ' . $numberAtTime . '.';
1375 break;
1376 }
1377 }
1378
1379 // Print the groups:
1380 $allGroups=array();
1381 // Header:
1382 $allCells = array();
1383
1384 $link_createNewUser='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[be_users][0]=new',$this->doc->backPath,-1)).'">'.
1385 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_el.gif') . ' title="' . $GLOBALS['LANG']->getLL('newUser', true) . '" alt="" />'.
1386 '</a>';
1387
1388 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><td><b>' . $GLOBALS['LANG']->getLL('usernames', true) . '</b></td><td width="12">' . $link_createNewUser . '</td></tr></table>';
1389
1390 foreach ($options as $kk => $vv) {
1391 if ($compareFlags[$kk]) {
1392 $allCells[$kk] = '<b>'.$vv.':</b>';
1393 }
1394 }
1395 $allGroups[]=$allCells;
1396
1397 foreach ($comparation as $dat) {
1398 $allCells = array();
1399
1400 $curUid = $GLOBALS['BE_USER']->user['uid'];
1401 $uListArr=array();
1402
1403 foreach ($dat['users'] as $uDat) {
1404 $uItem = '<tr><td width="130">' . t3lib_iconWorks::getIconImage('be_users',$uDat,$GLOBALS['BACK_PATH'],'align="top" title="' . $uDat['uid'] . '"') . $this->linkUser($uDat['username'],$uDat) . '&nbsp;&nbsp;</td><td nowrap="nowrap">' . $this->elementLinks('be_users',$uDat);
1405 if ($curUid != $uDat['uid'] && !$uDat['disable'] && ($uDat['starttime'] == 0 || $uDat['starttime'] < time()) && ($uDat['endtime'] == 0 || $uDat['endtime'] > time())) {
1406 $uItem .= '<a href="' . t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'])) . '" target="_top"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/su.gif') . ' border="0" align="top" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('switchUserTo', true) . ' ' . $uDat['username']) . ' ' . $GLOBALS['LANG']->getLL('changeToMode', true) . '" alt="" /></a>'.
1407 '<a href="' . t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'], 'switchBackUser' => 1)) . '" target="_top"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/su_back.gif') . ' border="0" align="top" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('switchUserTo', true) . ' ' . $uDat['username']) . ' ' . $GLOBALS['LANG']->getLL('switchBackMode', true) . '" alt="" /></a>';
1408 }
1409 $uItem .= '</td></tr>';
1410 $uListArr[] = $uItem;
1411 }
1412 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>';
1413
1414 foreach ($options as $kk => $vv) {
1415 if ($compareFlags[$kk]) {
1416 $allCells[$kk] = $dat[$kk];
1417 }
1418 }
1419 $allGroups[]=$allCells;
1420 }
1421
1422 // Make table
1423 $outTable='';
1424 $TDparams=' nowrap="nowrap" class="bgColor5" valign="top"';
1425 $i = 0;
1426 foreach ($allGroups as $allCells) {
1427 $outTable.='<tr><td'.$TDparams.'>'.implode('</td><td'.$TDparams.'>',$allCells).'</td></tr>';
1428 $TDparams=' nowrap="nowrap" class="'.($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6').'" valign="top"';
1429 }
1430 $outTable='<table border="0" cellpadding="2" cellspacing="2">' . $outTable . '</table>';
1431 $outTable.=fw('<br /><br />' . $GLOBALS['LANG']->getLL('cachedGrouplistsUpdated', true) . '');
1432 $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">' . $tooManyUsers . '</span></strong>':'';
1433 $content.= $this->doc->spacer(10);
1434 $content.= $this->doc->section($GLOBALS['LANG']->getLL('result', true),$outTable,0,1);
1435 }
1436 return $content;
1437 }
1438
1439
1440 /**
1441 * Creates a HTML anchor to the user record
1442 *
1443 * @param string the string used to identify the user (inside the <a>...</a>)
1444 * @param array the BE user record to link
1445 * @return string the HTML anchor
1446 */
1447 function linkUser($str,$rec) {
1448 return '<a href="'.htmlspecialchars($this->MCONF['_']).'&be_user_uid='.$rec['uid'].'">' . htmlspecialchars($str) . '</a>';
1449 }
1450
1451
1452 /**
1453 * Builds a list of all links for a specific element (here: BE user) and returns it for print.
1454 *
1455 * @param string the db table that should be used
1456 * @param array the BE user record to use
1457 * @return string a HTML formatted list of the link
1458 */
1459 function elementLinks($table,$row) {
1460 // Info:
1461 $cells[]='<a href="#" onclick="top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\',\'' . $GLOBALS['BACK_PATH'] . '\'); return false;"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/zoom2.gif') . ' border="0" align="top" title="' . $GLOBALS['LANG']->getLL('showInformation', true) . '" alt="" /></a>';
1462
1463 // Edit:
1464 $params='&edit[' . $table . '][' . $row['uid'] . ']=edit';
1465 $cells[]='<a href="#" onclick="' . t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'],'') . '"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/edit2.gif') . ' border="0" align="top" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit', true) . '" alt="" /></a>';
1466
1467 // Hide:
1468 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
1469 if ($row[$hiddenField]) {
1470 $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=0';
1471 $cells[]='<a href="' . $this->doc->issueCommand($params) . '"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/button_unhide.gif') . ' border="0" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:enable', true) . '" align="top" alt="" /></a>';
1472 } else {
1473 $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=1';
1474 $cells[]='<a href="' . $this->doc->issueCommand($params) . '"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/button_hide.gif') . ' border="0" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disable', true) . '" align="top" alt="" /></a>';
1475 }
1476
1477 // Delete
1478 $params='&cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
1479 $cells[]='<a href="' . $this->doc->issueCommand($params) . '" onclick="return confirm(unescape(\'' . rawurlencode($GLOBALS['LANG']->getLL('sureToDelete', true)) . '\'));"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/garbage.gif') . ' border="0" align="top" title="' . $GLOBALS['LANG']->getLL('delete', true) . '" alt="" /></a>';
1480
1481 return implode('',$cells);
1482 }
1483
1484
1485 /**
1486 * Inits all BE-users available, for development ONLY!
1487 *
1488 * @return void
1489 */
1490 function initUsers() {
1491 // Initializing all users in order to generate the usergroup_cached_list
1492 $users = t3lib_BEfunc::getUserNames();
1493
1494 // This is used to test with other users. Development ONLY!
1495 foreach ($users as $r) {
1496 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1497 /* @var $tempBE_USER local_beUserAuth */
1498 $tempBE_USER->OS = TYPO3_OS;
1499 $tempBE_USER->setBeUserByUid($r['uid']);
1500 $tempBE_USER->fetchGroupData();
1501 }
1502 }
1503
1504 /**
1505 * Returns the local path for this string (removes the PATH_site if it is included)
1506 *
1507 * @param string the path that will be checked
1508 * @return string the local path
1509 */
1510 function localPath($str) {
1511 if (substr($str,0,strlen(PATH_site))==PATH_site) {
1512 return substr($str,strlen(PATH_site));
1513 } else {
1514 return $str;
1515 }
1516 }
1517
1518 /**
1519 * Switches to a given user (SU-mode) and then redirects to the start page of the backend to refresh the navigation etc.
1520 *
1521 * @param array BE-user record that will be switched to
1522 * @return void
1523 */
1524 function switchUser($switchUser) {
1525 $uRec=t3lib_BEfunc::getRecord('be_users',$switchUser);
1526 if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin()) {
1527 $updateData['ses_userid'] = $uRec['uid'];
1528 // user switchback
1529 if (t3lib_div::_GP('switchBackUser')) {
1530 $updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']);
1531 }
1532 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id='.$GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions').' AND ses_name=\'be_typo_user\' AND ses_userid='.intval($GLOBALS['BE_USER']->user['uid']),$updateData);
1533
1534 header('Location: '.t3lib_div::locationHeaderUrl($GLOBALS['BACK_PATH'].'index.php'.($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']?'':'?commandLI=1')));
1535 exit;
1536 }
1537 }
1538
1539 /***************************
1540 *
1541 * "WHO IS ONLINE" FUNCTIONS:
1542 *
1543 ***************************/
1544
1545 /**
1546 * @author Martin Kutschker
1547 */
1548 function whoIsOnline() {
1549 $select_fields = 'ses_id, ses_tstamp, ses_iplock, u.uid,u.username, u.admin, u.realName, u.disable, u.starttime, u.endtime, u.deleted, bu.uid AS bu_uid,bu.username AS bu_username, bu.realName AS bu_realName';
1550 $from_table = '(be_sessions, be_users u) LEFT OUTER JOIN be_users bu ON (ses_backuserid=bu.uid)';
1551 $where_clause = 'ses_userid=u.uid';
1552 $orderBy = 'u.username';
1553
1554 if (t3lib_div::testInt($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'])) {
1555 $where_clause .= ' AND '.$GLOBALS['EXEC_TIME'].'<(ses_tstamp+'.$GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'].')';
1556 } else {
1557 $timeout = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
1558 if ($timeout > 0) {
1559 $where_clause .= ' AND '.$GLOBALS['EXEC_TIME'].'<(ses_tstamp+'.$timeout.')';
1560 }
1561 }
1562 // Fetch active sessions of other users from storage:
1563 $sessions = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select_fields,$from_table,$where_clause,'',$orderBy);
1564 // Process and visualized each active session as a table row:
1565 if (is_array($sessions)) {
1566 foreach ($sessions as $session) {
1567 $ip = $session['ses_iplock'];
1568 $hostName = '';
1569 if ($session['ses_iplock'] == '[DISABLED]' || $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 0) {
1570 $ip = '-';
1571 } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 4) {
1572 $hostName = ' title="' . @gethostbyaddr($session['ses_iplock']) . '"';
1573 } else {
1574 $ip .= str_repeat('.*', 4-$GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP']);
1575 }
1576 $outTable .= '
1577 <tr class="bgColor4" height="17" valign="top">' .
1578 '<td nowrap="nowrap">' .
1579 date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $session['ses_tstamp']) .
1580 '</td>' .
1581 '<td nowrap="nowrap">' .
1582 '<span'.$hostName.'>'.$ip.'</span>' .
1583 '</td>' .
1584 '<td width="130">' .
1585 t3lib_iconWorks::getIconImage('be_users',$session,$GLOBALS['BACK_PATH'],'align="top" title="'.$session['uid'].'"').htmlspecialchars($session['username']).'&nbsp;' .
1586 '</td>' .
1587 '<td nowrap="nowrap">'.htmlspecialchars($session['realName']).'&nbsp;&nbsp;</td>' .
1588 '<td nowrap="nowrap">'.$this->elementLinks('be_users',$session).'</td>' .
1589 '<td nowrap="nowrap" valign="top">'.($session['bu_username'] ? '&nbsp;SU from: ' : '').htmlspecialchars($session['bu_username']).'&nbsp;</td>' .
1590 '<td nowrap="nowrap" valign="top">&nbsp;'.htmlspecialchars($session['bu_realName']).'</td>' .
1591 '</tr>';
1592 }
1593 }
1594 // Wrap <table> tag around the rows:
1595 $outTable = '
1596 <table border="0" cellpadding="2" cellspacing="2">
1597 <tr class="bgColor5">
1598 <td valign="top"><b>' . $GLOBALS['LANG']->getLL('timestamp', true) . '</b></td>
1599 <td valign="top"><b>' . $GLOBALS['LANG']->getLL('host', true) . '</b></td>
1600 <td valign="top" colspan="5"><b>' . $GLOBALS['LANG']->getLL('username', true) . '</b></td>
1601 </tr>'.$outTable.'
1602 </table>';
1603
1604 $content.= $this->doc->section($GLOBALS['LANG']->getLL('whoIsOnline', true),$outTable,0,1);
1605 return $content;
1606 }
1607
1608 }
1609
1610
1611 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']) {
1612 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']);
1613 }
1614
1615
1616 // Make instance:
1617 $SOBE = t3lib_div::makeInstance('SC_mod_tools_be_user_index');
1618 $SOBE->init();
1619 $SOBE->main();
1620 $SOBE->printContent();
1621
1622 ?>