Fixed bug #12872: Use "strong" instead of "b": typo3/sysext/
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / mod / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 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_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 Skaarhoj <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 localPageTree($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 Skaarhoj <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 Skaarhoj <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-lock', 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 Skaarhoj <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 localFolderTree($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 Skaarhoj <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 Skaarhoj <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 $out[$k] = implode('<br />',$pageTypes);
646 break;
647 case 'tables_select':
648 case 'tables_modify':
649 $tables = explode(',',$v);
650 foreach ($tables as &$vv) {
651 if ($vv) {
652 $vv = '<span class="nobr">'.t3lib_iconWorks::getSpriteIconForRecord($vv,array()).$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>';
653 }
654 }
655 $out[$k] = implode('<br />',$tables);
656 break;
657 case 'non_exclude_fields':
658 $nef = explode(',',$v);
659 $table='';
660 $pout=array();
661 foreach ($nef as $vv) {
662 if ($vv) {
663 list($thisTable,$field) = explode(':',$vv);
664 if ($thisTable!=$table) {
665 $table=$thisTable;
666 t3lib_div::loadTCA($table);
667 $pout[]='<span class="nobr">'.t3lib_iconWorks::getSpriteIconForRecord($table,array()).$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']).'</span>';
668 }
669 if ($GLOBALS['TCA'][$table]['columns'][$field]) {
670 $pout[]='<span class="nobr"> - '.rtrim($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label']), ':').'</span>';
671 }
672 }
673 }
674 $out[$k] = implode('<br />',$pout);
675 break;
676 case 'groupList':
677 case 'firstMainGroup':
678 $uGroups = explode(',',$v);
679 $table='';
680 $pout=array();
681 foreach ($uGroups as $vv) {
682 if ($vv) {
683 $uGRow = t3lib_BEfunc::getRecord('be_groups',$vv);
684 $pout[]='<tr><td nowrap="nowrap">'.t3lib_iconWorks::getSpriteIconForRecord('be_groups',$uGRow).'&nbsp;'.htmlspecialchars($uGRow['title']).'&nbsp;&nbsp;</td><td width=1% nowrap="nowrap">'.$GLOBALS['SOBE']->elementLinks('be_groups',$uGRow).'</td></tr>';
685 }
686 }
687 $out[$k] = '<table border="0" cellpadding="0" cellspacing="0" width="100%">'.implode('',$pout).'</table>';
688 break;
689 case 'modules':
690 $mods = explode(',',$v);
691 $mainMod='';
692 $pout=array();
693 foreach ($mods as $vv) {
694 if ($vv) {
695 list($thisMod,$subMod) = explode('_',$vv);
696 if ($thisMod!=$mainMod) {
697 $mainMod=$thisMod;
698 $pout[]='<span class="nobr">'.($modNames[$mainMod]?$modNames[$mainMod]:$mainMod).'</span>';
699 }
700 if ($subMod) {
701 $pout[]='<span class="nobr"> - '.($modNames[$mainMod.'_'.$subMod]?$modNames[$mainMod.'_'.$subMod]:$mainMod.'_'.$subMod).'</span>';
702 }
703 }
704 }
705 $out[$k] = implode('<br />',$pout);
706 break;
707 case 'userTS':
708
709 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext'); // Defined global here!
710 $tmpl->tt_track = 0; // Do not log time-performance information
711
712 $tmpl->fixedLgd=0;
713 $tmpl->linkObjects=0;
714 $tmpl->bType='';
715 $tmpl->ext_expandAllNotes=1;
716 $tmpl->ext_noPMicons=1;
717 $out[$k] = $tmpl->ext_getObjTree($v,'','','','','1');
718 break;
719 case 'userTS_hl':
720 $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
721 $tsparser->lineNumberOffset=0;
722 $out[$k] = $tsparser->doSyntaxHighlight($v,0,1);
723 break;
724 case 'explicit_allowdeny':
725
726 // Explode and flip values:
727 $nef = array_flip(explode(',',$v));
728 $pout = array();
729
730 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
731
732 // Icons:
733 $icons = array(
734 'ALLOW' => t3lib_iconWorks::getSpriteIcon('status-dialog-ok'),
735 'DENY' => t3lib_iconWorks::getSpriteIcon('status-dialog-error'),
736 );
737
738 // Traverse types:
739 foreach ($theTypes as $tableFieldKey => $theTypeArrays) {
740 if (is_array($theTypeArrays['items'])) {
741 $pout[] = '<strong>'.$theTypeArrays['tableFieldLabel'].'</strong>';
742 // Traverse options for this field:
743 foreach ($theTypeArrays['items'] as $itemValue => $itemContent) {
744 $v = $tableFieldKey.':'.$itemValue.':'.$itemContent[0];
745 if (isset($nef[$v])) {
746 unset($nef[$v]);
747 $pout[] = $icons[$itemContent[0]].'['.$itemContent[2].'] '.$itemContent[1];
748 } else {
749 $pout[] = '<em style="color: #666666;">'.$icons[($itemContent[0]=='ALLOW' ? 'DENY' : 'ALLOW')].'['.$itemContent[2].'] '.$itemContent[1].'</em>';
750 }
751 }
752 $pout[] = '';
753 }
754 }
755
756 // Add remaining:
757 if (count($nef)) {
758 $pout = array_merge($pout, array_keys($nef));
759 }
760
761 // Implode for display:
762 $out[$k] = implode('<br />',$pout);
763 break;
764 case 'allowed_languages':
765
766 // Explode and flip values:
767 $nef = array_flip(explode(',',$v));
768 $pout = array();
769
770 // Get languages:
771 $items = t3lib_BEfunc::getSystemLanguages();
772
773 // Traverse values:
774 foreach ($items as $iCfg) {
775 if (isset($nef[$iCfg[1]])) {
776 unset($nef[$iCfg[1]]);
777 if (strlen($iCfg[2])) {
778 $icon = '<img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$iCfg[2]).' class="absmiddle" style="margin-right: 5px;" alt="" />';
779 } else {
780 $icon = '';
781 }
782 $pout[] = $icon.$iCfg[0];
783 }
784 }
785
786 // Add remaining:
787 if (count($nef)) {
788 $pout = array_merge($pout, array_keys($nef));
789 }
790
791 // Implode for display:
792 $out[$k] = implode('<br />',$pout);
793 break;
794 case 'workspace_perms':
795 $out[$k] = implode('<br/>',explode(', ',t3lib_BEfunc::getProcessedValue('be_users','workspace_perms',$v)));
796 break;
797 case 'workspace_membership':
798 $out[$k] = implode('<br/>',$this->ext_workspaceMembership());
799 break;
800 case 'custom_options':
801
802 // Explode and flip values:
803 $nef = array_flip(explode(',',$v));
804 $pout = array();
805
806 // Initialize:
807 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
808 if (is_array($customOptions)) {
809 foreach ($customOptions as $coKey => $coValue) {
810 if (is_array($coValue['items'])) {
811 // Traverse items:
812 foreach ($coValue['items'] as $itemKey => $itemCfg) {
813 $v = $coKey.':'.$itemKey;
814 if (isset($nef[$v])) {
815 unset($nef[$v]);
816 $pout[] = $GLOBALS['LANG']->sl($coValue['header']).' / '.$GLOBALS['LANG']->sl($itemCfg[0]);
817 }
818 }
819 }
820 }
821 }
822
823 // Add remaining:
824 if (count($nef)) {
825 $pout = array_merge($pout, array_keys($nef));
826 }
827
828 // Implode for display:
829 $out[$k] = implode('<br />',$pout);
830 break;
831 }
832 }
833 }
834 return $out;
835 }
836
837 /**
838 * Get HTML code for the pages which were mounted, but NOT readable!
839 *
840 * @return string HTML code.
841 */
842 function ext_getReadableButNonmounted() {
843
844 // List of page id mounts which ARE mounted (and should therefore not be selected)
845 if (!$this->ext_pageIdsFromMounts) {
846 $this->ext_pageIdsFromMounts=0;
847 }
848
849 // User and group names:
850 $be_user_Array = t3lib_BEfunc::getUserNames();
851 $be_group_Array = t3lib_BEfunc::getGroupNames();
852
853 // Create query:
854 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
855 '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':''),
856 'pages',
857 'uid NOT IN ('.$this->ext_pageIdsFromMounts.') AND '.$this->getPagePermsClause(1).t3lib_BEfunc::deleteClause('pages')
858 );
859 $dat = array();
860 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
861 $dat[] = array(
862 'row'=>$row,
863 'HTML'=>t3lib_iconWorks::getSpriteIconForRecord('pages',$row,array('title'=>'['.$row['uid'].']'))
864 );
865 }
866 $pp = t3lib_div::makeInstance('printAllPageTree_perms', $this);
867 return $pp->printTree($dat,1);
868 }
869
870 /**
871 * Print a set of permissions
872 *
873 * @param integer The permissions integer.
874 * @return string HTML formatted.
875 */
876 function ext_printPerms($int) {
877 $str='';
878 $str.= (($int&1)?'*':'<font color="red">x</font>');
879 $str.= (($int&16)?'*':'<font color="red">x</font>');
880 $str.= (($int&2)?'*':'<font color="red">x</font>');
881 $str.= (($int&4)?'*':'<font color="red">x</font>');
882 $str.= (($int&8)?'*':'<font color="red">x</font>');
883
884 return '<strong style="color:green;">'.$str.'</strong>';
885 }
886
887 /**
888 * 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
889 *
890 * @param array Page record.
891 * @param array First-group record.
892 * @return integer Permissions.
893 */
894 function ext_groupPerms($row,$firstGroup) {
895 if (is_array($row)) {
896 $out=intval($row['perms_everybody']);
897 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
898 $out|= intval($row['perms_group']);
899 }
900 return $out;
901 }
902 }
903
904 /**
905 * Creates uInfo array for the user.
906 *
907 * @param array Might contain array where keys/values indicate whether to render a certain value
908 * @return array Array with the information of the user for each analysis topic.
909 */
910 function ext_compileUserInfoForHash($filter=NULL) {
911 $uInfo=array();
912 $renderAll = !is_array($filter);
913
914 // Filemounts:
915 if ($renderAll || $filter['filemounts']) {
916 $uInfo['filemounts'] = $this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts'])));
917 }
918
919 // DBmounts:
920 if ($renderAll || $filter['webmounts']) {
921 $uInfo['webmounts'] = $this->ext_uniqueAndSortList($this->groupData['webmounts']);
922 }
923
924 // Sharing Upload Folder
925 if ($renderAll || $filter['tempPath']) {
926 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
927 $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
928 $uInfo['tempPath'] = $fileProcessor->findTempFolder(); // The closest TEMP-path is found
929 }
930
931 // First Main Group:
932 if ($renderAll || $filter['firstMainGroup']) {
933 $uInfo['firstMainGroup'] = $this->firstMainGroup;
934 }
935
936 // Group List:
937 if ($renderAll || $filter['groupList']) {
938 $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.
939 }
940
941 // Page Types:
942 if ($renderAll || $filter['pagetypes_select']) {
943 $uInfo['pagetypes_select'] = $this->ext_uniqueAndSortList($this->groupData['pagetypes_select']);
944 }
945
946 // Tables select:
947 if ($renderAll || $filter['tables_select']) {
948 $uInfo['tables_select'] = $this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']);
949 }
950
951 // Tables modify:
952 if ($renderAll || $filter['tables_modify']) {
953 $uInfo['tables_modify'] = $this->ext_uniqueAndSortList($this->groupData['tables_modify']);
954 }
955
956 // Non-exclude fields:
957 if ($renderAll || $filter['non_exclude_fields']) {
958 $uInfo['non_exclude_fields'] = $this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']);
959 }
960
961 // Explicit Allow/Deny:
962 if ($renderAll || $filter['explicit_allowdeny']) {
963 $uInfo['explicit_allowdeny'] = $this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']);
964 }
965
966 // Limit to languages:
967 if ($renderAll || $filter['allowed_languages']) {
968 $uInfo['allowed_languages'] = $this->ext_uniqueAndSortList($this->groupData['allowed_languages']);
969 }
970
971 // Workspace permissions
972 if ($renderAll || $filter['workspace_perms']) {
973 $uInfo['workspace_perms'] = $this->ext_uniqueAndSortList($this->groupData['workspace_perms']);
974 }
975
976 // Workspace membership
977 if ($renderAll || $filter['workspace_membership']) {
978 $uInfo['workspace_membership'] = $this->ext_workspaceMembership();
979 }
980
981 // Custom options:
982 if ($renderAll || $filter['custom_options']) {
983 $uInfo['custom_options'] = $this->ext_uniqueAndSortList($this->groupData['custom_options']);
984 }
985
986 // Modules:
987 if ($renderAll || $filter['modules']) {
988 $uInfo['modules'] = $this->ext_uniqueAndSortList($this->groupData['modules']);
989 }
990
991 // User TS:
992 $this->ext_ksortArrayRecursive($this->userTS);
993 if ($renderAll || $filter['userTS']) {
994 $uInfo['userTS'] = $this->userTS;
995 }
996
997 if ($renderAll || $filter['userTS_hl']) {
998 $uInfo['userTS_hl'] = $this->userTS_text;
999 }
1000
1001 return $uInfo;
1002 }
1003
1004 /**
1005 * Sorts a commalist of values and removes duplicates.
1006 *
1007 * @param string Commalist.
1008 * @return string Sorted, unique commalist.
1009 */
1010 function ext_uniqueAndSortList($list) {
1011 $uList=t3lib_div::trimExplode(',',$list,1);
1012 sort($uList);
1013 $uList=array_unique($uList);
1014 $uList=implode(',',$uList);
1015 return $uList;
1016 }
1017
1018 /**
1019 * Key sort input array recursively.
1020 *
1021 * @param array Multidimensional array (value by reference!)
1022 * @return void
1023 */
1024 function ext_ksortArrayRecursive(&$arr) {
1025 krsort($arr);
1026 foreach ($arr as &$v) {
1027 if (is_array($v)) {
1028 $this->ext_ksortArrayRecursive($v);
1029 }
1030 }
1031 }
1032
1033 /**
1034 * Returns all workspaces that are accessible for the BE_USER
1035 *
1036 * @return array with key / value pairs of available workspaces (filtered by BE_USER check)
1037 */
1038 function ext_workspaceMembership() {
1039 // Create accessible workspace arrays:
1040 $options = array();
1041 if ($this->checkWorkspace(array('uid' => 0))) {
1042 $options[0] = '0: ' . $GLOBALS['LANG']->getLL('live', true);
1043 }
1044 if ($this->checkWorkspace(array('uid' => -1))) {
1045 $options[-1] = '-1: ' . $GLOBALS['LANG']->getLL('defaultDraft', true);
1046 }
1047
1048 // Add custom workspaces (selecting all, filtering by BE_USER check):
1049 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers,db_mountpoints','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
1050 if (count($workspaces)) {
1051 foreach ($workspaces as $rec) {
1052 if ($this->checkWorkspace($rec)) {
1053 $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
1054
1055 // Check if all mount points are accessible, otherwise show error:
1056 if (trim($rec['db_mountpoints'])!=='') {
1057 $mountPoints = t3lib_div::intExplode(',',$this->workspaceRec['db_mountpoints'],1);
1058 foreach ($mountPoints as $mpId) {
1059 if (!$this->isInWebMount($mpId,'1=1')) {
1060 $options[$rec['uid']].= '<br> \- ' . $GLOBALS['LANG']->getLL('notAccessible', true) . ' ' . $mpId;
1061 }
1062 }
1063 }
1064 }
1065 }
1066 }
1067
1068 return $options;
1069 }
1070 }
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083 /**
1084 * Main script class
1085 *
1086 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1087 * @package TYPO3
1088 * @subpackage tx_beuser
1089 */
1090 class SC_mod_tools_be_user_index {
1091 var $MCONF=array();
1092 var $MOD_MENU=array();
1093 var $MOD_SETTINGS=array();
1094
1095 /**
1096 * document emplate object
1097 *
1098 * @var noDoc
1099 */
1100 var $doc;
1101
1102 var $include_once=array();
1103 var $content;
1104
1105
1106 /**
1107 * Basic initialization of the class
1108 *
1109 * @return void
1110 */
1111 function init() {
1112 $this->MCONF = $GLOBALS['MCONF'];
1113
1114 $this->menuConfig();
1115 $this->switchUser(t3lib_div::_GP('SwitchUser'));
1116
1117
1118 // **************************
1119 // Initializing
1120 // **************************
1121 $this->doc = t3lib_div::makeInstance('template');
1122 $this->doc->backPath = $GLOBALS['BACK_PATH'];
1123 $this->doc->setModuleTemplate('templates/beuser.html');
1124 $this->doc->form = '<form action="" method="post">';
1125
1126 // JavaScript
1127 $this->doc->JScode = $this->doc->wrapScriptTags('
1128 script_ended = 0;
1129 function jumpToUrl(URL) { //
1130 window.location.href = URL;
1131 }
1132 ' . $this->doc->redirectUrls());
1133 }
1134
1135 /**
1136 * Initialization of the module menu configuration
1137 *
1138 * @return void
1139 */
1140 function menuConfig() {
1141 // MENU-ITEMS:
1142 // If array, then it's a selector box menu
1143 // If empty string it's just a variable, that'll be saved.
1144 // Values NOT in this array will not be saved in the settings-array for the module.
1145 $this->MOD_MENU = array(
1146 'function' => array(
1147 'compare' => $GLOBALS['LANG']->getLL('compareUserSettings', true),
1148 'whoisonline' => $GLOBALS['LANG']->getLL('listUsersOnline', true)
1149 )
1150 );
1151 // CLEAN SETTINGS
1152 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
1153 }
1154
1155 /**
1156 * This functions builds the content of the page
1157 *
1158 * @return void
1159 */
1160 function main() {
1161 $this->content='';
1162
1163 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('backendUserAdministration', true));
1164 $this->content.=$this->doc->spacer(5);
1165
1166 switch($this->MOD_SETTINGS['function']) {
1167 case 'compare':
1168 if (t3lib_div::_GP('ads')) {
1169 $compareFlags = t3lib_div::_GP('compareFlags');
1170 $GLOBALS['BE_USER']->pushModuleData('tools_beuser/index.php/compare',$compareFlags);
1171 } else {
1172 $compareFlags = $GLOBALS['BE_USER']->getModuleData('tools_beuser/index.php/compare','ses');
1173 }
1174 $this->content.=$this->compareUsers($compareFlags);
1175 break;
1176 case 'whoisonline':
1177 $this->content.=$this->whoIsOnline();
1178 break;
1179 }
1180 // Setting up the buttons and markers for docheader
1181 $docHeaderButtons = $this->getButtons();
1182 //$markers['CSH'] = $docHeaderButtons['csh'];
1183 $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
1184 $markers['CONTENT'] = $this->content;
1185
1186 // Build the <body> for the module
1187 $this->content = $this->doc->startPage('Backend User Administration');
1188 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
1189 $this->content.= $this->doc->endPage();
1190 $this->content = $this->doc->insertStylesAndJS($this->content);
1191 }
1192
1193 /**
1194 * Prints the content of the page
1195 *
1196 * @return void
1197 */
1198 function printContent() {
1199 echo $this->content;
1200 }
1201
1202 /**
1203 * Create the panel of buttons for submitting the form or otherwise perform operations.
1204 *
1205 * @return array all available buttons as an assoc. array
1206 */
1207 protected function getButtons() {
1208
1209 $buttons = array(
1210 'csh' => '',
1211 'shortcut' => '',
1212 'save' => ''
1213 );
1214 // CSH
1215 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
1216
1217 // Shortcut
1218 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1219 $buttons['shortcut'] = $this->doc->makeShortcutIcon('be_user_uid,compareFlags','function', $this->MCONF['name']);
1220 }
1221
1222 return $buttons;
1223 }
1224
1225
1226
1227
1228
1229 /***************************
1230 *
1231 * OTHER FUNCTIONS:
1232 *
1233 ***************************/
1234
1235 /**
1236 * Compares the users with the given flags
1237 *
1238 * @param array options that should be taking into account to compare the users
1239 * @return string the content
1240 */
1241 function compareUsers($compareFlags) {
1242 // Menu:
1243 $options = array(
1244 'filemounts' => $GLOBALS['LANG']->getLL('filemounts', true),
1245 'webmounts' => $GLOBALS['LANG']->getLL('webmounts', true),
1246 'tempPath' => $GLOBALS['LANG']->getLL('defaultUploadPath', true),
1247 'firstMainGroup' => $GLOBALS['LANG']->getLL('mainUserGroup', true),
1248 'groupList' => $GLOBALS['LANG']->getLL('memberOfGroups', true),
1249 'pagetypes_select' => $GLOBALS['LANG']->getLL('pageTypesAccess', true),
1250 'tables_select' => $GLOBALS['LANG']->getLL('selectTables', true),
1251 'tables_modify' => $GLOBALS['LANG']->getLL('modifyTables', true),
1252 'non_exclude_fields' => $GLOBALS['LANG']->getLL('nonExcludeFields', true),
1253 'explicit_allowdeny' => $GLOBALS['LANG']->getLL('explicitAllowDeny', true),
1254 'allowed_languages' => $GLOBALS['LANG']->getLL('limitToLanguages', true),
1255 'workspace_perms' => $GLOBALS['LANG']->getLL('workspacePermissions', true),
1256 'workspace_membership' => $GLOBALS['LANG']->getLL('workspaceMembership', true),
1257 'custom_options' => $GLOBALS['LANG']->getLL('customOptions', true),
1258 'modules' => $GLOBALS['LANG']->getLL('modules', true),
1259 'userTS' => $GLOBALS['LANG']->getLL('tsconfig', true),
1260 'userTS_hl' => $GLOBALS['LANG']->getLL('tsconfigHL', true),
1261 );
1262
1263 $be_user_uid = t3lib_div::_GP('be_user_uid');
1264 if ($be_user_uid) {
1265 // This is used to test with other users. Development ONLY!
1266 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1267 $tempBE_USER->userTS_dontGetCached=1;
1268 $tempBE_USER->OS = TYPO3_OS;
1269 $tempBE_USER->setBeUserByUid($be_user_uid);
1270 $tempBE_USER->fetchGroupData();
1271
1272 $uInfo = $tempBE_USER->ext_compileUserInfoForHash();
1273 $uInfo_dat = $tempBE_USER->ext_printOverview($uInfo,$options,1);
1274
1275 $lines=array();
1276 foreach ($options as $kk => $vv) {
1277 if ($kk=='modules') {
1278 $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
1279 $loadModules->load($GLOBALS['TBE_MODULES'],$tempBE_USER);
1280 $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
1281 $uInfo_dat[$kk] = $alt_menuObj->topMenu($loadModules->modules,1,$GLOBALS['BACK_PATH']);
1282 }
1283 $lines[]='<tr class="bgColor4">
1284 <td nowrap="nowrap" valign="top">'.$vv.':&nbsp;&nbsp;</td>
1285 <td>'.$uInfo_dat[$kk].'&nbsp;</td>
1286 </tr>';
1287
1288 if ($kk=='webmounts' && !$tempBE_USER->isAdmin()) {
1289 $lines[]='<tr class="bgColor4">
1290 <td nowrap="nowrap" valign="top">' . $GLOBALS['LANG']->getLL('nonMountedReadablePages', true) . '&nbsp;&nbsp;</td>
1291 <td>'.$tempBE_USER->ext_getReadableButNonmounted().'&nbsp;</td>
1292 </tr>';
1293 }
1294 }
1295
1296 $email = htmlspecialchars($tempBE_USER->user['email']);
1297 $realname = htmlspecialchars($tempBE_USER->user['realName']);
1298 $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>';
1299 $outTable.= '<td>'.($realname?$realname.', ':'').($email ? '<a href="mailto:'.$email.'">'.$email.'</a>' : '').'</td>';
1300 $outTable.= '<td>'.$this->elementLinks('be_users',$tempBE_USER->user).'</td></tr></table>';
1301 $outTable.= '<strong><a href="'.htmlspecialchars($this->MCONF['_']).'">' . $GLOBALS['LANG']->getLL('backToOverview', true) . '</a></strong><br />';
1302
1303 $outTable.= '<br /><table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
1304 $content.= $this->doc->section($GLOBALS['LANG']->getLL('userInfo', true),$outTable,0,1);
1305 } else {
1306 $menu = array(0 => array());
1307 $rowCounter = 0;
1308 $columnCounter = 0;
1309 $itemsPerColumn = ceil(count($options) / 3);
1310 foreach ($options as $kk => $vv) {
1311 if ($rowCounter == $itemsPerColumn) {
1312 $rowCounter = 0;
1313 $columnCounter++;
1314 $menu[$columnCounter] = array();
1315 }
1316 $rowCounter++;
1317 $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>';
1318 }
1319 $outCode = '<p>' . $GLOBALS['LANG']->getLL('groupBy', true) . '</p>';
1320 $outCode .= '<table border="0" cellpadding="3" cellspacing="1" class="compare-checklist valign-top"><tr>';
1321 foreach ($menu as $column) {
1322 $outCode .= '<td>' . implode('<br />', $column) . '</td>';
1323 }
1324 $outCode .= '</tr></table>';
1325 $outCode.='<br /><input type="submit" name="ads" value="' . $GLOBALS['LANG']->getLL('update', true) . '">';
1326 $content = $this->doc->section($GLOBALS['LANG']->getLL('groupAndCompareUsers', true),$outCode,0,1);
1327
1328
1329 // Traverse all users
1330 $users = t3lib_BEfunc::getUserNames();
1331 $comparation=array();
1332 $counter=0;
1333
1334
1335 $offset=0;
1336 $numberAtTime=1000;
1337 $tooManyUsers='';
1338
1339 foreach ($users as $r) {
1340 if ($counter>=$offset) {
1341 // This is used to test with other users. Development ONLY!
1342 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1343 /* @var $tempBE_USER local_beUserAuth */
1344 $tempBE_USER->OS = TYPO3_OS;
1345 $tempBE_USER->setBeUserByUid($r['uid']);
1346 $tempBE_USER->fetchGroupData();
1347
1348 // Making group data
1349 $md5pre='';
1350 $menu=array();
1351 $uInfo = $tempBE_USER->ext_compileUserInfoForHash((array)$compareFlags);
1352 foreach ($options as $kk => $vv) {
1353 if ($compareFlags[$kk]) {
1354 $md5pre.=serialize($uInfo[$kk]).'|';
1355 }
1356 }
1357 // setting md5:
1358 $md5=md5($md5pre);
1359 if (!isset($comparation[$md5])) {
1360 $comparation[$md5]=$tempBE_USER->ext_printOverview($uInfo,$compareFlags);
1361 $comparation[$md5]['users']=array();
1362 }
1363 $comparation[$md5]['users'][]=$tempBE_USER->user;
1364 unset($tempBE_USER);
1365 }
1366 $counter++;
1367 if ($counter>=($numberAtTime+$offset)) {
1368 $tooManyUsers=$GLOBALS['LANG']->getLL('tooManyUsers', true) . ' ' . count($users) . '. ' . $GLOBALS['LANG']->getLL('canOnlyDisplay', true) . ' ' . $numberAtTime . '.';
1369 break;
1370 }
1371 }
1372
1373 // Print the groups:
1374 $allGroups=array();
1375 // Header:
1376 $allCells = array();
1377
1378 $link_createNewUser='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[be_users][0]=new',$this->doc->backPath,-1)).'" title="' . $GLOBALS['LANG']->getLL('newUser', true) . '">'.
1379 t3lib_iconWorks::getSpriteIcon('actions-document-new') .
1380 '</a>';
1381
1382 $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>';
1383
1384 foreach ($options as $kk => $vv) {
1385 if ($compareFlags[$kk]) {
1386 $allCells[$kk] = '<strong>'.$vv.':</strong>';
1387 }
1388 }
1389 $allGroups[]=$allCells;
1390
1391 foreach ($comparation as $dat) {
1392 $allCells = array();
1393
1394 $curUid = $GLOBALS['BE_USER']->user['uid'];
1395 $uListArr=array();
1396
1397 foreach ($dat['users'] as $uDat) {
1398 $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);
1399 if ($curUid != $uDat['uid'] && !$uDat['disable'] && ($uDat['starttime'] == 0 ||
1400 $uDat['starttime'] < $GLOBALS['EXEC_TIME']) && ($uDat['endtime'] == 0 ||
1401 $uDat['endtime'] > $GLOBALS['EXEC_TIME'])) {
1402 $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) . '">' .
1403 t3lib_iconWorks::getSpriteIcon('actions-system-backend-user-switch') .
1404 '</a>'.
1405 '<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) . '">' .
1406 t3lib_iconWorks::getSpriteIcon('actions-system-backend-user-emulate') .
1407 '</a>';
1408 }
1409 $uItem .= '</td></tr>';
1410 $uListArr[] = $uItem;
1411 }
1412 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>';
1413
1414 foreach ($options as $kk => $vv) {
1415 if ($compareFlags[$kk]) {
1416 $allCells[$kk] = $dat[$kk];
1417 }
1418 }
1419 $allGroups[]=$allCells;
1420 }
1421
1422 // Make table
1423 $outTable='';
1424 $TDparams=' nowrap="nowrap" class="bgColor5" valign="top"';
1425 $i = 0;
1426 foreach ($allGroups as $allCells) {
1427 $outTable.='<tr><td'.$TDparams.'>'.implode('</td><td'.$TDparams.'>',$allCells).'</td></tr>';
1428 $TDparams=' nowrap="nowrap" class="'.($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6').'" valign="top"';
1429 }
1430 $outTable='<table border="0" cellpadding="2" cellspacing="2">' . $outTable . '</table>';
1431 $outTable .= '<br /><br />' . $GLOBALS['LANG']->getLL('cachedGrouplistsUpdated', true);
1432 $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">' . $tooManyUsers . '</span></strong>':'';
1433 $content.= $this->doc->spacer(10);
1434 $content.= $this->doc->section($GLOBALS['LANG']->getLL('result', true),$outTable,0,1);
1435 }
1436 return $content;
1437 }
1438
1439
1440 /**
1441 * Creates a HTML anchor to the user record
1442 *
1443 * @param string the string used to identify the user (inside the <a>...</a>)
1444 * @param array the BE user record to link
1445 * @return string the HTML anchor
1446 */
1447 function linkUser($str,$rec) {
1448 return '<a href="'.htmlspecialchars($this->MCONF['_']).'&be_user_uid='.$rec['uid'].'">' . htmlspecialchars($str) . '</a>';
1449 }
1450
1451
1452 /**
1453 * Builds a list of all links for a specific element (here: BE user) and returns it for print.
1454 *
1455 * @param string the db table that should be used
1456 * @param array the BE user record to use
1457 * @return string a HTML formatted list of the link
1458 */
1459 function elementLinks($table,$row) {
1460 // Info:
1461 $cells[]='<a href="#" onclick="top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\',\'' . $GLOBALS['BACK_PATH'] . '\'); return false;" title="' . $GLOBALS['LANG']->getLL('showInformation', TRUE) . '">' .
1462 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1463 '</a>';
1464
1465 // Edit:
1466 $params='&edit[' . $table . '][' . $row['uid'] . ']=edit';
1467 $cells[]='<a href="#" onclick="' . t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'],'') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit', TRUE) . '">' .
1468 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
1469 '</a>';
1470
1471 // Hide:
1472 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
1473 if ($row[$hiddenField]) {
1474 $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=0';
1475 $cells[]='<a href="' . $this->doc->issueCommand($params) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:enable', TRUE) . '">' .
1476 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
1477 '</a>';
1478 } else {
1479 $params='&data[' . $table . '][' . $row['uid'] . '][' . $hiddenField . ']=1';
1480 $cells[]='<a href="' . $this->doc->issueCommand($params) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disable', true) . '">' .
1481 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
1482 '</a>';
1483 }
1484
1485 // Delete
1486 $params='&cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
1487 $cells[]='<a href="' . $this->doc->issueCommand($params) . '" onclick="return confirm(unescape(\'' . rawurlencode($GLOBALS['LANG']->getLL('sureToDelete', TRUE)) . '\'));" title="' . $GLOBALS['LANG']->getLL('delete', TRUE) . '">' .
1488 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1489 '</a>';
1490
1491 return implode('',$cells);
1492 }
1493
1494
1495 /**
1496 * Inits all BE-users available, for development ONLY!
1497 *
1498 * @return void
1499 */
1500 function initUsers() {
1501 // Initializing all users in order to generate the usergroup_cached_list
1502 $users = t3lib_BEfunc::getUserNames();
1503
1504 // This is used to test with other users. Development ONLY!
1505 foreach ($users as $r) {
1506 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1507 /* @var $tempBE_USER local_beUserAuth */
1508 $tempBE_USER->OS = TYPO3_OS;
1509 $tempBE_USER->setBeUserByUid($r['uid']);
1510 $tempBE_USER->fetchGroupData();
1511 }
1512 }
1513
1514 /**
1515 * Returns the local path for this string (removes the PATH_site if it is included)
1516 *
1517 * @param string the path that will be checked
1518 * @return string the local path
1519 */
1520 function localPath($str) {
1521 if (substr($str,0,strlen(PATH_site))==PATH_site) {
1522 return substr($str,strlen(PATH_site));
1523 } else {
1524 return $str;
1525 }
1526 }
1527
1528 /**
1529 * Switches to a given user (SU-mode) and then redirects to the start page of the backend to refresh the navigation etc.
1530 *
1531 * @param array BE-user record that will be switched to
1532 * @return void
1533 */
1534 function switchUser($switchUser) {
1535 $uRec=t3lib_BEfunc::getRecord('be_users',$switchUser);
1536 if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin()) {
1537 $updateData['ses_userid'] = $uRec['uid'];
1538 // user switchback
1539 if (t3lib_div::_GP('switchBackUser')) {
1540 $updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']);
1541 }
1542 $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);
1543
1544 $redirectUrl = $GLOBALS['BACK_PATH'] . 'index.php' . ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] ? '' : '?commandLI=1');
1545 t3lib_utility_Http::redirect($redirectUrl);
1546 }
1547 }
1548
1549 /***************************
1550 *
1551 * "WHO IS ONLINE" FUNCTIONS:
1552 *
1553 ***************************/
1554
1555 /**
1556 * @author Martin Kutschker
1557 */
1558 function whoIsOnline() {
1559 $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';
1560 $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';
1561 $where_clause = '';
1562 $orderBy = 'u.username';
1563
1564 if (t3lib_div::testInt($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'])) {
1565 $where_clause .= 'ses_tstamp+' . $GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'] . ' > ' . $GLOBALS['EXEC_TIME'];
1566 } else {
1567 $timeout = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
1568 if ($timeout > 0) {
1569 $where_clause .= 'ses_tstamp+' . $timeout . ' > ' . $GLOBALS['EXEC_TIME'];
1570 }
1571 }
1572 // Fetch active sessions of other users from storage:
1573 $sessions = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select_fields,$from_table,$where_clause,'',$orderBy);
1574 // Process and visualized each active session as a table row:
1575 if (is_array($sessions)) {
1576 foreach ($sessions as $session) {
1577 $ip = $session['ses_iplock'];
1578 $hostName = '';
1579 if ($session['ses_iplock'] == '[DISABLED]' || $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 0) {
1580 $ip = '-';
1581 } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'] == 4) {
1582 $hostName = ' title="' . @gethostbyaddr($session['ses_iplock']) . '"';
1583 } else {
1584 $ip .= str_repeat('.*', 4-$GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP']);
1585 }
1586 $outTable .= '
1587 <tr class="bgColor4" height="17" valign="top">' .
1588 '<td nowrap="nowrap">' .
1589 date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $session['ses_tstamp']) .
1590 '</td>' .
1591 '<td nowrap="nowrap">' .
1592 '<span'.$hostName.'>'.$ip.'</span>' .
1593 '</td>' .
1594 '<td width="130">' .
1595 t3lib_iconWorks::getSpriteIconForRecord('be_users',$session,array('title'=>$session['uid'])).htmlspecialchars($session['username']).'&nbsp;' .
1596 '</td>' .
1597 '<td nowrap="nowrap">'.htmlspecialchars($session['realName']).'&nbsp;&nbsp;</td>' .
1598 '<td nowrap="nowrap">'.$this->elementLinks('be_users',$session).'</td>' .
1599 '<td nowrap="nowrap" valign="top">'.($session['bu_username'] ? '&nbsp;SU from: ' : '').htmlspecialchars($session['bu_username']).'&nbsp;</td>' .
1600 '<td nowrap="nowrap" valign="top">&nbsp;'.htmlspecialchars($session['bu_realName']).'</td>' .
1601 '</tr>';
1602 }
1603 }
1604 // Wrap <table> tag around the rows:
1605 $outTable = '
1606 <table border="0" cellpadding="2" cellspacing="2">
1607 <tr class="bgColor5">
1608 <td valign="top"><strong>' . $GLOBALS['LANG']->getLL('timestamp', true) . '</strong></td>
1609 <td valign="top"><strong>' . $GLOBALS['LANG']->getLL('host', true) . '</strong></td>
1610 <td valign="top" colspan="5"><strong>' . $GLOBALS['LANG']->getLL('username', true) . '</strong></td>
1611 </tr>'.$outTable.'
1612 </table>';
1613
1614 $content.= $this->doc->section($GLOBALS['LANG']->getLL('whoIsOnline', true),$outTable,0,1);
1615 return $content;
1616 }
1617
1618 }
1619
1620
1621 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']) {
1622 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']);
1623 }
1624
1625
1626 // Make instance:
1627 $SOBE = t3lib_div::makeInstance('SC_mod_tools_be_user_index');
1628 $SOBE->init();
1629 $SOBE->main();
1630 $SOBE->printContent();
1631
1632 ?>