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