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