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