PageRenderTime 80ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/typo3/sysext/beuser/mod/index.php

https://bitbucket.org/linxpinx/mercurial
PHP | 1632 lines | 882 code | 234 blank | 516 comment | 118 complexity | 2d40a3cefb8429f6946dffa54a57f6a7 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, Unlicense, LGPL-2.1, Apache-2.0

Large files files are truncated, but you can click here to view the full file

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

Large files files are truncated, but you can click here to view the full file