2005-11-12 Sebastian Kurfuerst <sebastian@garbage-group.de>
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / mod / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 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 * 128: class localPageTree extends t3lib_browseTree
38 * 139: function localPageTree($BE_USER,$WEBMOUNTS='')
39 * 153: function ext_permsC()
40 * 164: function wrapTitle($str,$row)
41 * 176: function PM_ATagWrap($icon,$cmd,$bMark='')
42 * 187: function wrapIcon($icon,$row)
43 * 200: function initializePositionSaving()
44 *
45 *
46 * 221: class printAllPageTree extends localPageTree
47 * 230: function ext_permsC()
48 * 242: function PM_ATagWrap($icon,$cmd,$bMark='')
49 * 253: function wrapIcon($icon,$row)
50 *
51 *
52 * 278: class printAllPageTree_perms extends printAllPageTree
53 * 287: function printTree($treeArr='',$printPath=0)
54 * 330: function ext_printPerms($int)
55 * 348: function ext_groupPerms($row,$firstGroup)
56 *
57 *
58 * 376: class localFolderTree extends t3lib_folderTree
59 * 387: function localFolderTree($BE_USER,$FILEMOUNTS='')
60 * 402: function wrapTitle($str,$row)
61 * 414: function PM_ATagWrap($icon,$cmd,$bMark='')
62 * 425: function wrapIcon($icon,$row)
63 * 438: function initializePositionSaving()
64 *
65 *
66 * 462: class printAllFolderTree extends localFolderTree
67 * 474: function PM_ATagWrap($icon,$cmd,$bMark='')
68 *
69 *
70 * 496: class local_beUserAuth extends t3lib_beUserAuth
71 * 508: function returnWebmounts($pClause='')
72 * 532: function ext_non_readAccessPages()
73 * 555: function user_where_clause()
74 * 567: function ext_printOverview($uInfo,$compareFlags,$printTrees=0)
75 * 831: function ext_getReadableButNonmounted()
76 * 866: function ext_printPerms($int)
77 * 884: function ext_groupPerms($row,$firstGroup)
78 * 899: function ext_compileUserInfoForHash()
79 * 959: function ext_uniqueAndSortList($list)
80 * 973: function ext_ksortArrayRecursive(&$arr)
81 *
82 *
83 * 1000: class SC_mod_tools_be_user_index
84 * 1012: function init()
85 * 1040: function menuConfig()
86 * 1061: function main()
87 * 1097: function printContent()
88 *
89 * SECTION: OTHER FUNCTIONS:
90 * 1119: function compareUsers($compareFlags)
91 * 1297: function linkUser($str,$rec)
92 * 1308: function elementLinks($table,$row)
93 * 1339: function initUsers()
94 * 1359: function localPath($str)
95 * 1371: function switchUser($switchUser)
96 *
97 * TOTAL FUNCTIONS: 38
98 * (This index is automatically created/updated by the extension "extdeveval")
99 *
100 */
101
102 unset($MCONF);
103 require ('conf.php');
104 require ($BACK_PATH.'init.php');
105 require ($BACK_PATH.'template.php');
106 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
107 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
108 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
109 require_once (PATH_t3lib.'class.t3lib_tstemplate.php');
110 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
111 require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php');
112 require_once (PATH_typo3.'class.alt_menu_functions.inc');
113
114 $BE_USER->modAccess($MCONF,1);
115
116
117
118
119
120
121 /**
122 * Base Extension class for printing a page tree (non-browsable though)
123 *
124 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
125 * @package TYPO3
126 * @subpackage tx_beuser
127 */
128 class localPageTree extends t3lib_browseTree {
129 var $expandFirst=0;
130 var $expandAll=0;
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>Page title:</strong></td>
295 '.($printPath?'<td nowrap="nowrap"><strong>Path:</strong></td>':'').'
296 <td nowrap="nowrap" colspan=2><strong>User:</strong></td>
297 <td nowrap="nowrap" colspan=2><strong>Group: &nbsp;</strong></td>
298 <td nowrap="nowrap"><strong>Everybody: &nbsp;</strong></td>
299 <td nowrap="nowrap"><strong>This user: &nbsp;</strong></td>
300 <td nowrap="nowrap"><strong>Main group:</strong></td>
301 </tr>';
302
303 if (!is_array($treeArr)) $treeArr=$this->tree;
304 reset($treeArr);
305 while(list($k,$v)=each($treeArr)) {
306 $col1 = ' bgcolor="'.t3lib_div::modifyHtmlColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"';
307 $row = $v['row'];
308 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'],$this->BE_USER->uc['titleLen']));
309 $lines[]='<tr class="bgColor4">
310 <td nowrap="nowrap">'.$v['HTML'].$title.' &nbsp;</td>
311 '.($printPath?'<td nowrap="nowrap">'.htmlspecialchars(t3lib_BEfunc::getRecordPath ($row['pid'],'',15)).' &nbsp;</td>':'').'
312 <td nowrap="nowrap"'.$col1.'>'.$be_user_Array[$row['perms_userid']]['username'].' &nbsp;</td>
313 <td nowrap="nowrap"'.$col1.'>'.$this->ext_printPerms($row['perms_user']).' &nbsp;</td>
314 <td nowrap="nowrap">'.$be_group_Array[$row['perms_groupid']]['title'].' &nbsp;</td>
315 <td nowrap="nowrap">'.$this->ext_printPerms($row['perms_group']).' &nbsp;</td>
316 <td nowrap="nowrap" align="center" '.$col1.'>'.$this->ext_printPerms($row['perms_everybody']).' &nbsp;</td>
317 <td nowrap="nowrap" align="center">'.($row['editlock'] ? '<img src="'.$this->backPath.'gfx/recordlock_warning2.gif" width="22" height="16" title="Edit lock prevents all editing" alt="" />' : $this->ext_printPerms($this->BE_USER->calcPerms($row))).' &nbsp;</td>
318 <td nowrap="nowrap" align="center">'.$this->ext_printPerms($this->ext_groupPerms($row,$be_group_Array[$this->BE_USER->firstMainGroup])).' &nbsp;</td>
319 </tr>';
320 }
321 return '<table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table>';
322 }
323
324 /**
325 * Print a set of permissions
326 *
327 * @param integer The permissions integer.
328 * @return string HTML formatted.
329 */
330 function ext_printPerms($int) {
331 $str='';
332 $str.= (($int&1)?'*':'<font color="red">x</font>');
333 $str.= (($int&16)?'*':'<font color="red">x</font>');
334 $str.= (($int&2)?'*':'<font color="red">x</font>');
335 $str.= (($int&4)?'*':'<font color="red">x</font>');
336 $str.= (($int&8)?'*':'<font color="red">x</font>');
337
338 return '<b><font color="green">'.$str.'</font></b>';
339 }
340
341 /**
342 * 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
343 *
344 * @param array Page record.
345 * @param array First-group record.
346 * @return integer Permissions.
347 */
348 function ext_groupPerms($row,$firstGroup) {
349 if (is_array($row)) {
350 $out=intval($row['perms_everybody']);
351 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
352 $out|= intval($row['perms_group']);
353 }
354 return $out;
355 }
356 }
357 }
358
359
360
361
362
363
364
365
366
367
368
369 /**
370 * Base Extension class for printing a folder tree (non-browsable though)
371 *
372 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
373 * @package TYPO3
374 * @subpackage tx_beuser
375 */
376 class localFolderTree extends t3lib_folderTree {
377 var $expandFirst=0;
378 var $expandAll=0;
379
380 /**
381 * Constructor for the local folder tree.
382 *
383 * @param object Local backend user (not the GLOBALS[] backend user!!)
384 * @param array Filemounts for the backend user.
385 * @return void
386 */
387 function localFolderTree($BE_USER,$FILEMOUNTS='') {
388 $this->init();
389
390 $this->BE_USER = $BE_USER;
391 $this->MOUNTS = $FILEMOUNTS;
392 $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.
393 }
394
395 /**
396 * Wraps the title.
397 *
398 * @param string [See parent]
399 * @param array [See parent]
400 * @return string
401 */
402 function wrapTitle($str,$row) {
403 return $str;
404 }
405
406 /**
407 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon!
408 *
409 * @param string [See parent]
410 * @param string [See parent]
411 * @param string [See parent]
412 * @return string
413 */
414 function PM_ATagWrap($icon,$cmd,$bMark='') {
415 return '';
416 }
417
418 /**
419 * 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.
420 *
421 * @param string Icon image tag.
422 * @param array Row.
423 * @return string Icon with title attribute added.
424 */
425 function wrapIcon($icon,$row) {
426 // Add title attribute to input icon tag
427 $title = $GLOBALS['SOBE']->localPath($row['path']);
428 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.htmlspecialchars($title).'"' : ''));
429
430 return $theIcon;
431 }
432
433 /**
434 * This will make sure that no position data is acquired from the BE_USER uc variable.
435 *
436 * @return void
437 */
438 function initializePositionSaving() {
439 $this->stored=array();
440 }
441 }
442
443
444
445
446
447
448
449
450
451
452
453
454
455 /**
456 * Extension class for printing a folder tree: All folders
457 *
458 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
459 * @package TYPO3
460 * @subpackage tx_beuser
461 */
462 class printAllFolderTree extends localFolderTree {
463 var $expandFirst=1;
464 var $expandAll=1;
465
466 /**
467 * Wraps the plus/minus icon - in this case we just return blank which means we STRIP AWAY the plus/minus icon!
468 *
469 * @param string [See parent]
470 * @param string [See parent]
471 * @param string [See parent]
472 * @return string
473 */
474 function PM_ATagWrap($icon,$cmd,$bMark='') {
475 return $icon;
476 }
477 }
478
479
480
481
482
483
484
485
486
487
488
489 /**
490 * Extension class of beuserauth class.
491 *
492 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
493 * @package TYPO3
494 * @subpackage tx_beuser
495 */
496 class local_beUserAuth extends t3lib_beUserAuth {
497 var $ext_pageIdsFromMounts=''; // List of mounted page ids (from browsetree class when selecting mountpoints)
498 var $ext_non_readAccessPageArray=array(); // Storage for non-readable webmounts, see returnWebmounts()
499
500 /**
501 * Returns an array of the webmounts for the user, with non-readable webmounts filtered out.
502 * If there are non-readable webmounts they are registered in $this->ext_non_readAccessPageArray
503 * (Extending function in parent class)
504 *
505 * @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".
506 * @return array Webmounts id's
507 */
508 function returnWebmounts($pClause='') {
509
510 // Get array of webmounts:
511 $webmounts = (string)($this->groupData['webmounts'])!='' ? explode(',',$this->groupData['webmounts']) : Array();
512
513 // Get select clause:
514 $pClause=$pClause?$pClause:$this->getPagePermsClause(1);
515
516 // Traverse mounts, check if they are readable:
517 foreach($webmounts as $k => $id) {
518 $rec=t3lib_BEfunc::getRecord('pages',$id,'*',' AND '.$pClause);
519 if (!is_array($rec)) {
520 $this->ext_non_readAccessPageArray[$id]=t3lib_BEfunc::getRecord('pages',$id);
521 unset($webmounts[$k]);
522 }
523 }
524 return $webmounts;
525 }
526
527 /**
528 * Based on the content of ->ext_non_readAccessPageArray (see returnWebmounts()) it generates visually formatted information about these non-readable mounts.
529 *
530 * @return string HTML content showing which DB-mounts were not accessible for the user
531 */
532 function ext_non_readAccessPages() {
533 $lines=array();
534
535 foreach($this->ext_non_readAccessPageArray as $pA) {
536 if ($pA) $lines[]=t3lib_BEfunc::getRecordPath($pA['uid'],'',15);
537 }
538 if (count($lines)) {
539 return '<table bgcolor="red" border="0" cellpadding="0" cellspacing="0">
540 <tr>
541 <td align="center"><font color="white"><strong>The user has no read access to these DB-mounts!</strong></font></td>
542 </tr>
543 <tr>
544 <td>'.implode('</td></tr><tr><td>',$lines).'</td>
545 </tr>
546 </table>';
547 }
548 }
549
550 /**
551 * This returns the where-clause needed to select the user with respect flags like deleted, hidden, starttime, endtime
552 *
553 * @return string
554 */
555 function user_where_clause() {
556 return 'AND pid=0 ';
557 }
558
559 /**
560 * Creates the overview information based on which analysis topics were selected.
561 *
562 * @param array Array of analysis topics
563 * @param array Array of the selected analysis topics (from session variable somewhere)
564 * @param boolean If set, the full trees of pages/folders are printed.
565 * @return array Array with accumulated HTML content.
566 */
567 function ext_printOverview($uInfo,$compareFlags,$printTrees=0) {
568 // Prepare for filemount and db-mount
569 if ($printTrees) { // ... this is if we see the detailed view for a user:
570 // Page tree object:
571 $className=t3lib_div::makeInstanceClassName(!$this->isAdmin() ? 'printAllPageTree_perms' : 'printAllPageTree');
572 $pagetree = new $className($this,$this->returnWebmounts()); // Here, only readable webmounts are returned (1=1)
573 $pagetree->addField('perms_user',1);
574 $pagetree->addField('perms_group',1);
575 $pagetree->addField('perms_everybody',1);
576 $pagetree->addField('perms_userid',1);
577 $pagetree->addField('perms_groupid',1);
578 $pagetree->addField('editlock',1);
579
580 // Folder tree object:
581 $className=t3lib_div::makeInstanceClassName('printAllFolderTree');
582 $foldertree = new $className($this,$this->returnFilemounts());
583 } else {
584 // Page tree object:
585 $className=t3lib_div::makeInstanceClassName('localPageTree');
586 $pagetree = new $className($this,$this->returnWebmounts('1=1')); // Here, ALL webmounts are returned (1=1)
587
588 // Folder tree object:
589 $className=t3lib_div::makeInstanceClassName('localFolderTree');
590 $foldertree = new $className($this,$this->returnFilemounts());
591 }
592
593 // Names for modules:
594 $modNames = array(
595 'web' => 'Web',
596 'web_layout' => 'Page',
597 'web_modules' => 'Modules',
598 'web_info' => 'Info',
599 'web_perms' => 'Access',
600 'web_func' => 'Func',
601 'web_list' => 'List',
602 'web_ts' => 'Template',
603 'file' => 'File',
604 'file_list' => 'List',
605 'file_images' => 'Images',
606 'doc' => 'Doc.',
607 'help' => 'Help',
608 'help_about' => 'About',
609 'help_quick' => 'User manual',
610 'help_welcome' => 'Welcome',
611 'user' => 'User',
612 'user_setup' => 'Setup',
613 'user_task' => 'Task center'
614 );
615
616 // Traverse the enabled analysis topics:
617 $out=array();
618 foreach($uInfo as $k => $v) {
619 if ($compareFlags[$k]) {
620 switch($k) {
621 case 'filemounts':
622 $out[$k] = $foldertree->getBrowsableTree();
623 break;
624 case 'webmounts':
625 // Print webmounts:
626 $pagetree->addSelfId=1;
627 $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)
628 $out[$k].= $pagetree->getBrowsableTree(); // Add HTML for readable webmounts.
629 $this->ext_pageIdsFromMounts=implode(',',array_unique($pagetree->ids)); // List of mounted page ids
630 break;
631 case 'tempPath':
632 $out[$k] = $GLOBALS['SOBE']->localPath($v);
633 break;
634 case 'pagetypes_select':
635 $pageTypes = explode(',',$v);
636 reset($pageTypes);
637 while(list($kk,$vv)=each($pageTypes)) {
638 $pageTypes[$kk]=$GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('pages','doktype',$vv));
639 }
640 $out[$k] = implode('<br />',$pageTypes);
641 break;
642 case 'tables_select':
643 case 'tables_modify':
644 $tables = explode(',',$v);
645 reset($tables);
646 while(list($kk,$vv)=each($tables)) {
647 if ($vv) {
648 $tables[$kk]='<span class="nobr">'.t3lib_iconWorks::getIconImage($vv,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$vv]['ctrl']['title']).'</span>';
649 }
650 }
651 $out[$k] = implode('<br />',$tables);
652 break;
653 case 'non_exclude_fields':
654 $nef = explode(',',$v);
655 reset($nef);
656 $table='';
657 $pout=array();
658 while(list($kk,$vv)=each($nef)) {
659 if ($vv) {
660 list($thisTable,$field) = explode(':',$vv);
661 if ($thisTable!=$table) {
662 $table=$thisTable;
663 t3lib_div::loadTCA($table);
664 $pout[]='<span class="nobr">'.t3lib_iconWorks::getIconImage($table,array(),$GLOBALS['BACK_PATH'],'align="top"').$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']).'</span>';
665 }
666 if ($GLOBALS['TCA'][$table]['columns'][$field]) {
667 $pout[]='<span class="nobr"> - '.ereg_replace(':$','',$GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$field]['label'])).'</span>';
668 }
669 }
670 }
671 $out[$k] = implode('<br />',$pout);
672 break;
673 case 'groupList':
674 case 'firstMainGroup':
675 $uGroups = explode(',',$v);
676 reset($uGroups);
677 $table='';
678 $pout=array();
679 while(list($kk,$vv)=each($uGroups)) {
680 if ($vv) {
681 $uGRow = t3lib_BEfunc::getRecord('be_groups',$vv);
682 $pout[]='<tr><td nowrap="nowrap">'.t3lib_iconWorks::getIconImage('be_groups',$uGRow,$GLOBALS['BACK_PATH'],'align="top"').'&nbsp;'.htmlspecialchars($uGRow['title']).'&nbsp;&nbsp;</td><td width=1% nowrap="nowrap">'.$GLOBALS['SOBE']->elementLinks('be_groups',$uGRow).'</td></tr>';
683 }
684 }
685 $out[$k] = '<table border="0" cellpadding="0" cellspacing="0" width="100%">'.implode('',$pout).'</table>';
686 break;
687 case 'modules':
688 $mods = explode(',',$v);
689 reset($mods);
690 $mainMod='';
691 $pout=array();
692 while(list($kk,$vv)=each($mods)) {
693 if ($vv) {
694 list($thisMod,$subMod) = explode('_',$vv);
695 if ($thisMod!=$mainMod) {
696 $mainMod=$thisMod;
697 $pout[]='<span class="nobr">'.($modNames[$mainMod]?$modNames[$mainMod]:$mainMod).'</span>';
698 }
699 if ($subMod) {
700 $pout[]='<span class="nobr"> - '.($modNames[$mainMod.'_'.$subMod]?$modNames[$mainMod.'_'.$subMod]:$mainMod.'_'.$subMod).'</span>';
701 }
702 }
703 }
704 $out[$k] = implode('<br />',$pout);
705 break;
706 case 'userTS':
707
708 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext'); // Defined global here!
709 $tmpl->tt_track = 0; // Do not log time-performance information
710
711 $tmpl->fixedLgd=0;
712 $tmpl->linkObjects=0;
713 $tmpl->bType='';
714 $tmpl->ext_expandAllNotes=1;
715 $tmpl->ext_noPMicons=1;
716 $out[$k] = $tmpl->ext_getObjTree($v,'','');
717 break;
718 case 'userTS_hl':
719 $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
720 $tsparser->lineNumberOffset=0;
721 $out[$k] = $tsparser->doSyntaxHighlight($v,0,1);
722 break;
723 case 'explicit_allowdeny':
724
725 // Explode and flip values:
726 $nef = array_flip(explode(',',$v));
727 $pout = array();
728
729 $theTypes = t3lib_BEfunc::getExplicitAuthFieldValues();
730
731 // Icons:
732 $icons = array(
733 'ALLOW' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_ok2.gif','').' class="absmiddle" alt="" />',
734 'DENY' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_fatalerror.gif','').' class="absmiddle" alt="" />',
735 );
736
737 // Traverse types:
738 foreach($theTypes as $tableFieldKey => $theTypeArrays) {
739 if (is_array($theTypeArrays['items'])) {
740 $pout[] = '<b>'.$theTypeArrays['tableFieldLabel'].'</b>';
741 // Traverse options for this field:
742 foreach($theTypeArrays['items'] as $itemValue => $itemContent) {
743 $v = $tableFieldKey.':'.$itemValue.':'.$itemContent[0];
744 if (isset($nef[$v])) {
745 unset($nef[$v]);
746 $pout[] = $icons[$itemContent[0]].'['.$itemContent[2].'] '.$itemContent[1];
747 } else {
748 $pout[] = '<em style="color: #666666;">'.$icons[($itemContent[0]=='ALLOW' ? 'DENY' : 'ALLOW')].'['.$itemContent[2].'] '.$itemContent[1].'</em>';
749 }
750 }
751 $pout[] = '';
752 }
753 }
754
755 // Add remaining:
756 if (count($nef)) {
757 $pout = array_merge($pout, array_keys($nef));
758 }
759
760 // Implode for display:
761 $out[$k] = implode('<br />',$pout);
762 break;
763 case 'allowed_languages':
764
765 // Explode and flip values:
766 $nef = array_flip(explode(',',$v));
767 $pout = array();
768
769 // Get languages:
770 $items = t3lib_BEfunc::getSystemLanguages();
771
772 // Traverse values:
773 foreach($items as $iCfg) {
774 if (isset($nef[$iCfg[1]])) {
775 unset($nef[$iCfg[1]]);
776 $icon = '<img src="'.$GLOBALS['BACK_PATH'].$iCfg[2].'" class="absmiddle" style="margin-right: 5px;" alt="" />';
777 $pout[] = $icon.$iCfg[0];
778 }
779 }
780
781 // Add remaining:
782 if (count($nef)) {
783 $pout = array_merge($pout, array_keys($nef));
784 }
785
786 // Implode for display:
787 $out[$k] = implode('<br />',$pout);
788 break;
789 case 'workspace_perms':
790 $out[$k] = implode('<br/>',explode(', ',t3lib_BEfunc::getProcessedValue('be_users','workspace_perms',$v)));
791 break;
792 case 'custom_options':
793
794 // Explode and flip values:
795 $nef = array_flip(explode(',',$v));
796 $pout = array();
797
798 // Initialize:
799 $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'];
800 if (is_array($customOptions)) {
801 foreach($customOptions as $coKey => $coValue) {
802 if (is_array($coValue['items'])) {
803 // Traverse items:
804 foreach($coValue['items'] as $itemKey => $itemCfg) {
805 $v = $coKey.':'.$itemKey;
806 if (isset($nef[$v])) {
807 unset($nef[$v]);
808 $pout[] = $GLOBALS['LANG']->sl($coValue['header']).' / '.$GLOBALS['LANG']->sl($itemCfg[0]);
809 }
810 }
811 }
812 }
813 }
814
815 // Add remaining:
816 if (count($nef)) {
817 $pout = array_merge($pout, array_keys($nef));
818 }
819
820 // Implode for display:
821 $out[$k] = implode('<br />',$pout);
822 break;
823 }
824 }
825 }
826 return $out;
827 }
828
829 /**
830 * Get HTML code for the pages which were mounted, but NOT readable!
831 *
832 * @return string HTML code.
833 */
834 function ext_getReadableButNonmounted() {
835
836 // List of page id mounts which ARE mounted (and should therefore not be selected)
837 if (!$this->ext_pageIdsFromMounts) {
838 $this->ext_pageIdsFromMounts=0;
839 }
840
841 // User and group names:
842 $be_user_Array = t3lib_BEfunc::getUserNames();
843 $be_group_Array = t3lib_BEfunc::getGroupNames();
844
845 // Create query:
846 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
847 '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':''),
848 'pages',
849 'uid NOT IN ('.$this->ext_pageIdsFromMounts.') AND '.$this->getPagePermsClause(1).t3lib_BEfunc::deleteClause('pages')
850 );
851 $dat = array();
852 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
853 $dat[] = array(
854 'row'=>$row,
855 'HTML'=>t3lib_iconWorks::getIconImage('pages',$row,$GLOBALS['BACK_PATH'],'align="top" title="['.$row['uid'].']"') // .htmlspecialchars($row['title'])
856 );
857 }
858 $className=t3lib_div::makeInstanceClassName('printAllPageTree_perms');
859 $pp = new $className($this);
860 return $pp->printTree($dat,1);
861 }
862
863 /**
864 * Print a set of permissions
865 *
866 * @param integer The permissions integer.
867 * @return string HTML formatted.
868 */
869 function ext_printPerms($int) {
870 $str='';
871 $str.= (($int&1)?'*':'<font color="red">x</font>');
872 $str.= (($int&16)?'*':'<font color="red">x</font>');
873 $str.= (($int&2)?'*':'<font color="red">x</font>');
874 $str.= (($int&4)?'*':'<font color="red">x</font>');
875 $str.= (($int&8)?'*':'<font color="red">x</font>');
876
877 return '<b><font color="green">'.$str.'</font></b>';
878 }
879
880 /**
881 * 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
882 *
883 * @param array Page record.
884 * @param array First-group record.
885 * @return integer Permissions.
886 */
887 function ext_groupPerms($row,$firstGroup) {
888 if (is_array($row)) {
889 $out=intval($row['perms_everybody']);
890 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
891 $out|= intval($row['perms_group']);
892 }
893 return $out;
894 }
895 }
896
897 /**
898 * Creates uInfo array for the user.
899 *
900 * @return array Array with the information of the user for each analysis topic.
901 */
902 function ext_compileUserInfoForHash() {
903 $uInfo=array();
904
905 // Filemounts:
906 $uInfo['filemounts']=$this->ext_uniqueAndSortList(implode(',',array_keys($this->groupData['filemounts'])));
907
908 // DBmounts:
909 $uInfo['webmounts']=$this->ext_uniqueAndSortList($this->groupData['webmounts']);
910
911 // Sharing Upload Folder
912 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
913 $fileProcessor->init($this->groupData['filemounts'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
914 $uInfo['tempPath'] = $fileProcessor->findTempFolder(); // The closest TEMP-path is found
915
916 // First Main Group:
917 $uInfo['firstMainGroup']=$this->firstMainGroup;
918
919 // Group List:
920 // $uInfo['groupList']=$this->ext_uniqueAndSortList($this->groupList);
921 $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.
922
923 // Page Types:
924 $uInfo['pagetypes_select']=$this->ext_uniqueAndSortList($this->groupData['pagetypes_select']);
925
926 // Tables select:
927 $uInfo['tables_select']=$this->ext_uniqueAndSortList($this->groupData['tables_select'].','.$this->groupData['tables_modify']);
928
929 // Tables modify:
930 $uInfo['tables_modify']=$this->ext_uniqueAndSortList($this->groupData['tables_modify']);
931
932 // Non-exclude fields:
933 $uInfo['non_exclude_fields']=$this->ext_uniqueAndSortList($this->groupData['non_exclude_fields']);
934
935 // Explicit Allow/Deny:
936 $uInfo['explicit_allowdeny']=$this->ext_uniqueAndSortList($this->groupData['explicit_allowdeny']);
937
938 // Limit to languages:
939 $uInfo['allowed_languages']=$this->ext_uniqueAndSortList($this->groupData['allowed_languages']);
940
941 // Workspace permissions
942 $uInfo['workspace_perms']=$this->ext_uniqueAndSortList($this->groupData['workspace_perms']);
943
944 // Custom options:
945 $uInfo['custom_options']=$this->ext_uniqueAndSortList($this->groupData['custom_options']);
946
947 // Modules:
948 $uInfo['modules']=$this->ext_uniqueAndSortList($this->groupData['modules']);
949
950 // User TS:
951 $this->ext_ksortArrayRecursive($this->userTS);
952 $uInfo['userTS'] = $this->userTS;
953
954 $uInfo['userTS_hl'] = $this->userTS_text;
955
956 return $uInfo;
957 }
958
959 /**
960 * Sorts a commalist of values and removes duplicates.
961 *
962 * @param string Commalist.
963 * @return string Sorted, unique commalist.
964 */
965 function ext_uniqueAndSortList($list) {
966 $uList=t3lib_div::trimExplode(',',$list,1);
967 sort($uList);
968 $uList=array_unique($uList);
969 $uList=implode(',',$uList);
970 return $uList;
971 }
972
973 /**
974 * Key sort input array recursively.
975 *
976 * @param array Multidimensional array (value by reference!)
977 * @return void
978 */
979 function ext_ksortArrayRecursive(&$arr) {
980 krsort($arr);
981 reset($arr);
982 while(list($k,$v)=each($arr)) {
983 if (is_array($v)) $this->ext_ksortArrayRecursive($arr[$k]);
984 }
985 }
986 }
987
988
989
990
991
992
993
994
995
996
997
998
999 /**
1000 * Main script class
1001 *
1002 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1003 * @package TYPO3
1004 * @subpackage tx_beuser
1005 */
1006 class SC_mod_tools_be_user_index {
1007 var $MCONF=array();
1008 var $MOD_MENU=array();
1009 var $MOD_SETTINGS=array();
1010 var $doc;
1011
1012 var $include_once=array();
1013 var $content;
1014
1015 /**
1016 * @return [type] ...
1017 */
1018 function init() {
1019 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
1020 $this->MCONF = $GLOBALS['MCONF'];
1021
1022 $this->menuConfig();
1023 $this->switchUser(t3lib_div::_GP('SwitchUser'));
1024
1025
1026 // **************************
1027 // Initializing
1028 // **************************
1029 $this->doc = t3lib_div::makeInstance('noDoc');
1030 $this->doc->form='<form action="" method="POST">';
1031 $this->doc->backPath = $BACK_PATH;
1032 // JavaScript
1033 $this->doc->JScode = $this->doc->wrapScriptTags('
1034 script_ended = 0;
1035 function jumpToUrl(URL) { //
1036 document.location = URL;
1037 }
1038 ' . $this->doc->redirectUrls());
1039 }
1040
1041 /**
1042 * [Describe function...]
1043 *
1044 * @return [type] ...
1045 */
1046 function menuConfig() {
1047 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
1048
1049 // MENU-ITEMS:
1050 // If array, then it's a selector box menu
1051 // If empty string it's just a variable, that'll be saved.
1052 // Values NOT in this array will not be saved in the settings-array for the module.
1053 $this->MOD_MENU = array(
1054 'function' => array(
1055 'compare' => 'Compare User Settings'
1056 )
1057 );
1058 // CLEANSE SETTINGS
1059 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
1060 }
1061
1062 /**
1063 * [Describe function...]
1064 *
1065 * @return [type] ...
1066 */
1067 function main() {
1068 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
1069
1070 $this->content='';
1071 $this->content.=$this->doc->startPage('Backend User Administration');
1072
1073 $menu=t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
1074
1075 $this->content.=$this->doc->header('Backend User Administration');
1076 $this->content.=$this->doc->spacer(5);
1077 $this->content.=$this->doc->section('',$menu).$this->doc->divider(5);
1078
1079 switch($this->MOD_SETTINGS['function']) {
1080 case 'compare':
1081 if (t3lib_div::_GP('ads')) {
1082 $compareFlags = t3lib_div::_GP('compareFlags');
1083 $BE_USER->pushModuleData('tools_beuser/index.php/compare',$compareFlags);
1084 } else {
1085 $compareFlags = $BE_USER->getModuleData('tools_beuser/index.php/compare','ses');
1086 }
1087 $this->content.=$this->compareUsers($compareFlags);
1088 break;
1089 }
1090
1091
1092 if ($BE_USER->mayMakeShortcut()) {
1093 $this->content.=$this->doc->spacer(20).
1094 $this->doc->section('',$this->doc->makeShortcutIcon('be_user_uid,compareFlags','function',$this->MCONF['name']));
1095 }
1096 }
1097
1098 /**
1099 * [Describe function...]
1100 *
1101 * @return [type] ...
1102 */
1103 function printContent() {
1104
1105 $this->content.=$this->doc->endPage();
1106 echo $this->content;
1107 }
1108
1109
1110
1111
1112
1113
1114
1115 /***************************
1116 *
1117 * OTHER FUNCTIONS:
1118 *
1119 ***************************/
1120
1121 /**
1122 * @param [type] $compareFlags: ...
1123 * @return [type] ...
1124 */
1125 function compareUsers($compareFlags) {
1126 global $SOBE;
1127 // Menu:
1128 $options = array(
1129 'filemounts' => 'Filemounts',
1130 'webmounts' => 'Webmounts',
1131 'tempPath' => 'Default upload path',
1132 'firstMainGroup' => 'Main user group',
1133 'groupList' => 'Member of groups',
1134 'pagetypes_select' => 'Page types access',
1135 'tables_select' => 'Select tables',
1136 'tables_modify' => 'Modify tables',
1137 'non_exclude_fields' => 'Non-exclude fields',
1138 'explicit_allowdeny' => 'Explicit Allow/Deny',
1139 'allowed_languages' => 'Limit to languages',
1140 'workspace_perms' => 'Workspace permissions',
1141 'custom_options' => 'Custom options',
1142 'modules' => 'Modules',
1143 'userTS' => 'TSconfig',
1144 'userTS_hl' => 'TSconfig HL',
1145 );
1146
1147 $be_user_uid = t3lib_div::_GP('be_user_uid');
1148 if ($be_user_uid) {
1149 // This is used to test with other users. Development ONLY!
1150 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1151 $tempBE_USER->userTS_dontGetCached=1;
1152 $tempBE_USER->OS = TYPO3_OS;
1153 $tempBE_USER->setBeUserByUid($be_user_uid);
1154 $tempBE_USER->fetchGroupData();
1155
1156 $uInfo = $tempBE_USER->ext_compileUserInfoForHash();
1157 $uInfo_dat = $tempBE_USER->ext_printOverview($uInfo,$options,1);
1158
1159 $lines=array();
1160 reset($options);
1161 while(list($kk,$vv)=each($options)) {
1162 if ($kk=='modules') {
1163 $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
1164 $loadModules->load($GLOBALS['TBE_MODULES'],$tempBE_USER);
1165 $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
1166 $uInfo_dat[$kk] = $alt_menuObj->topMenu($loadModules->modules,1,$GLOBALS['BACK_PATH']);
1167 }
1168 $lines[]='<tr class="bgColor4">
1169 <td nowrap="nowrap" valign="top">'.$vv.':&nbsp;&nbsp;</td>
1170 <td>'.$uInfo_dat[$kk].'&nbsp;</td>
1171 </tr>';
1172
1173 if ($kk=='webmounts' && !$tempBE_USER->isAdmin()) {
1174 $lines[]='<tr class="bgColor4">
1175 <td nowrap="nowrap" valign="top">Non-mounted readable pages:&nbsp;&nbsp;</td>
1176 <td>'.$tempBE_USER->ext_getReadableButNonmounted().'&nbsp;</td>
1177 </tr>';
1178 }
1179 }
1180
1181 $outTable = '<table border="0" cellpadding="1" cellspacing="1"><tr class="bgColor5"><td>'.t3lib_iconWorks::getIconImage('be_users',$tempBE_USER->user,$GLOBALS['BACK_PATH'],'class="absmiddle" title="'.$tempBE_USER->user['uid'].'"').$tempBE_USER->user['username'].'</td>';
1182 $outTable.= '<td>'.$tempBE_USER->user['realName'].($tempBE_USER->user['email'] ? ', <a href="mailto:'.$tempBE_USER->user['email'].'">'.$tempBE_USER->user['email'].'</a>' : '').'</td>';
1183 $outTable.= '<td>'.$this->elementLinks('be_users',$tempBE_USER->user).'</td></tr></table>';
1184 $outTable.= '<strong><a href="index.php">&lt; Back to overview</a></strong><br />';
1185
1186 $outTable.= '<br /><table border="0" cellpadding="2" cellspacing="1">'.implode('',$lines).'</table>';
1187 $content.= $this->doc->section('User info',$outTable,0,1);
1188 } else {
1189 reset($options);
1190 $menu=array();
1191 while(list($kk,$vv)=each($options)) {
1192 $menu[]='<input type="checkbox" value="1" name="compareFlags['.$kk.']"'.($compareFlags[$kk]?' checked="checked"':'').'>'.htmlspecialchars($vv);
1193 }
1194 $outCode = 'Group by:<br />'.implode('<br />',$menu);
1195 $outCode.='<br /><input type="submit" name="ads" value="Update">';
1196 $content = $this->doc->section('Group and Compare Users',$outCode,0,1);
1197
1198
1199 // Traverse all users
1200 $users = t3lib_BEfunc::getUserNames();
1201 $comparation=array();
1202 // debug($users);
1203 reset($users);
1204 $counter=0;
1205
1206
1207 $offset=0;
1208 $numberAtTime=1000;
1209 $tooManyUsers='';
1210
1211 while(list(,$r)=each($users)) {
1212 if ($counter>=$offset) {
1213 // This is used to test with other users. Development ONLY!
1214 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1215 $tempBE_USER->OS = TYPO3_OS;
1216 $tempBE_USER->setBeUserByUid($r['uid']);
1217 $tempBE_USER->fetchGroupData();
1218
1219 // Making group data
1220 $md5pre='';
1221 $menu=array();
1222 $uInfo = $tempBE_USER->ext_compileUserInfoForHash();
1223 reset($options);
1224 while(list($kk,$vv)=each($options)) {
1225 if ($compareFlags[$kk]) {
1226 $md5pre.=serialize($uInfo[$kk]).'|';
1227 }
1228 }
1229 // setting md5:
1230 $md5=md5($md5pre);
1231 if (!isset($comparation[$md5])) {
1232 $comparation[$md5]=$tempBE_USER->ext_printOverview($uInfo,$compareFlags);
1233 $comparation[$md5]['users']=array();
1234 }
1235 $comparation[$md5]['users'][]=$tempBE_USER->user; //array('uid'=>$r['uid'],'username'=>$r['username'],'realName'=>$tempBE_USER->user['realName'],'email'=>$tempBE_USER->user['email'],'admin'=>$tempBE_USER->user['admin']);
1236 unset($tempBE_USER);
1237 }
1238 $counter++;
1239 if ($counter>=($numberAtTime+$offset)) {
1240 $tooManyUsers='There were more than '.$numberAtTime.' users (total: '.count($users).') and this tool can display only '.$numberAtTime.' at a time!';
1241 break;
1242 }
1243 }
1244
1245 // Print the groups:
1246 $allGroups=array();
1247 // Header:
1248 $allCells = array();
1249 reset($options);
1250
1251 $link_createNewUser='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[be_users][0]=new',$this->doc->backPath,-1)).'">'.
1252 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/new_el.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('new',1).'" alt="" />'.
1253 '</a>';
1254
1255 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><td><b>Usernames:</b></td><td width="12">'.$link_createNewUser.'</td></tr></table>';
1256
1257 while(list($kk,$vv)=each($options)) {
1258 if ($compareFlags[$kk]) {
1259 $allCells[$kk] = '<b>'.$vv.':</b>';
1260 }
1261 }
1262 $allGroups[]=$allCells;
1263
1264 reset($comparation);
1265 while(list(,$dat)=each($comparation)) {
1266 $allCells = array();
1267
1268 $uListArr=array();
1269 reset($dat['users']);
1270 while(list(,$uDat)=each($dat['users'])) {
1271 $uListArr[] = '<tr><td width="130">'.t3lib_iconWorks::getIconImage('be_users',$uDat,$GLOBALS['BACK_PATH'],'align="top" title="'.$uDat['uid'].'"').$this->linkuser($uDat['username'],$uDat).'&nbsp;&nbsp;</td><td nowrap="nowrap">'.$this->elementLinks('be_users',$uDat).
1272 '<a href="'.t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'])).'" target="_top"><img src="'.$GLOBALS['BACK_PATH'].'gfx/su.gif" width="18" height="11" border="0" align="top" title="'.htmlspecialchars('Switch User to: '.$uDat['username']).'" alt="" /></a>'.
1273 '<a href="'.t3lib_div::linkThisScript(array('SwitchUser'=>$uDat['uid'], 'switchBackUser' => 1)).'" target="_top"><img src="'.$GLOBALS['BACK_PATH'].'gfx/su.gif" width="18" height="11" border="0" align="top" title="'.htmlspecialchars('Switch User to: '.$uDat['username']).' [SU-mode]" alt="" style="background-color:red;" /></a>'.
1274 '</td></tr>';
1275 }
1276 $allCells['USERS'] = '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.implode('',$uListArr).'</table>';
1277
1278 reset($options);
1279 while(list($kk,$vv)=each($options)) {
1280 if ($compareFlags[$kk]) {
1281 $allCells[$kk] = $dat[$kk];
1282 }
1283 }
1284 $allGroups[]=$allCells;
1285 }
1286
1287 // Make table
1288 $outTable='';
1289 reset($allGroups);
1290 $TDparams=' nowrap="nowrap" class="bgColor5" valign="top"';
1291 while(list(,$allCells)=each($allGroups)) {
1292 $outTable.='<tr><td'.$TDparams.'>'.implode('</td><td'.$TDparams.'>',$allCells).'</td></tr>';
1293 $TDparams=' nowrap="nowrap" class="bgColor4" valign="top"';
1294 }
1295 $outTable='<table border="0" cellpadding="2" cellspacing="2">'.$outTable.'</table>';
1296 $outTable.=fw('<br /><br />(All cached group lists updated.)');
1297 $outTable.=$tooManyUsers?'<br /><br /><strong><span class="typo3-red">'.$tooManyUsers.'</span></strong>':'';
1298 $content.= $this->doc->spacer(10);
1299 $content.= $this->doc->section('Result',$outTable,0,1);
1300 }
1301 return $content;
1302 }
1303
1304 /**
1305 * [Describe function...]
1306 *
1307 * @param [type] $str: ...
1308 * @param [type] $rec: ...
1309 * @return [type] ...
1310 */
1311 function linkUser($str,$rec) {
1312 return '<a href="index.php?be_user_uid='.$rec['uid'].'">'.$str.'</a>';
1313 }
1314
1315 /**
1316 * [Describe function...]
1317 *
1318 * @param [type] $table: ...
1319 * @param [type] $row: ...
1320 * @return [type] ...
1321 */
1322 function elementLinks($table,$row) {
1323 global $TCA;
1324 // Info:
1325 $cells[]='<a href="#" onclick="top.launchView(\''.$table.'\', \''.$row['uid'].'\',\''.$GLOBALS['BACK_PATH'].'\'); return false;"><img src="'.$GLOBALS['BACK_PATH'].'gfx/zoom2.gif" width="12" height="12" border="0" align="top" title="Show information" alt="" /></a>';
1326
1327 // Edit:
1328 $params='&edit['.$table.']['.$row['uid'].']=edit';
1329 $cells[]='<a href="#" onclick="'.t3lib_BEfunc::editOnClick($params,$GLOBALS['BACK_PATH'],'').'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/edit2.gif" width="11" height="12" border="0" align="top" title="Edit" alt="" /></a>';
1330
1331 // Hide:
1332 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1333 if ($row[$hiddenField]) {
1334 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
1335 $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/button_unhide.gif" width="11" height="10" border="0" title="Disable" align="top" alt="" /></a>';
1336 } else {
1337 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
1338 $cells[]='<a href="'.$this->doc->issueCommand($params).'"><img src="'.$GLOBALS['BACK_PATH'].'gfx/button_hide.gif" width="11" height="10" border="0" title="Disable" align="top" alt="" /></a>';
1339 }
1340
1341 // Delete
1342 $params='&cmd['.$table.']['.$row['uid'].'][delete]=1';
1343 $cells[]='<a href="'.$this->doc->issueCommand($params).'" onclick="return confirm(unescape(\''.rawurlencode('Are you sure you want to delete this element?').'\'));"><img src="'.$GLOBALS['BACK_PATH'].'gfx/garbage.gif" width="11" height="12" border="0" align="top" title="Delete(!)" alt="" /></a>';
1344
1345 return implode('',$cells);
1346 }
1347
1348 /**
1349 * [Describe function...]
1350 *
1351 * @return [type] ...
1352 */
1353 function initUsers() {
1354 // Initializing all users in order to generate the usergroup_cached_list
1355 $users = t3lib_BEfunc::getUserNames();
1356 //debug($users);
1357 reset($users);
1358 while(list(,$r)=each($users)) {
1359 // This is used to test with other users. Development ONLY!
1360 $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth'); // New backend user object
1361 $tempBE_USER->OS = TYPO3_OS;
1362 $tempBE_USER->setBeUserByUid($r['uid']);
1363 $tempBE_USER->fetchGroupData();
1364 }
1365 }
1366
1367 /**
1368 * [Describe function...]
1369 *
1370 * @param [type] $str: ...
1371 * @return [type] ...
1372 */
1373 function localPath($str) {
1374 if (substr($str,0,strlen(PATH_site))==PATH_site) {
1375 return substr($str,strlen(PATH_site));
1376 } else return $str;
1377 }
1378
1379 /**
1380 * [Describe function...]
1381 *
1382 * @param [type] $switchUser: ...
1383 * @return [type] ...
1384 */
1385 function switchUser($switchUser) {
1386 $uRec=t3lib_BEfunc::getRecord('be_users',$switchUser);
1387 if (is_array($uRec) && $GLOBALS['BE_USER']->isAdmin()) {
1388 $updateData['ses_userid'] = $uRec['uid'];
1389 // user switchback
1390 if (t3lib_div::_GP('switchBackUser')) {
1391 $updateData['ses_backuserid'] = intval($GLOBALS['BE_USER']->user['uid']);
1392 }
1393 $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);
1394
1395 header('Location: '.t3lib_div::locationHeaderUrl($GLOBALS['BACK_PATH'].'index.php'.($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']?'':'?commandLI=1')));
1396 exit;
1397 }
1398 }
1399 }
1400
1401 // Include extension?
1402 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']) {
1403 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/beuser/mod/index.php']);
1404 }
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417 // Make instance:
1418 $SOBE = t3lib_div::makeInstance('SC_mod_tools_be_user_index');
1419 $SOBE->init();
1420 $SOBE->main();
1421 $SOBE->printContent();
1422 ?>