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