[TASK] "t3-table" (Web>List) & tree sprites (AbstractTreeView)
[Packages/TYPO3.CMS.git] / typo3 / sysext / perm / Classes / Controller / PermissionModuleController.php
1 <?php
2 namespace TYPO3\CMS\Perm\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Core\Utility\GeneralUtility;
31 use TYPO3\CMS\Backend\Utility\BackendUtility;
32 use TYPO3\CMS\Backend\Utility\IconUtility;
33
34 /**
35 * Module: Permission setting
36 *
37 * Script Class for the Web > Access module
38 * This module lets you view and change permissions for pages.
39 *
40 * Variables:
41 * $this->MOD_SETTINGS['depth']: int 1-3: decides the depth of the list
42 *
43 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
44 * @author Andreas Kundoch <typo3@mehrwert.de>
45 */
46 class PermissionModuleController {
47
48 /**
49 * Number of levels to enable recursive settings for
50 *
51 * @var integer
52 */
53 public $getLevels = 10;
54
55 /**
56 * Module config
57 * Internal static
58 *
59 * @var array
60 */
61 protected $MCONF = array();
62
63 /**
64 * Document Template Object
65 *
66 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
67 */
68 public $doc;
69
70 /**
71 * Content accumulation
72 *
73 * @var string
74 */
75 public $content;
76
77 /**
78 * Module menu
79 *
80 * @var array
81 */
82 public $MOD_MENU = array();
83
84 /**
85 * Module settings, cleansed.
86 *
87 * @var aray
88 */
89 public $MOD_SETTINGS = array();
90
91 /**
92 * Page select permissions
93 *
94 * @var string
95 */
96 public $perms_clause;
97
98 /**
99 * Current page record
100 *
101 * @var array
102 */
103 public $pageinfo;
104
105 /**
106 * Background color 1
107 *
108 * @var string
109 */
110 public $color;
111
112 /**
113 * Background color 2
114 *
115 * @var string
116 */
117 public $color2;
118
119 /**
120 * Background color 3
121 *
122 * @var string
123 */
124 public $color3;
125
126 /**
127 * Set internally if the current user either OWNS the page OR is admin user!
128 *
129 * @var boolean
130 */
131 public $editingAllowed;
132
133 /**
134 * Internal, static: GPvars: Page id.
135 *
136 * @var integer
137 */
138 public $id;
139
140 /**
141 * If set, editing of the page permissions will occur (showing the editing screen). Notice:
142 * This value is evaluated against permissions and so it will change internally!
143 *
144 * @var boolean
145 */
146 public $edit;
147
148 /**
149 * ID to return to after editing.
150 *
151 * @var integer
152 */
153 public $return_id;
154
155 /**
156 * Id of the page which was just edited.
157 *
158 * @var integer
159 */
160 public $lastEdited;
161
162 /**
163 * Initialization of the class
164 *
165 * @return void
166 */
167 public function init() {
168 // Setting GPvars:
169 $this->id = (int)GeneralUtility::_GP('id');
170 $this->edit = GeneralUtility::_GP('edit');
171 $this->return_id = GeneralUtility::_GP('return_id');
172 $this->lastEdited = GeneralUtility::_GP('lastEdited');
173 // Module name;
174 $this->MCONF = $GLOBALS['MCONF'];
175 // Page select clause:
176 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
177 // Initializing document template object:
178 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
179 $this->doc->backPath = $GLOBALS['BACK_PATH'];
180 $this->doc->setModuleTemplate('EXT:perm/Resources/Private/Templates/perm.html');
181 $this->doc->form = '<form action="' . $GLOBALS['BACK_PATH'] . 'tce_db.php" method="post" name="editform">';
182 $this->doc->loadJavascriptLib('js/jsfunc.updateform.js');
183 $this->doc->getPageRenderer()->loadPrototype();
184 $this->doc->loadJavascriptLib(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('perm') . 'mod1/perm.js');
185 // Setting up the context sensitive menu:
186 $this->doc->getContextMenuCode();
187 // Set up menus:
188 $this->menuConfig();
189 }
190
191 /**
192 * Configuration of the menu and initialization of ->MOD_SETTINGS
193 *
194 * @return void
195 */
196 public function menuConfig() {
197 $level = $GLOBALS['LANG']->getLL('levels');
198 $this->MOD_MENU = array(
199 'depth' => array(
200 1 => '1 ' . $level,
201 2 => '2 ' . $level,
202 3 => '3 ' . $level,
203 4 => '4 ' . $level,
204 10 => '10 ' . $level
205 )
206 );
207 // Clean up settings:
208 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name']);
209 }
210
211 /**
212 * Main function, creating the content for the access editing forms/listings
213 *
214 * @return void
215 */
216 public function main() {
217 // Access check...
218 // The page will show only if there is a valid page and if this page may be viewed by the user
219 $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
220 $access = is_array($this->pageinfo);
221 // Checking access:
222 if ($this->id && $access || $GLOBALS['BE_USER']->isAdmin() && !$this->id) {
223 if ($GLOBALS['BE_USER']->isAdmin() && !$this->id) {
224 $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
225 }
226 // This decides if the editform can and will be drawn:
227 $this->editingAllowed = $this->pageinfo['perms_userid'] == $GLOBALS['BE_USER']->user['uid'] || $GLOBALS['BE_USER']->isAdmin();
228 $this->edit = $this->edit && $this->editingAllowed;
229 // If $this->edit then these functions are called in the end of the page...
230 if ($this->edit) {
231 $this->doc->postCode .= $this->doc->wrapScriptTags('
232 setCheck("check[perms_user]", "data[pages][' . $this->id . '][perms_user]");
233 setCheck("check[perms_group]", "data[pages][' . $this->id . '][perms_group]");
234 setCheck("check[perms_everybody]", "data[pages][' . $this->id . '][perms_everybody]");
235 ');
236 }
237
238 // Draw the HTML page header.
239 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('permissions') . ($this->edit ? ': ' . $GLOBALS['LANG']->getLL('Edit') : ''));
240 $vContent = $this->doc->getVersionSelector($this->id, 1);
241 if ($vContent) {
242 $this->content .= $this->doc->section('', $vContent);
243 }
244
245 // Main function, branching out:
246 if (!$this->edit) {
247 $this->notEdit();
248 } else {
249 $this->doEdit();
250 }
251
252 $docHeaderButtons = $this->getButtons();
253 $markers['CSH'] = $this->docHeaderButtons['csh'];
254 $markers['FUNC_MENU'] = BackendUtility::getFuncMenu($this->id, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']);
255 $markers['CONTENT'] = $this->content;
256
257 // Build the <body> for the module
258 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
259 } else {
260 // If no access or if ID == zero
261 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('permissions'));
262 }
263 // Renders the module page
264 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('permissions'), $this->content);
265 }
266
267 /**
268 * Outputting the accumulated content to screen
269 *
270 * @return void
271 */
272 public function printContent() {
273 $this->content = $this->doc->insertStylesAndJS($this->content);
274 echo $this->content;
275 }
276
277 /**
278 * Create the panel of buttons for submitting the form or otherwise perform operations.
279 *
280 * @return array all available buttons as an assoc. array
281 */
282 protected function getButtons() {
283 $buttons = array(
284 'csh' => '',
285 'view' => '',
286 'shortcut' => ''
287 );
288 // CSH
289 $buttons['csh'] = BackendUtility::cshItem('_MOD_web_info', '', $GLOBALS['BACK_PATH'], '', TRUE);
290 // View page
291 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewonclick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
292 // Shortcut
293 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
294 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
295 }
296 return $buttons;
297 }
298
299 /*****************************
300 *
301 * Listing and Form rendering
302 *
303 *****************************/
304 /**
305 * Creating form for editing the permissions ($this->edit = TRUE)
306 * (Adding content to internal content variable)
307 *
308 * @return void
309 */
310 public function doEdit() {
311 if ($GLOBALS['BE_USER']->workspace != 0) {
312 // Adding section with the permission setting matrix:
313 $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('WorkspaceWarningText'), $GLOBALS['LANG']->getLL('WorkspaceWarning'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
314 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
315 $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
316 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
317 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
318 $defaultFlashMessageQueue->enqueue($flashMessage);
319 }
320 // Get usernames and groupnames
321 $beGroupArray = BackendUtility::getListGroupNames('title,uid');
322 $beGroupKeys = array_keys($beGroupArray);
323 $beUserArray = BackendUtility::getUserNames();
324 if (!$GLOBALS['BE_USER']->isAdmin()) {
325 $beUserArray = BackendUtility::blindUserNames($beUserArray, $beGroupKeys, 1);
326 }
327 $beGroupArray_o = ($beGroupArray = BackendUtility::getGroupNames());
328 if (!$GLOBALS['BE_USER']->isAdmin()) {
329 $beGroupArray = BackendUtility::blindGroupNames($beGroupArray_o, $beGroupKeys, 1);
330 }
331
332 // Owner selector:
333 $options = '';
334
335 // flag: is set if the page-userid equals one from the user-list
336 $userset = 0;
337 foreach ($beUserArray as $uid => $row) {
338 if ($uid == $this->pageinfo['perms_userid']) {
339 $userset = 1;
340 $selected = ' selected="selected"';
341 } else {
342 $selected = '';
343 }
344 $options .= '<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['username']) . '</option>';
345 }
346 $options = '<option value="0"></option>' . $options;
347 $selector = '<select name="data[pages][' . $this->id . '][perms_userid]">' . $options . '</select>';
348 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Owner'), $selector, TRUE);
349
350 // Group selector:
351 $options = '';
352 $userset = 0;
353 foreach ($beGroupArray as $uid => $row) {
354 if ($uid == $this->pageinfo['perms_groupid']) {
355 $userset = 1;
356 $selected = ' selected="selected"';
357 } else {
358 $selected = '';
359 }
360 $options .= '<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['title']) . '</option>';
361 }
362
363 // If the group was not set AND there is a group for the page
364 if (!$userset && $this->pageinfo['perms_groupid']) {
365 $options = '<option value="' . $this->pageinfo['perms_groupid'] . '" selected="selected">' . htmlspecialchars($beGroupArray_o[$this->pageinfo['perms_groupid']]['title']) . '</option>' . $options;
366 }
367 $options = '<option value="0"></option>' . $options;
368 $selector = '<select name="data[pages][' . $this->id . '][perms_groupid]">' . $options . '</select>';
369
370 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Group'), $selector, TRUE);
371
372 // Permissions checkbox matrix:
373 $code = '
374 <table class="t3-table" id="typo3-permissionMatrix">
375 <thead>
376 <tr>
377 <th></th>
378 <th>' . $GLOBALS['LANG']->getLL('1', TRUE) . '</th>
379 <th>' . $GLOBALS['LANG']->getLL('16', TRUE) . '</th>
380 <th>' . $GLOBALS['LANG']->getLL('2', TRUE) . '</th>
381 <th>' . $GLOBALS['LANG']->getLL('4', TRUE) . '</th>
382 <th>' . $GLOBALS['LANG']->getLL('8', TRUE) . '</th>
383 </tr>
384 </thead>
385 <tbody>
386 <tr>
387 <td><strong>' . $GLOBALS['LANG']->getLL('Owner', TRUE) . '</strong></td>
388 <td>' . $this->printCheckBox('perms_user', 1) . '</td>
389 <td>' . $this->printCheckBox('perms_user', 5) . '</td>
390 <td>' . $this->printCheckBox('perms_user', 2) . '</td>
391 <td>' . $this->printCheckBox('perms_user', 3) . '</td>
392 <td>' . $this->printCheckBox('perms_user', 4) . '</td>
393 </tr>
394 <tr>
395 <td><strong>' . $GLOBALS['LANG']->getLL('Group', TRUE) . '</strong></td>
396 <td>' . $this->printCheckBox('perms_group', 1) . '</td>
397 <td>' . $this->printCheckBox('perms_group', 5) . '</td>
398 <td>' . $this->printCheckBox('perms_group', 2) . '</td>
399 <td>' . $this->printCheckBox('perms_group', 3) . '</td>
400 <td>' . $this->printCheckBox('perms_group', 4) . '</td>
401 </tr>
402 <tr>
403 <td><strong>' . $GLOBALS['LANG']->getLL('Everybody', TRUE) . '</strong></td>
404 <td>' . $this->printCheckBox('perms_everybody', 1) . '</td>
405 <td>' . $this->printCheckBox('perms_everybody', 5) . '</td>
406 <td>' . $this->printCheckBox('perms_everybody', 2) . '</td>
407 <td>' . $this->printCheckBox('perms_everybody', 3) . '</td>
408 <td>' . $this->printCheckBox('perms_everybody', 4) . '</td>
409 </tr>
410 </tbody>
411 </table>
412
413 <input type="hidden" name="data[pages][' . $this->id . '][perms_user]" value="' . $this->pageinfo['perms_user'] . '" />
414 <input type="hidden" name="data[pages][' . $this->id . '][perms_group]" value="' . $this->pageinfo['perms_group'] . '" />
415 <input type="hidden" name="data[pages][' . $this->id . '][perms_everybody]" value="' . $this->pageinfo['perms_everybody'] . '" />
416 ' . $this->getRecursiveSelect($this->id, $this->perms_clause) . '
417 <input type="submit" name="submit" value="' . $GLOBALS['LANG']->getLL('Save', TRUE) . '" />' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('Abort', TRUE) . '" onclick="' . htmlspecialchars(('jumpToUrl(' . GeneralUtility::quoteJSvalue((BackendUtility::getModuleUrl('web_perm') . '&id=' . $this->id), TRUE) . '); return false;')) . '" />
418 <input type="hidden" name="redirect" value="' . htmlspecialchars((BackendUtility::getModuleUrl('web_perm') . '&mode=' . $this->MOD_SETTINGS['mode'] . '&depth=' . $this->MOD_SETTINGS['depth'] . '&id=' . (int)$this->return_id . '&lastEdited=' . $this->id)) . '" />
419 ' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
420
421 // Adding section with the permission setting matrix:
422 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('permissions'), $code, TRUE);
423
424 // CSH for permissions setting
425 $this->content .= BackendUtility::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'], '<br /><br />');
426
427 // Adding help text:
428 if ($GLOBALS['BE_USER']->uc['helpText']) {
429 $legendText = '<p><strong>' . $GLOBALS['LANG']->getLL('1', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('1_t', TRUE) . '<br />';
430 $legendText .= '<strong>' . $GLOBALS['LANG']->getLL('16', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('16_t', TRUE) . '<br />';
431 $legendText .= '<strong>' . $GLOBALS['LANG']->getLL('2', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('2_t', TRUE) . '<br />';
432 $legendText .= '<strong>' . $GLOBALS['LANG']->getLL('4', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('4_t', TRUE) . '<br />';
433 $legendText .= '<strong>' . $GLOBALS['LANG']->getLL('8', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('8_t', TRUE) . '</p>';
434
435 $code = $legendText . '<p>' . $GLOBALS['LANG']->getLL('def', TRUE) . '</p>';
436
437 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Legend', TRUE), $code, TRUE);
438 }
439 }
440
441 /**
442 * Showing the permissions in a tree ($this->edit = FALSE)
443 * (Adding content to internal content variable)
444 *
445 * @return void
446 */
447 public function notEdit() {
448 // Get usernames and groupnames: The arrays we get in return contains only 1) users which are members of the groups of the current user, 2) groups that the current user is member of
449 $beGroupKeys = $GLOBALS['BE_USER']->userGroupsUID;
450 $beUserArray = BackendUtility::getUserNames();
451 if (!$GLOBALS['BE_USER']->isAdmin()) {
452 $beUserArray = BackendUtility::blindUserNames($beUserArray, $beGroupKeys, 0);
453 }
454 $beGroupArray = BackendUtility::getGroupNames();
455 if (!$GLOBALS['BE_USER']->isAdmin()) {
456 $beGroupArray = BackendUtility::blindGroupNames($beGroupArray, $beGroupKeys, 0);
457 }
458
459 // Length of strings:
460 $tLen = 20;
461
462 // Selector for depth:
463 $code = $GLOBALS['LANG']->getLL('Depth') . ': ';
464 $code .= BackendUtility::getFuncMenu($this->id, 'SET[depth]', $this->MOD_SETTINGS['depth'], $this->MOD_MENU['depth']);
465 $this->content .= $this->doc->section('', $code);
466
467 /** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView */
468 $tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
469 $tree->init('AND ' . $this->perms_clause);
470 $tree->addField('perms_user', 1);
471 $tree->addField('perms_group', 1);
472 $tree->addField('perms_everybody', 1);
473 $tree->addField('perms_userid', 1);
474 $tree->addField('perms_groupid', 1);
475 $tree->addField('hidden');
476 $tree->addField('fe_group');
477 $tree->addField('starttime');
478 $tree->addField('endtime');
479 $tree->addField('editlock');
480
481 // Creating top icon; the current page
482 $HTML = IconUtility::getSpriteIconForRecord('pages', $this->pageinfo);
483 $tree->tree[] = array('row' => $this->pageinfo, 'HTML' => $HTML);
484
485 // Create the tree from $this->id:
486 $tree->getTree($this->id, $this->MOD_SETTINGS['depth'], '');
487
488 // Make header of table:
489 $code = '
490 <thead>
491 <tr>
492 <th colspan="2">&nbsp;</th>
493 <th>' . $GLOBALS['LANG']->getLL('Owner', TRUE) . '</th>
494 <th align="center">' . $GLOBALS['LANG']->getLL('Group', TRUE) . '</th>
495 <th align="center">' . $GLOBALS['LANG']->getLL('Everybody', TRUE) . '</th>
496 <th align="center">' . $GLOBALS['LANG']->getLL('EditLock', TRUE) . '</th>
497 </tr>
498 </thead>
499 ';
500
501 // Traverse tree:
502 foreach ($tree->tree as $data) {
503 $cells = array();
504 $pageId = $data['row']['uid'];
505
506 // Background colors:
507 $bgCol = $this->lastEdited == $pageId ? ' class="bgColor-20"' : '';
508 $lE_bgCol = $bgCol;
509
510 // User/Group names:
511 $userName = $beUserArray[$data['row']['perms_userid']] ?
512 $beUserArray[$data['row']['perms_userid']]['username'] :
513 ($data['row']['perms_userid'] ? $data['row']['perms_userid'] : '');
514
515 if ($data['row']['perms_userid'] && !$beUserArray[$data['row']['perms_userid']]) {
516 $userName = \TYPO3\CMS\Perm\Controller\PermissionAjaxController::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(GeneralUtility::fixed_lgd_cs($userName, 20)), FALSE);
517 } else {
518 $userName = \TYPO3\CMS\Perm\Controller\PermissionAjaxController::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(GeneralUtility::fixed_lgd_cs($userName, 20)));
519 }
520
521 $groupName = $beGroupArray[$data['row']['perms_groupid']] ?
522 $beGroupArray[$data['row']['perms_groupid']]['title'] :
523 ($data['row']['perms_groupid'] ? $data['row']['perms_groupid'] : '');
524
525 if ($data['row']['perms_groupid'] && !$beGroupArray[$data['row']['perms_groupid']]) {
526 $groupName = \TYPO3\CMS\Perm\Controller\PermissionAjaxController::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(GeneralUtility::fixed_lgd_cs($groupName, 20)), FALSE);
527 } else {
528 $groupName = \TYPO3\CMS\Perm\Controller\PermissionAjaxController::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(GeneralUtility::fixed_lgd_cs($groupName, 20)));
529 }
530
531 // Seeing if editing of permissions are allowed for that page:
532 $editPermsAllowed = $data['row']['perms_userid'] == $GLOBALS['BE_USER']->user['uid'] || $GLOBALS['BE_USER']->isAdmin();
533
534 // First column:
535 $cellAttrib = $data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '';
536 $cells[] = '<td align="left" nowrap="nowrap"' . ($cellAttrib ? $cellAttrib : $bgCol) . '>' .
537 $data['HTML'] . htmlspecialchars(GeneralUtility::fixed_lgd_cs($data['row']['title'], $tLen)) . '</td>';
538
539 // "Edit permissions" -icon
540 if ($editPermsAllowed && $pageId) {
541 $aHref = BackendUtility::getModuleUrl('web_perm') . '&mode=' . $this->MOD_SETTINGS['mode'] . '&depth=' . $this->MOD_SETTINGS['depth'] . '&id=' . ($data['row']['_ORIG_uid'] ? $data['row']['_ORIG_uid'] : $pageId) . '&return_id=' . $this->id . '&edit=1';
542 $cells[] = '<td' . $bgCol . '><a href="' . htmlspecialchars($aHref) . '" title="' . $GLOBALS['LANG']->getLL('ch_permissions', TRUE) . '">' .
543 IconUtility::getSpriteIcon('actions-document-open') . '</a></td>';
544 } else {
545 $cells[] = '<td' . $bgCol . '></td>';
546 }
547
548 $cells[] = '
549 <td' . $bgCol . ' nowrap="nowrap">' . ($pageId ? \TYPO3\CMS\Perm\Controller\PermissionAjaxController::renderPermissions($data['row']['perms_user'], $pageId, 'user') . ' ' . $userName : '') . '</td>
550 <td' . $bgCol . ' nowrap="nowrap">' . ($pageId ? \TYPO3\CMS\Perm\Controller\PermissionAjaxController::renderPermissions($data['row']['perms_group'], $pageId, 'group') . ' ' . $groupName : '') . '</td>
551 <td' . $bgCol . ' nowrap="nowrap">' . ($pageId ? ' ' . \TYPO3\CMS\Perm\Controller\PermissionAjaxController::renderPermissions($data['row']['perms_everybody'], $pageId, 'everybody') : '') . '</td>
552 <td' . $bgCol . ' nowrap="nowrap">' . ($data['row']['editlock'] ? '<span id="el_' . $pageId . '" class="editlock"><a class="editlock" onclick="WebPermissions.toggleEditLock(\'' . $pageId . '\', \'1\');" title="' . $GLOBALS['LANG']->getLL('EditLock_descr', TRUE) . '">' . IconUtility::getSpriteIcon('status-warning-lock') . '</a></span>' : ($pageId === 0 ? '' : '<span id="el_' . $pageId . '" class="editlock"><a class="editlock" onclick="WebPermissions.toggleEditLock(\'' . $pageId . '\', \'0\');" title="Enable the &raquo;Admin-only&laquo; edit lock for this page">[+]</a></span>')) . '</td>
553 ';
554
555 // Compile table row:
556 $code .= '<tr>' . implode('', $cells) . '</tr>';
557 }
558
559 // Wrap rows in table tags:
560 $code = '<table class="t3-table" id="typo3-permissionList">' . $code . '</table>';
561
562 // Adding the content as a section:
563 $this->content .= $this->doc->section('', $code);
564
565 // CSH for permissions setting
566 $this->content .= BackendUtility::cshItem('xMOD_csh_corebe', 'perm_module', $GLOBALS['BACK_PATH'], '<br />|');
567
568 // Creating legend table:
569 $legendText = '<strong>' . $GLOBALS['LANG']->getLL('1', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('1_t', TRUE);
570 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('16', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('16_t', TRUE);
571 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('2', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('2_t', TRUE);
572 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('4', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('4_t', TRUE);
573 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('8', TRUE) . '</strong>: ' . $GLOBALS['LANG']->getLL('8_t', TRUE);
574
575 $code = '<div id="permission-information">
576 <img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/legend.gif', 'width="86" height="75"') . ' alt="" />
577 <div class="text">' . $legendText . '</div></div>';
578
579 $code .= '<div id="perm-legend">' . $GLOBALS['LANG']->getLL('def', TRUE);
580 $code .= '<br /><br />' . IconUtility::getSpriteIcon('status-status-permission-granted') . ': ' . $GLOBALS['LANG']->getLL('A_Granted', TRUE);
581 $code .= '<br />' . IconUtility::getSpriteIcon('status-status-permission-denied') . ': ' . $GLOBALS['LANG']->getLL('A_Denied', TRUE);
582 $code .= '</div>';
583
584 // Adding section with legend code:
585 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Legend') . ':', $code, TRUE, TRUE);
586 }
587
588 /*****************************
589 *
590 * Helper functions
591 *
592 *****************************/
593 /**
594 * Print a checkbox for the edit-permission form
595 *
596 * @param string $checkName Checkbox name key
597 * @param integer $num Checkbox number index
598 * @return string HTML checkbox
599 */
600 public function printCheckBox($checkName, $num) {
601 $onclick = 'checkChange(\'check[' . $checkName . ']\', \'data[pages][' . $GLOBALS['SOBE']->id . '][' . $checkName . ']\')';
602 return '<input type="checkbox" name="check[' . $checkName . '][' . $num . ']" onclick="' . htmlspecialchars($onclick) . '" /><br />';
603 }
604
605 /**
606 * Finding tree and offer setting of values recursively.
607 *
608 * @param integer $id Page id.
609 * @param string $perms_clause Select clause
610 * @return string Select form element for recursive levels (if any levels are found)
611 */
612 public function getRecursiveSelect($id, $perms_clause) {
613 // Initialize tree object:
614 $tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
615 $tree->init('AND ' . $perms_clause);
616 $tree->addField('perms_userid', 1);
617 $tree->makeHTML = 0;
618 $tree->setRecs = 1;
619 // Make tree:
620 $tree->getTree($id, $this->getLevels, '');
621 // If there are a hierarchy of page ids, then...
622 if ($GLOBALS['BE_USER']->user['uid'] && count($tree->orig_ids_hierarchy)) {
623 // Init:
624 $label_recur = $GLOBALS['LANG']->getLL('recursive');
625 $label_levels = $GLOBALS['LANG']->getLL('levels');
626 $label_pA = $GLOBALS['LANG']->getLL('pages_affected');
627 $theIdListArr = array();
628 $opts = '
629 <option value=""></option>';
630 // Traverse the number of levels we want to allow recursive setting of permissions for:
631 for ($a = $this->getLevels; $a > 0; $a--) {
632 if (is_array($tree->orig_ids_hierarchy[$a])) {
633 foreach ($tree->orig_ids_hierarchy[$a] as $theId) {
634 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->user['uid'] == $tree->recs[$theId]['perms_userid']) {
635 $theIdListArr[] = $theId;
636 }
637 }
638 $lKey = $this->getLevels - $a + 1;
639 $opts .= '
640 <option value="' . htmlspecialchars(implode(',', $theIdListArr)) . '">' . GeneralUtility::deHSCentities(htmlspecialchars(($label_recur . ' ' . $lKey . ' ' . $label_levels))) . ' (' . count($theIdListArr) . ' ' . $label_pA . ')' . '</option>';
641 }
642 }
643 // Put the selector box together:
644 $theRecursiveSelect = '<br />
645 <select name="mirror[pages][' . $id . ']">
646 ' . $opts . '
647 </select>
648 <br /><br />';
649 } else {
650 $theRecursiveSelect = '';
651 }
652 // Return selector box element:
653 return $theRecursiveSelect;
654 }
655
656 }