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