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