PageRenderTime 47ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Classes/Utility/OverviewUtility.php

https://github.com/dkd/tc_beuser
PHP | 1023 lines | 819 code | 136 blank | 68 comment | 67 complexity | 05efcdcdbbeb900eda16cb7d30b845fd MD5 | raw file
  1. <?php
  2. namespace dkd\TcBeuser\Utility;
  3. /***************************************************************
  4. * Copyright notice
  5. *
  6. * (c) 2006 Ingo Renner (ingo.renner@dkd.de)
  7. * All rights reserved
  8. *
  9. * This script is part of the TYPO3 project. The TYPO3 project is
  10. * free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * The GNU General Public License can be found at
  16. * http://www.gnu.org/copyleft/gpl.html.
  17. *
  18. * This script is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * This copyright notice MUST APPEAR in all copies of the script!
  24. ***************************************************************/
  25. use TYPO3\CMS\Backend\Form\FormEngine;
  26. use TYPO3\CMS\Backend\Utility\BackendUtility;
  27. use TYPO3\CMS\Backend\Utility\IconUtility;
  28. use TYPO3\CMS\Core\Utility\GeneralUtility;
  29. $GLOBALS['LANG']->includeLLFile('EXT:tc_beuser/mod4/locallang.xml');
  30. /**
  31. * OverviewUtility.php
  32. *
  33. * DESCRIPTION HERE
  34. * $Id$
  35. *
  36. * @author Ingo Renner <ingo.renner@dkd.de>
  37. */
  38. class OverviewUtility {
  39. var $row;
  40. /**
  41. * @var array $availableMethods a list of methods, that are directly available ( ~ the interface)
  42. */
  43. var $availableMethods = array(
  44. 'renderColFilemounts',
  45. 'renderColWebmounts',
  46. 'renderColPagetypes',
  47. 'renderColSelecttables',
  48. 'renderColModifytables',
  49. 'renderColNonexcludefields',
  50. 'renderColExplicitallowdeny',
  51. 'renderColLimittolanguages',
  52. 'renderColWorkspaceperms',
  53. 'renderColWorkspacememship',
  54. 'renderColDescription',
  55. 'renderColModules',
  56. 'renderColTsconfig',
  57. 'renderColTsconfighl',
  58. 'renderColMembers',
  59. );
  60. var $backPath;
  61. var $table;
  62. /**
  63. * method dispatcher
  64. * checks input vars and returns result of desired method if available
  65. *
  66. * @param string $method: defines what to return
  67. * @param int $groupId
  68. * @param bool $open
  69. * @param string $backPath
  70. * @return string
  71. */
  72. function handleMethod ($method, $groupId, $open=false, $backPath='') {
  73. $content = '';
  74. $method = trim(strval($method));
  75. $groupId = intval($groupId);
  76. $open = (bool) $open;
  77. // We need some uid in rootLine for the access check, so use first webmount
  78. $webmounts = $GLOBALS['BE_USER']->returnWebmounts();
  79. $this->pageinfo['uid'] = $webmounts[0];
  80. if (in_array($method, $this->availableMethods)) {
  81. $content = $this->$method($groupId, $open, $backPath);
  82. }
  83. return $content;
  84. }
  85. function getTable($row, $setCols) {
  86. $content = '';
  87. $this->row = $row;
  88. $out = $this->renderListHeader($setCols);
  89. $cc = 0;
  90. $groups = GeneralUtility::intExplode(',', $row['usergroup']);
  91. foreach($groups as $groupId) {
  92. if ($groupId != 0){
  93. $tree = $this->getGroupTree($groupId);
  94. foreach($tree as $row) {
  95. $tCells = $this->renderListRow($setCols, $row,'');
  96. $out .= '
  97. <tr class="db_list_normal">
  98. '.implode('',$tCells).'
  99. </tr>';
  100. $cc++;
  101. }
  102. } else {
  103. return '<br /><br />'.$GLOBALS['LANG']->sL('LLL:EXT:tc_beuser/mod3/locallang.xml:not-found').'<br />';
  104. }
  105. }
  106. $content .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
  107. '.$out.'
  108. </table>'."\n";
  109. return $content;
  110. }
  111. /**
  112. * only used for group view
  113. */
  114. function getTableGroup($row, $setCols) {
  115. $content = '';
  116. $this->row = $row;
  117. $out = $this->renderListHeader($setCols);
  118. $cc = 0;
  119. $groups = GeneralUtility::intExplode(',', $row['uid']);
  120. foreach($groups as $groupId) {
  121. $tree = $this->getGroupTree($groupId);
  122. foreach($tree as $row) {
  123. $tCells = $this->renderListRow($setCols, $row, '');
  124. $out .= '
  125. <tr class="db_list_normal">
  126. '.implode('',$tCells).'
  127. </tr>';
  128. $cc++;
  129. }
  130. }
  131. $content .= '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
  132. '.$out.'
  133. </table>'."\n";
  134. return $content;
  135. }
  136. function renderListHeader($setCols) {
  137. $content = '';
  138. $content .= '
  139. <tr>
  140. <td class="t3-row-header" colspan="'.(count($setCols) + 2).'">&nbsp;</td>
  141. </tr>'."\n";
  142. $content .= '<tr>'."\n";
  143. // always show groups and Id
  144. #$label = $GLOBALS['LANG']->sL('LLL:EXT:tc_beuser/mod4/locallang.xml:showCol-groups', 1);
  145. $label = $GLOBALS['LANG']->getLL('showCol-groups');
  146. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  147. $content .= $this->wrapTd('ID:', 'class="c-headLine"');
  148. if(count($setCols)) {
  149. foreach($setCols as $col => $set) {
  150. switch($col) {
  151. case 'members':
  152. $label = $GLOBALS['LANG']->getLL('showCol-members');
  153. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  154. break;
  155. case 'filemounts':
  156. $label = $GLOBALS['LANG']->getLL('showCol-filemounts');
  157. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  158. break;
  159. case 'webmounts':
  160. $label = $GLOBALS['LANG']->getLL('showCol-webmounts');
  161. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  162. break;
  163. case 'pagetypes':
  164. $label = $GLOBALS['LANG']->getLL('showCol-pagetypes');
  165. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  166. break;
  167. case 'selecttables':
  168. $label = $GLOBALS['LANG']->getLL('showCol-selecttables');
  169. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  170. break;
  171. case 'modifytables':
  172. $label = $GLOBALS['LANG']->getLL('showCol-modifytables');
  173. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  174. break;
  175. case 'nonexcludefields':
  176. $label = $GLOBALS['LANG']->getLL('showCol-nonexcludefields');
  177. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  178. break;
  179. case 'explicitallowdeny':
  180. $label = $GLOBALS['LANG']->getLL('showCol-explicitallowdeny');
  181. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  182. break;
  183. case 'limittolanguages':
  184. $label = $GLOBALS['LANG']->getLL('showCol-limittolanguages');
  185. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  186. break;
  187. case 'workspaceperms':
  188. $label = $GLOBALS['LANG']->getLL('showCol-workspaceperms');
  189. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  190. break;
  191. case 'workspacememship':
  192. $label = $GLOBALS['LANG']->getLL('showCol-workspacememship');
  193. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  194. break;
  195. case 'description':
  196. $label = $GLOBALS['LANG']->getLL('showCol-description');
  197. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  198. break;
  199. case 'modules':
  200. $label = $GLOBALS['LANG']->getLL('showCol-modules');
  201. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  202. break;
  203. case 'tsconfig':
  204. $label = $GLOBALS['LANG']->getLL('showCol-tsconfig');
  205. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  206. break;
  207. case 'tsconfighl':
  208. $label = $GLOBALS['LANG']->getLL('showCol-tsconfighl');
  209. $content .= $this->wrapTd($label.':', 'class="c-headLine"');
  210. break;
  211. }
  212. }
  213. }
  214. $content .= '</tr>'."\n";
  215. return $content;
  216. }
  217. function renderListRow($setCols, $treeRow, $class) {
  218. $tCells = array();
  219. // title:
  220. $rowTitle = $treeRow['HTML'].' '.htmlspecialchars($treeRow['row']['title']);
  221. $tCells[] = $this->wrapTd($rowTitle, 'nowrap="nowrap"', $class);
  222. // id
  223. $tCells[] = $this->wrapTd($treeRow['row']['uid'], 'nowrap="nowrap"', $class);
  224. if(count($setCols)) {
  225. foreach($setCols as $colName => $set) {
  226. $td = call_user_func(
  227. array(
  228. &$this,
  229. 'renderCol'.ucfirst($colName)
  230. ),
  231. $treeRow['row']['uid'],
  232. ''
  233. );
  234. $tCells[] = $this->wrapTd($td, 'id="'.mt_rand().'" nowrap="nowrap"', $class);
  235. }
  236. }
  237. return $tCells;
  238. }
  239. function renderColFilemounts($groupId, $open = false, $backPath = '') {
  240. $content = '';
  241. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  242. $title = $GLOBALS['LANG']->getLL('showCol-filemounts');
  243. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  244. $this->table = 'sys_filemounts';
  245. $this->backPath = $backPath;
  246. if($open) {
  247. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  248. 'file_mountpoints',
  249. 'be_groups',
  250. 'uid = '.$groupId
  251. );
  252. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  253. $fileMounts = GeneralUtility::intExplode(',', $row['file_mountpoints']);
  254. $items = array();
  255. if(is_array($fileMounts) && $fileMounts[0] != 0) {
  256. $content .= '<br />';
  257. foreach($fileMounts as $fm) {
  258. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  259. '*',
  260. $this->table,
  261. 'uid = '.$fm
  262. );
  263. $filemount = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  264. $fmIcon = IconUtility::getSpriteIconForRecord(
  265. $this->table,
  266. $filemount
  267. );
  268. $items[] = '<tr><td>'.$fmIcon.$filemount['title'].'</td><td>'.$this->makeUserControl($filemount).'</td></tr>'."\n";
  269. }
  270. }
  271. $content .= '<table>'.implode('',$items).'</table>';
  272. }
  273. $toggle = '<span onclick="updateData(this, \'renderColFilemounts\', '
  274. .$groupId.', '
  275. .($open?'0':'1')
  276. .');" style="cursor: pointer;">'
  277. . $icon . $title
  278. .'</span>';
  279. return $toggle . $content;
  280. }
  281. function renderColWebmounts($groupId, $open = false, $backPath = '') {
  282. $content = '';
  283. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  284. $title = $GLOBALS['LANG']->getLL('showCol-webmounts');
  285. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  286. if($open) {
  287. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  288. 'db_mountpoints',
  289. 'be_groups',
  290. 'uid = '.$groupId
  291. );
  292. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  293. $webMounts = GeneralUtility::intExplode(',', $row['db_mountpoints']);
  294. if(is_array($webMounts) && $webMounts[0] != 0) {
  295. $content .= '<br />';
  296. foreach($webMounts as $wm) {
  297. $webmount = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
  298. 'uid, title, nav_hide, doktype, module',
  299. 'pages',
  300. 'uid = '.$wm
  301. );
  302. $webmount = $webmount[0];
  303. $wmIcon = IconUtility::getSpriteIconForRecord(
  304. 'pages',
  305. $webmount,
  306. array(' title'=> 'id='.$webmount['uid'])
  307. );
  308. $content .= $wmIcon.$webmount['title'].'<br />'."\n";
  309. }
  310. }
  311. }
  312. $toggle = '<span onclick="updateData(this, \'renderColWebmounts\', '
  313. .$groupId.', '
  314. .($open?'0':'1')
  315. .');" style="cursor: pointer;">'
  316. . $icon . $title
  317. .'</span>';
  318. return $toggle . $content;
  319. }
  320. function renderColPagetypes($groupId, $open = false, $backPath = '') {
  321. $content = '';
  322. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  323. $title = $GLOBALS['LANG']->getLL('showCol-pagetypes');
  324. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  325. if($open) {
  326. $content .= '<br />';
  327. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  328. 'pagetypes_select',
  329. 'be_groups',
  330. 'uid = '.$groupId
  331. );
  332. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  333. $pageTypes = explode(',', $row['pagetypes_select']);
  334. reset($pageTypes);
  335. while(list($kk,$vv) = each($pageTypes)) {
  336. if(!empty($vv)) {
  337. $ptIcon = IconUtility::getSpriteIconForRecord(
  338. 'pages',
  339. array('doktype' => $vv),
  340. array('title' => 'doktype='.$vv)
  341. );
  342. $content .= $ptIcon . $GLOBALS['LANG']->sL(BackendUtility::getLabelFromItemlist('pages','doktype',$vv));
  343. $content .= '<br />'."\n";
  344. }
  345. }
  346. }
  347. $toggle = '<span onclick="updateData(this, \'renderColPagetypes\', '
  348. .$groupId.', '
  349. .($open?'0':'1')
  350. .');" style="cursor: pointer;">'
  351. . $icon . $title
  352. .'</span>';
  353. return $toggle . $content;
  354. }
  355. function renderColSelecttables($groupId, $open = false, $backPath = '') {
  356. $content = '';
  357. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  358. $title = $GLOBALS['LANG']->getLL('showCol-selecttables');
  359. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  360. if($open) {
  361. $content .= '<br />';
  362. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  363. 'tables_select',
  364. 'be_groups',
  365. 'uid = '.$groupId
  366. );
  367. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  368. $tablesSelect = explode(',', $row['tables_select']);
  369. reset($tablesSelect);
  370. while(list($kk,$vv) = each($tablesSelect)) {
  371. if(!empty($vv)) {
  372. $ptIcon = IconUtility::getSpriteIconForRecord(
  373. $vv,
  374. array(),
  375. array('title' => 'table='.$vv)
  376. );
  377. $tableTitle = $GLOBALS['TCA'][$vv]['ctrl']['title'];
  378. $content .= $ptIcon . $GLOBALS['LANG']->sL($tableTitle);
  379. $content .= '<br />'."\n";
  380. }
  381. }
  382. }
  383. $toggle = '<span onclick="updateData(this, \'renderColSelecttables\', '
  384. .$groupId.', '
  385. .($open?'0':'1')
  386. .');" style="cursor: pointer;">'
  387. . $icon . $title
  388. .'</span>';
  389. return $toggle . $content;
  390. }
  391. function renderColModifytables($groupId, $open = false, $backPath = '') {
  392. $content = '';
  393. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  394. $title = $GLOBALS['LANG']->getLL('showCol-modifytables');
  395. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  396. if($open) {
  397. $content .= '<br />';
  398. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  399. 'tables_modify',
  400. 'be_groups',
  401. 'uid = '.$groupId
  402. );
  403. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  404. $tablesModify = explode(',', $row['tables_modify']);
  405. reset($tablesModify);
  406. while(list($kk,$vv) = each($tablesModify)) {
  407. if(!empty($vv)) {
  408. $ptIcon = IconUtility::getSpriteIconForRecord(
  409. $vv,
  410. array(),
  411. array('title' => 'table='.$vv)
  412. );
  413. $tableTitle = $GLOBALS['TCA'][$vv]['ctrl']['title'];
  414. $content .= $ptIcon . $GLOBALS['LANG']->sL($tableTitle);
  415. $content .= '<br />'."\n";
  416. }
  417. }
  418. }
  419. $toggle = '<span onclick="updateData(this, \'renderColModifytables\', '
  420. .$groupId.', '
  421. .($open?'0':'1')
  422. .');" style="cursor: pointer;">'
  423. . $icon . $title
  424. .'</span>';
  425. return $toggle . $content;
  426. }
  427. function renderColNonexcludefields($groupId, $open = false, $backPath = '') {
  428. $content = '';
  429. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  430. $title = $GLOBALS['LANG']->getLL('showCol-nonexcludefields');
  431. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  432. if($open) {
  433. $content .= '<br />';
  434. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  435. 'non_exclude_fields',
  436. 'be_groups',
  437. 'uid = '.$groupId
  438. );
  439. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  440. $non_exclude_fields = explode(',', $row['non_exclude_fields']);
  441. reset($non_exclude_fields);
  442. while(list($kk,$vv) = each($non_exclude_fields)) {
  443. if(!empty($vv)) {
  444. $data = explode(':',$vv);
  445. $tableTitle = $GLOBALS['TCA'][$data[0]]['ctrl']['title'];
  446. $fieldTitle = $GLOBALS['TCA'][$data[0]]['columns'][$data[1]]['label'];
  447. $content .= $GLOBALS['LANG']->sL($tableTitle).': '.rtrim($GLOBALS['LANG']->sL($fieldTitle),':');
  448. $content .= '<br />'."\n";
  449. }
  450. }
  451. }
  452. $toggle = '<span onclick="updateData(this, \'renderColNonexcludefields\', '
  453. .$groupId.', '
  454. .($open?'0':'1')
  455. .');" style="cursor: pointer;">'
  456. . $icon . $title
  457. .'</span>';
  458. return $toggle . $content;
  459. }
  460. function renderColExplicitallowdeny($groupId, $open = false, $backPath = '') {
  461. $content = '';
  462. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  463. $title = $GLOBALS['LANG']->getLL('showCol-explicitallowdeny');
  464. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  465. $adLabel = array(
  466. 'ALLOW' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.allow'),
  467. 'DENY' => $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.deny'),
  468. );
  469. $iconsPath = array(
  470. 'ALLOW' => '../'.TYPO3_mainDir.IconUtility::skinImg($this->backPath,'gfx/icon_ok2.gif','',1),
  471. 'DENY' => '../'.TYPO3_mainDir.IconUtility::skinImg($this->backPath,'gfx/icon_fatalerror.gif','',1),
  472. );
  473. if($open) {
  474. $content .= '<br />';
  475. $data = '';
  476. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  477. 'explicit_allowdeny',
  478. 'be_groups',
  479. 'uid = '.$groupId
  480. );
  481. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  482. if(!empty($row['explicit_allowdeny'])) {
  483. $explicit_allowdeny = explode(',', $row['explicit_allowdeny']);
  484. reset($explicit_allowdeny);
  485. foreach($explicit_allowdeny as $val) {
  486. $dataParts = explode(':',$val);
  487. $items = $GLOBALS['TCA'][$dataParts[0]]['columns'][$dataParts[1]]['config']['items'];
  488. foreach($items as $val) {
  489. if ($val[1] == $dataParts[2]) {
  490. $imageInfo = FormEngine::getIcon($iconsPath[$dataParts['3']]);
  491. $imageInfo[0] = str_replace('../typo3',$backPath,$imageInfo[0]);
  492. $data .= '<img src ="'.$imageInfo[0].'" '.$imageInfo[1][3].'/>'.
  493. ' ['.$adLabel[$dataParts['3']].'] '.
  494. $GLOBALS['LANG']->sl($val[0]).'<br />';
  495. }
  496. }
  497. }
  498. }
  499. $content .= $data .'<br />';
  500. }
  501. $toggle = '<span onclick="updateData(this, \'renderColExplicitallowdeny\', '
  502. .$groupId.', '
  503. .($open?'0':'1')
  504. .');" style="cursor: pointer;">'
  505. . $icon . $title
  506. .'</span>';
  507. return $toggle . $content;
  508. }
  509. function renderColLimittolanguages($groupId, $open = false, $backPath = '') {
  510. $content = '';
  511. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  512. $title = $GLOBALS['LANG']->getLL('showCol-limittolanguages');
  513. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  514. if($open) {
  515. $content .= '<br />';
  516. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  517. 'allowed_languages',
  518. 'be_groups',
  519. 'uid = '.$groupId
  520. );
  521. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  522. $allowed_languages = explode(',', $row['allowed_languages']);
  523. reset($allowed_languages);
  524. $availLang = BackendUtility::getSystemLanguages();
  525. $data = '';
  526. foreach($allowed_languages as $langId) {
  527. foreach($availLang as $availLangInfo) {
  528. if($availLangInfo[1] == $langId) {
  529. $dataIcon = array();
  530. if(isset($availLangInfo[2])) {
  531. $dataIcon = FormEngine::getIcon($availLangInfo[2]);
  532. }
  533. if(empty($dataIcon)) {
  534. $dataIcon[0]='clear.gif';
  535. }
  536. $data .= '<img src="'.$backPath.$dataIcon[0].'" '.$dataIcon[1][3].'/> '.
  537. $availLangInfo[0].'<br />';
  538. }
  539. }
  540. }
  541. $content .= $data .'<br />';
  542. }
  543. $toggle = '<span onclick="updateData(this, \'renderColLimittolanguages\', '
  544. .$groupId.', '
  545. .($open?'0':'1')
  546. .');" style="cursor: pointer;">'
  547. . $icon . $title
  548. .'</span>';
  549. return $toggle . $content;
  550. }
  551. function renderColWorkspaceperms($groupId, $open = false, $backPath = '') {
  552. $content = '';
  553. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  554. $title = $GLOBALS['LANG']->getLL('showCol-workspaceperms');
  555. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  556. if($open) {
  557. $content .= '<br />';
  558. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  559. 'workspace_perms',
  560. 'be_groups',
  561. 'uid = '.$groupId
  562. );
  563. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  564. $permissions = floatval($row['workspace_perms']);
  565. $items = $GLOBALS['TCA']['be_groups']['columns']['workspace_perms']['config']['items'];
  566. $check = array();
  567. foreach($items as $key => $val) {
  568. if($permissions & pow(2,$key)){
  569. $check[] = $GLOBALS['LANG']->sL($val[0]);
  570. }
  571. }
  572. $content .= implode('<br />',$check);
  573. }
  574. $toggle = '<span onclick="updateData(this, \'renderColWorkspaceperms\', '
  575. .$groupId.', '
  576. .($open?'0':'1')
  577. .');" style="cursor: pointer;">'
  578. . $icon . $title
  579. .'</span>';
  580. return $toggle . $content;
  581. }
  582. function renderColWorkspacememship($groupId, $open = false, $backPath = '') {
  583. $content = '';
  584. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  585. $title = $GLOBALS['LANG']->getLL('showCol-workspacememship');
  586. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  587. if($open) {
  588. $content .= '<br />';
  589. $userAuthGroup = GeneralUtility::makeInstance('\\TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
  590. //get workspace perms
  591. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  592. 'workspace_perms',
  593. 'be_groups',
  594. 'uid = '.$groupId
  595. );
  596. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  597. $userAuthGroup->groupData['workspace_perms'] = $row['workspace_perms'];
  598. // Create accessible workspace arrays:
  599. $options = array();
  600. if ($userAuthGroup->checkWorkspace(array('uid' => 0))) {
  601. $options[0] = '0: [LIVE]';
  602. }
  603. if ($userAuthGroup->checkWorkspace(array('uid' => -1))) {
  604. $options[-1] = '-1: [Default Draft]';
  605. }
  606. // Add custom workspaces (selecting all, filtering by BE_USER check):
  607. $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers,db_mountpoints','sys_workspace','pid=0'.BackendUtility::deleteClause('sys_workspace'),'','title');
  608. if (count($workspaces)) {
  609. foreach ($workspaces as $rec) {
  610. if ($userAuthGroup->checkWorkspace($rec)) {
  611. $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
  612. // Check if all mount points are accessible, otherwise show error:
  613. if (trim($rec['db_mountpoints'])!=='') {
  614. $mountPoints = GeneralUtility::intExplode(',',$userAuthGroup->workspaceRec['db_mountpoints'],1);
  615. foreach($mountPoints as $mpId) {
  616. if (!$userAuthGroup->isInWebMount($mpId,'1=1')) {
  617. $options[$rec['uid']].= '<br> \- WARNING: Workspace Webmount page id "'.$mpId.'" not accessible!';
  618. }
  619. }
  620. }
  621. }
  622. }
  623. }
  624. $content .= implode('<br />', $options);
  625. }
  626. $toggle = '<span onclick="updateData(this, \'renderColWorkspacememship\', '
  627. .$groupId.', '
  628. .($open?'0':'1')
  629. .');" style="cursor: pointer;">'
  630. . $icon . $title
  631. .'</span>';
  632. return $toggle . $content;
  633. }
  634. function renderColDescription($groupId, $open = false, $backPath = '') {
  635. $content = '';
  636. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  637. $title = $GLOBALS['LANG']->getLL('showCol-description');
  638. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  639. if($open) {
  640. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  641. 'description',
  642. 'be_groups',
  643. 'uid = '.$groupId
  644. );
  645. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  646. $content .= '<br />';
  647. $content .= '<pre>'.$row['description'].'</pre><br />'."\n";
  648. }
  649. $toggle = '<span onclick="updateData(this, \'renderColDescription\', '
  650. .$groupId.', '
  651. .($open?'0':'1')
  652. .');" style="cursor: pointer;">'
  653. . $icon . $title
  654. .'</span>';
  655. return $toggle . $content;
  656. }
  657. function renderColModules($groupId, $open = false, $backPath = '') {
  658. $content = '';
  659. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  660. $title = $GLOBALS['LANG']->getLL('showCol-modules');
  661. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  662. if($open) {
  663. $content .='<br />';
  664. $tceForms = GeneralUtility::makeInstance('\\TYPO3\\CMS\\Backend\\Form\\FormEngine');
  665. $tceForms->backPath = $backPath;
  666. $TCAconf = $GLOBALS['TCA']['be_groups']['columns']['groupMods'];
  667. $table = 'be_groups';
  668. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  669. '*',
  670. $table,
  671. 'uid = '.$groupId
  672. );
  673. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  674. $allMods = $tceForms->addSelectOptionsToItemArray($tceForms->initItemArray($TCAconf),$TCAconf,$tceForms->setTSconfig($table,$row),'groupMods');
  675. $items = array();
  676. foreach($allMods as $id => $modsInfo) {
  677. if(GeneralUtility::inList($row['groupMods'],$modsInfo[1])) {
  678. $modIcon = FormEngine::getIcon($modsInfo[2]);
  679. $items[] = '<img src="'.$backPath.$modIcon[0].'" '.$modIcon[1][3].'/> '.$modsInfo[0];
  680. }
  681. }
  682. $content .= implode('<br />',$items);
  683. }
  684. $toggle = '<span onclick="updateData(this, \'renderColModules\', '
  685. .$groupId.', '
  686. .($open?'0':'1')
  687. .');" style="cursor: pointer;">'
  688. . $icon . $title
  689. .'</span>';
  690. return $toggle . $content;
  691. }
  692. function renderColTsconfig($groupId, $open = false, $backPath = '') {
  693. $content = '';
  694. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  695. $title = $GLOBALS['LANG']->getLL('showCol-tsconfig');
  696. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  697. if($open) {
  698. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  699. 'TSconfig',
  700. 'be_groups',
  701. 'uid = '.$groupId
  702. );
  703. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  704. $TSconfig = GeneralUtility::intExplode(',', $row['TSconfig']);
  705. $content .= '<pre>'.$row['TSconfig'].'</pre><br />'."\n";
  706. }
  707. $toggle = '<span onclick="updateData(this, \'renderColTsconfig\', '
  708. .$groupId.', '
  709. .($open?'0':'1')
  710. .');" style="cursor: pointer;">'
  711. . $icon . $title
  712. .'</span>';
  713. return $toggle . $content;
  714. }
  715. function renderColTsconfighl($groupId, $open = false, $backPath = '') {
  716. $content = '';
  717. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  718. $title = $GLOBALS['LANG']->getLL('showCol-tsconfighl');
  719. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  720. if($open) {
  721. $tsparser = GeneralUtility::makeInstance('\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser');
  722. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  723. 'TSconfig',
  724. 'be_groups',
  725. 'uid = '.$groupId
  726. );
  727. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  728. $content = $tsparser->doSyntaxHighlight($row['TSconfig'],'',1);
  729. }
  730. $toggle = '<span onclick="updateData(this, \'renderColTsconfighl\', '
  731. .$groupId.', '
  732. .($open?'0':'1')
  733. .');" style="cursor: pointer;">'
  734. . $icon . $title
  735. .'</span>';
  736. return $toggle . $content;
  737. }
  738. function renderColMembers($groupId, $open = false, $backPath = '') {
  739. $content = '';
  740. $backPath = $backPath ? $backPath : $GLOBALS['SOBE']->doc->backPath;
  741. $title = $GLOBALS['LANG']->getLL('showCol-members');
  742. $icon = '<img'.IconUtility::skinImg($backPath, 'gfx/ol/'.($open?'minus':'plus').'bullet.gif','width="18" height="16"').' alt="" />';
  743. $this->backPath = $backPath;
  744. $this->table = 'be_users';
  745. if($open) {
  746. $content .= '<br />';
  747. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  748. '*',
  749. 'be_users',
  750. 'usergroup like '.$GLOBALS['TYPO3_DB']->fullQuoteStr('%'.$groupId.'%','be_users').BackendUtility::deleteClause('be_users')
  751. );
  752. $members = array();
  753. while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)){
  754. if (GeneralUtility::inList($row['usergroup'],$groupId)){
  755. //$members[] = $row;
  756. $fmIcon = IconUtility::getSpriteIconForRecord(
  757. 'be_users',
  758. $row
  759. );
  760. $members[] = '<tr><td>'.$fmIcon.' '.$row['realName'].' ('.$row['username'].')</td><td>'.$this->makeUserControl($row).'</td></tr>';
  761. }
  762. }
  763. $content .= '<table>'.implode('', $members).'</table>';
  764. }
  765. $toggle = '<span onclick="updateData(this, \'renderColMembers\', '
  766. .$groupId.', '
  767. .($open?'0':'1')
  768. .');" style="cursor: pointer;">'
  769. . $icon . $title
  770. .'</span>';
  771. return $toggle . $content;
  772. }
  773. /**
  774. * from mod4/index.php
  775. */
  776. function editOnClick($params, $requestUri = '') {
  777. $retUrl = '&returnUrl=' . ($requestUri == -1 ? "'+T3_THIS_LOCATION+'" : rawurlencode($requestUri ? $requestUri : GeneralUtility::getIndpEnv('REQUEST_URI')));
  778. return "window.location.href='". BackendUtility::getModuleUrl('txtcbeuserM1_txtcbeuserM2') . $retUrl . $params . "'; return false;";
  779. }
  780. function makeUserControl($userRecord) {
  781. $doc = GeneralUtility::makeInstance('template');
  782. $doc->backPath = $this->backPath;
  783. $this->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
  784. $permsEdit = $this->calcPerms&16;
  785. $control = '';
  786. if($this->table == 'be_users' && $permsEdit){
  787. // edit
  788. $control = '<a href="#" onclick="' . htmlspecialchars(
  789. $this->editOnClick('&edit[' . $this->table . '][' . $userRecord['uid'] . ']=edit&SET[function]=edit', -1)
  790. ) . '"><img' . IconUtility::skinImg(
  791. $this->backPath,
  792. 'gfx/edit2.gif',
  793. 'width="11" height="12"'
  794. ) . ' title="edit" alt="" /></a>' . chr(10);
  795. }
  796. //info
  797. if ($GLOBALS['BE_USER']->check('tables_select', $this->table)
  798. && is_array(BackendUtility::readPageAccess($userRecord['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1)))
  799. ) {
  800. $control .= '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $this->table . '\', \'' . $userRecord['uid'] . '\'); return false;') . '">' .
  801. '<img' . IconUtility::skinImg($this->backPath, 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="" alt="" />' .
  802. '</a>' . chr(10);
  803. }
  804. // hide/unhide
  805. $hiddenField = $GLOBALS['TCA'][$this->table]['ctrl']['enablecolumns']['disabled'];
  806. if ($permsEdit) {
  807. $redirect = '&redirect=\'+T3_THIS_LOCATION+\'&vC=' . rawurlencode($GLOBALS['BE_USER']->veriCode()) . '&prErr=1&uPT=1';
  808. if ($userRecord[$hiddenField]) {
  809. $params = '&data[' . $this->table . '][' . $userRecord['uid'] . '][' . $hiddenField . ']=0&SET[function]=action';
  810. $control .= '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' .
  811. BackendUtility::getModuleUrl('txtcbeuserM1_txtcbeuserM2') . $params . $redirect . '\');') . '">' .
  812. '<img' . IconUtility::skinImg($this->backPath, 'gfx/button_unhide.gif', 'width="11" height="10"') . ' title="unhide" alt="" />' .
  813. '</a>' . chr(10);
  814. } else {
  815. $params = '&data[' . $this->table . '][' . $userRecord['uid'] . '][' . $hiddenField . ']=1&SET[function]=action';
  816. $control .= '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' .
  817. BackendUtility::getModuleUrl('txtcbeuserM1_txtcbeuserM2') . $params . $redirect . '\');') . '">' .
  818. '<img' . IconUtility::skinImg($this->backPath, 'gfx/button_hide.gif', 'width="11" height="10"') . ' title="hide" alt="" />' .
  819. '</a>' . chr(10);
  820. }
  821. }
  822. // delete
  823. if($permsEdit) {
  824. $params = '&cmd[' . $this->table . '][' . $userRecord['uid'] . '][delete]=1&SET[function]=action';
  825. $redirect = '&redirect=\'+T3_THIS_LOCATION+\'&vC=' . rawurlencode($GLOBALS['BE_USER']->veriCode()) . '&prErr=1&uPT=1';
  826. $control .= '<a href="#" onclick="' . htmlspecialchars('if (confirm(' .
  827. $GLOBALS['LANG']->JScharCode(
  828. $GLOBALS['LANG']->getLL('deleteWarning') .
  829. BackendUtility::referenceCount(
  830. $this->table,
  831. $userRecord['uid'],
  832. ' (There are %s reference(s) to this record!)'
  833. )
  834. ) . ')) {jumpToUrl(\'' . BackendUtility::getModuleUrl('txtcbeuserM1_txtcbeuserM2') . $params . $redirect . '\');} return false;'
  835. ) . '">' .
  836. '<img' . IconUtility::skinImg($this->backPath, 'gfx/garbage.gif', 'width="11" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('delete', 1) . '" alt="" />' .
  837. '</a>' . chr(10);
  838. }
  839. // swith user / switch user back
  840. if($this->table == 'be_users' && $permsEdit && $GLOBALS['BE_USER']->isAdmin()) {
  841. if ($userRecord[$hiddenField]) {
  842. $control .= '<img '.IconUtility::skinImg($this->backPath,'gfx/su.gif').' border="0" align="top" title="'.htmlspecialchars('Switch user to: '.$userRecord['username']).' [change-to mode]" alt="" />'.
  843. '<img '.IconUtility::skinImg($this->backPath,'gfx/su_back.gif').' border="0" align="top" title="'.htmlspecialchars('Switch user to: '.$userRecord['username']).' [switch-back mode]" alt="" />'
  844. .chr(10).chr(10);
  845. } else {
  846. $control .= '<a href="'.GeneralUtility::linkThisScript(array('SwitchUser'=>$userRecord['uid'])).'" target="_top"><img '.IconUtility::skinImg($this->backPath,'gfx/su.gif').' border="0" align="top" title="'.htmlspecialchars('Switch user to: '.$userRecord['username']).' [change-to mode]" alt="" /></a>'.
  847. '<a href="'.GeneralUtility::linkThisScript(array('SwitchUser'=>$userRecord['uid'], 'switchBackUser' => 1)).'" target="_top"><img '.IconUtility::skinImg($this->backPath,'gfx/su_back.gif').' border="0" align="top" title="'.htmlspecialchars('Switch user to: '.$userRecord['username']).' [switch-back mode]" alt="" /></a>'
  848. .chr(10).chr(10);
  849. }
  850. }
  851. return $control;
  852. }
  853. function getGroupTree($groupId) {
  854. $treeStartingPoint = $groupId;
  855. $treeStartingRecord = BackendUtility::getRecord('be_groups', $treeStartingPoint);
  856. $depth = 10;
  857. // Initialize tree object:
  858. /** @var dkd\TcBeuser\Utility\GroupTreeUtility $tree */
  859. $tree = GeneralUtility::makeInstance('dkd\\TcBeuser\\Utility\\GroupTreeUtility');
  860. $tree->init('');
  861. $tree->expandAll = true;
  862. // Creating top icon; the main group
  863. $HTML = IconUtility::getSpriteIconForRecord('be_groups', $treeStartingRecord, array('align' => 'top'));
  864. $tree->tree[] = array(
  865. 'row' => $treeStartingRecord,
  866. 'HTML' => $HTML
  867. );
  868. $dataTree = array();
  869. $dataTree[$groupId] = $tree->buildTree($groupId);
  870. $tree->setDataFromArray($dataTree);
  871. // Create the tree from starting point:
  872. if ($depth > 0) {
  873. $tree->getTree($treeStartingPoint, $depth);
  874. }
  875. return $tree->tree;
  876. }
  877. function wrapTd($str, $tdParams = '', $class = '', $style = '') {
  878. return "\t".'<td'
  879. .($tdParams ? ' '.$tdParams : '')
  880. .($class ? ' class="'.$class.'"' : '')
  881. .' style="vertical-align: top;'.($style ? ' '.$style : '').'">'.$str.'</td>'."\n";
  882. }
  883. }
  884. if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tc_beuser/class.tx_tcbeuser_overview.php']) {
  885. include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tc_beuser/class.tx_tcbeuser_overview.php']);
  886. }
  887. ?>