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