[TASK] Remove function index
[Packages/TYPO3.CMS.git] / typo3 / sysext / perm / mod1 / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Module: Permission setting
29 *
30 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
31 * XHTML compliant
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36 unset($MCONF);
37 require('conf.php');
38 require($BACK_PATH.'init.php');
39 require($BACK_PATH.'template.php');
40 require('class.sc_mod_web_perm_ajax.php');
41 $LANG->includeLLFile('EXT:lang/locallang_mod_web_perm.xml');
42
43 $BE_USER->modAccess($MCONF,1);
44
45
46
47
48
49
50 /**
51 * Module: Permission setting
52 *
53 * Script Class for the Web > Access module
54 * This module lets you view and change permissions for pages.
55 *
56 * Variables:
57 * $this->MOD_SETTINGS['depth']: intval 1-3: decides the depth of the list
58 * $this->MOD_SETTINGS['mode']: 'perms' / '': decides if we view a user-overview or the permissions.
59 *
60 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
61 * @author Andreas Kundoch <typo3@mehrwert.de>
62 * @package TYPO3
63 * @subpackage core
64 */
65 class SC_mod_web_perm_index {
66
67 /**
68 * Number of levels to enable recursive settings for
69 * @var integer
70 */
71 public $getLevels = 10;
72
73 /**
74 * Module config
75 * Internal static
76 * @var array
77 */
78 protected $MCONF = array();
79
80 /**
81 * Document Template Object
82 * @var template
83 */
84 public $doc;
85
86 /**
87 * Content accumulation
88 * @var string
89 */
90 public $content;
91
92 /**
93 * Module menu
94 * @var array
95 */
96 public $MOD_MENU = array();
97
98 /**
99 * Module settings, cleansed.
100 * @var aray
101 */
102 public $MOD_SETTINGS = array();
103
104 /**
105 * Page select permissions
106 * @var string
107 */
108 public $perms_clause;
109
110 /**
111 * Current page record
112 * @var array
113 */
114 public $pageinfo;
115
116 /**
117 * Background color 1
118 * @var string
119 */
120 public $color;
121
122 /**
123 * Background color 2
124 * @var string
125 */
126 public $color2;
127
128 /**
129 * Background color 3
130 * @var string
131 */
132 public $color3;
133
134 /**
135 * Set internally if the current user either OWNS the page OR is admin user!
136 * @var boolean
137 */
138 public $editingAllowed;
139
140 /**
141 * Internal, static: GPvars: Page id.
142 * @var integer
143 */
144 public $id;
145
146 /**
147 * If set, editing of the page permissions will occur (showing the editing screen). Notice:
148 * This value is evaluated against permissions and so it will change internally!
149 * @var boolean
150 */
151 public $edit;
152
153 /**
154 * ID to return to after editing.
155 * @var integer
156 */
157 public $return_id;
158
159 /**
160 * Id of the page which was just edited.
161 * @var integer
162 */
163 public $lastEdited;
164
165 /**
166 * Initialization of the class
167 *
168 * @return void
169 */
170 public function init() {
171
172 // Setting GPvars:
173 $this->id = intval(t3lib_div::_GP('id'));
174 $this->edit = t3lib_div::_GP('edit');
175 $this->return_id = t3lib_div::_GP('return_id');
176 $this->lastEdited = t3lib_div::_GP('lastEdited');
177
178 // Module name;
179 $this->MCONF = $GLOBALS['MCONF'];
180
181 // Page select clause:
182 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
183
184 // Initializing document template object:
185 $this->doc = t3lib_div::makeInstance('template');
186 $this->doc->backPath = $GLOBALS['BACK_PATH'];
187 $this->doc->setModuleTemplate('templates/perm.html');
188 $this->doc->form = '<form action="'.$GLOBALS['BACK_PATH'].'tce_db.php" method="post" name="editform">';
189 $this->doc->loadJavascriptLib('../t3lib/jsfunc.updateform.js');
190 $this->doc->getPageRenderer()->loadPrototype();
191 $this->doc->loadJavascriptLib(TYPO3_MOD_PATH . 'perm.js');
192
193 // Setting up the context sensitive menu:
194 $this->doc->getContextMenuCode();
195
196 // Set up menus:
197 $this->menuConfig();
198 }
199
200 /**
201 * Configuration of the menu and initialization of ->MOD_SETTINGS
202 *
203 * @return void
204 */
205 public function menuConfig() {
206 // MENU-ITEMS:
207 // If array, then it's a selector box menu
208 // If empty string it's just a variable, that'll be saved.
209 // Values NOT in this array will not be saved in the settings-array for the module.
210 $temp = $GLOBALS['LANG']->getLL('levels');
211 $this->MOD_MENU = array(
212 'depth' => array(
213 1 => '1 '.$temp,
214 2 => '2 '.$temp,
215 3 => '3 '.$temp,
216 4 => '4 '.$temp,
217 10 => '10 '.$temp
218 ),
219 'mode' => array(
220 0 => $GLOBALS['LANG']->getLL('user_overview'),
221 'perms' => $GLOBALS['LANG']->getLL('permissions')
222 )
223 );
224
225 // Clean up settings:
226 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
227 }
228
229 /**
230 * Main function, creating the content for the access editing forms/listings
231 *
232 * @return void
233 */
234 public function main() {
235 // Access check...
236 // The page will show only if there is a valid page and if this page may be viewed by the user
237 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
238 $access = is_array($this->pageinfo);
239
240 // Checking access:
241 if (($this->id && $access) || ($GLOBALS['BE_USER']->isAdmin() && !$this->id)) {
242 if ($GLOBALS['BE_USER']->isAdmin() && !$this->id) {
243 $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0);
244 }
245
246 // This decides if the editform can and will be drawn:
247 $this->editingAllowed = ($this->pageinfo['perms_userid'] == $GLOBALS['BE_USER']->user['uid'] || $GLOBALS['BE_USER']->isAdmin());
248 $this->edit = $this->edit && $this->editingAllowed;
249
250 // If $this->edit then these functions are called in the end of the page...
251 if ($this->edit) {
252 $this->doc->postCode.= $this->doc->wrapScriptTags('
253 setCheck("check[perms_user]","data[pages]['.$this->id.'][perms_user]");
254 setCheck("check[perms_group]","data[pages]['.$this->id.'][perms_group]");
255 setCheck("check[perms_everybody]","data[pages]['.$this->id.'][perms_everybody]");
256 ');
257 }
258
259 // Draw the HTML page header.
260 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('permissions') . ($this->edit ? ': ' . $GLOBALS['LANG']->getLL('Edit') : ''));
261 $this->content.=$this->doc->spacer(5);
262
263 $vContent = $this->doc->getVersionSelector($this->id,1);
264 if ($vContent) {
265 $this->content .= $this->doc->section('',$vContent);
266 }
267
268 // Main function, branching out:
269 if (!$this->edit) {
270 $this->notEdit();
271 } else {
272 $this->doEdit();
273 }
274
275 $docHeaderButtons = $this->getButtons();
276
277 $markers['CSH'] = $this->docHeaderButtons['csh'];
278 $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu($this->id, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']);
279 $markers['CONTENT'] = $this->content;
280
281 // Build the <body> for the module
282 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
283 } else {
284 // If no access or if ID == zero
285 $this->content =$this->doc->header($GLOBALS['LANG']->getLL('permissions'));
286 }
287 // Renders the module page
288 $this->content = $this->doc->render(
289 $GLOBALS['LANG']->getLL('permissions'),
290 $this->content
291 );
292 }
293
294 /**
295 * Outputting the accumulated content to screen
296 *
297 * @return void
298 */
299 public function printContent() {
300 $this->content = $this->doc->insertStylesAndJS($this->content);
301 echo $this->content;
302 }
303
304 /**
305 * Create the panel of buttons for submitting the form or otherwise perform operations.
306 *
307 * @return array all available buttons as an assoc. array
308 */
309 protected function getButtons() {
310
311 $buttons = array(
312 'csh' => '',
313 'view' => '',
314 'record_list' => '',
315 'shortcut' => '',
316 );
317 // CSH
318 $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_info', '', $GLOBALS['BACK_PATH'], '', TRUE);
319
320 // View page
321 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewonclick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '">' .
322 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
323 '</a>';
324
325 // Shortcut
326 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
327 $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']);
328 }
329
330 // If access to Web>List for user, then link to that module.
331 $buttons['record_list'] = t3lib_BEfunc::getListViewLink(
332 array(
333 'id' => $this->pageinfo['uid'],
334 'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
335 ),
336 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
337 );
338 return $buttons;
339 }
340
341
342
343
344
345
346
347
348 /*****************************
349 *
350 * Listing and Form rendering
351 *
352 *****************************/
353
354 /**
355 * Creating form for editing the permissions ($this->edit = TRUE)
356 * (Adding content to internal content variable)
357 *
358 * @return void
359 */
360 public function doEdit() {
361 if ($GLOBALS['BE_USER']->workspace != 0) {
362 // Adding section with the permission setting matrix:
363 $lockedMessage = t3lib_div::makeInstance(
364 't3lib_FlashMessage',
365 $GLOBALS['LANG']->getLL('WorkspaceWarningText'),
366 $GLOBALS['LANG']->getLL('WorkspaceWarning'),
367 t3lib_FlashMessage::WARNING
368 );
369 t3lib_FlashMessageQueue::addMessage($lockedMessage);
370 }
371
372 // Get usernames and groupnames
373 $beGroupArray = t3lib_BEfunc::getListGroupNames('title,uid');
374 $beGroupKeys = array_keys($beGroupArray);
375
376 $beUserArray = t3lib_BEfunc::getUserNames();
377 if (!$GLOBALS['BE_USER']->isAdmin()) {
378 $beUserArray = t3lib_BEfunc::blindUserNames($beUserArray,$beGroupKeys,1);
379 }
380 $beGroupArray_o = $beGroupArray = t3lib_BEfunc::getGroupNames();
381 if (!$GLOBALS['BE_USER']->isAdmin()) {
382 $beGroupArray = t3lib_BEfunc::blindGroupNames($beGroupArray_o,$beGroupKeys,1);
383 }
384 $firstGroup = $beGroupKeys[0] ? $beGroupArray[$beGroupKeys[0]] : ''; // data of the first group, the user is member of
385
386
387 // Owner selector:
388 $options='';
389 $userset=0; // flag: is set if the page-userid equals one from the user-list
390 foreach($beUserArray as $uid => $row) {
391 if ($uid==$this->pageinfo['perms_userid']) {
392 $userset = 1;
393 $selected=' selected="selected"';
394 } else {
395 $selected='';
396 }
397 $options.='
398 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['username']).'</option>';
399 }
400 $options='
401 <option value="0"></option>'.$options;
402 $selector='
403 <select name="data[pages]['.$this->id.'][perms_userid]">
404 '.$options.'
405 </select>';
406
407 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Owner') . ':', $selector);
408
409
410 // Group selector:
411 $options='';
412 $userset=0;
413 foreach($beGroupArray as $uid => $row) {
414 if ($uid==$this->pageinfo['perms_groupid']) {
415 $userset = 1;
416 $selected=' selected="selected"';
417 } else {
418 $selected='';
419 }
420 $options.='
421 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['title']).'</option>';
422 }
423 if (!$userset && $this->pageinfo['perms_groupid']) { // If the group was not set AND there is a group for the page
424 $options='
425 <option value="'.$this->pageinfo['perms_groupid'].'" selected="selected">'.
426 htmlspecialchars($beGroupArray_o[$this->pageinfo['perms_groupid']]['title']).
427 '</option>'.
428 $options;
429 }
430 $options='
431 <option value="0"></option>'.$options;
432 $selector='
433 <select name="data[pages]['.$this->id.'][perms_groupid]">
434 '.$options.'
435 </select>';
436
437 $this->content.=$this->doc->divider(5);
438 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Group') . ':', $selector);
439
440 // Permissions checkbox matrix:
441 $code='
442 <table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix">
443 <tr>
444 <td></td>
445 <td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('1', 1)) . '</td>
446 <td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('16', 1)) . '</td>
447 <td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('2', 1)) . '</td>
448 <td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('4', 1)) . '</td>
449 <td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('8', 1)) . '</td>
450 </tr>
451 <tr>
452 <td align="right" class="bgColor2">' . $GLOBALS['LANG']->getLL('Owner', 1) . '</td>
453 <td class="bgColor-20">'.$this->printCheckBox('perms_user',1).'</td>
454 <td class="bgColor-20">'.$this->printCheckBox('perms_user',5).'</td>
455 <td class="bgColor-20">'.$this->printCheckBox('perms_user',2).'</td>
456 <td class="bgColor-20">'.$this->printCheckBox('perms_user',3).'</td>
457 <td class="bgColor-20">'.$this->printCheckBox('perms_user',4).'</td>
458 </tr>
459 <tr>
460 <td align="right" class="bgColor2">' . $GLOBALS['LANG']->getLL('Group', 1) . '</td>
461 <td class="bgColor-20">'.$this->printCheckBox('perms_group',1).'</td>
462 <td class="bgColor-20">'.$this->printCheckBox('perms_group',5).'</td>
463 <td class="bgColor-20">'.$this->printCheckBox('perms_group',2).'</td>
464 <td class="bgColor-20">'.$this->printCheckBox('perms_group',3).'</td>
465 <td class="bgColor-20">'.$this->printCheckBox('perms_group',4).'</td>
466 </tr>
467 <tr>
468 <td align="right" class="bgColor2">' . $GLOBALS['LANG']->getLL('Everybody', 1) . '</td>
469 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',1).'</td>
470 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',5).'</td>
471 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',2).'</td>
472 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',3).'</td>
473 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',4).'</td>
474 </tr>
475 </table>
476 <br />
477
478 <input type="hidden" name="data[pages]['.$this->id.'][perms_user]" value="'.$this->pageinfo['perms_user'].'" />
479 <input type="hidden" name="data[pages]['.$this->id.'][perms_group]" value="'.$this->pageinfo['perms_group'].'" />
480 <input type="hidden" name="data[pages]['.$this->id.'][perms_everybody]" value="'.$this->pageinfo['perms_everybody'].'" />
481 '.$this->getRecursiveSelect($this->id,$this->perms_clause).'
482 <input type="submit" name="submit" value="' . $GLOBALS['LANG']->getLL('Save', 1) . '" />'.
483 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('Abort', 1) . '" onclick="' . htmlspecialchars('jumpToUrl(\'index.php?id=' . $this->id . '\'); return false;') . '" />
484 <input type="hidden" name="redirect" value="'.htmlspecialchars(TYPO3_MOD_PATH.'index.php?mode='.$this->MOD_SETTINGS['mode'].'&depth='.$this->MOD_SETTINGS['depth'].'&id='.intval($this->return_id).'&lastEdited='.$this->id).'" />
485 ' . t3lib_TCEforms::getHiddenTokenField('tceAction');
486
487 // Adding section with the permission setting matrix:
488 $this->content.=$this->doc->divider(5);
489 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('permissions') . ':', $code);
490
491 // CSH for permissions setting
492 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'], '<br /><br />');
493
494 // Adding help text:
495 if ($GLOBALS['BE_USER']->uc['helpText']) {
496 $this->content.=$this->doc->divider(20);
497 $legendText = '<strong>' . $GLOBALS['LANG']->getLL('1', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('1_t', 1);
498 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('16', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('16_t', 1);
499 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('2', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('2_t', 1);
500 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('4', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('4_t', 1);
501 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('8', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('8_t', 1);
502
503 $code = $legendText . '<br /><br />' . $GLOBALS['LANG']->getLL('def', 1);
504 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Legend', 1) . ':', $code);
505 }
506 }
507
508 /**
509 * Showing the permissions in a tree ($this->edit = FALSE)
510 * (Adding content to internal content variable)
511 *
512 * @return void
513 */
514 public function notEdit() {
515 // 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
516 $beGroupKeys = $GLOBALS['BE_USER']->userGroupsUID;
517 $beUserArray = t3lib_BEfunc::getUserNames();
518 if (!$GLOBALS['BE_USER']->isAdmin()) {
519 $beUserArray = t3lib_BEfunc::blindUserNames($beUserArray,$beGroupKeys,0);
520 }
521 $beGroupArray = t3lib_BEfunc::getGroupNames();
522 if (!$GLOBALS['BE_USER']->isAdmin()) {
523 $beGroupArray = t3lib_BEfunc::blindGroupNames($beGroupArray,$beGroupKeys,0);
524 }
525
526 // Length of strings:
527 $tLen= ($this->MOD_SETTINGS['mode']=='perms' ? 20 : 30);
528
529
530 // Selector for depth:
531 $code = $GLOBALS['LANG']->getLL('Depth') . ': ';
532 $code.=t3lib_BEfunc::getFuncMenu($this->id,'SET[depth]',$this->MOD_SETTINGS['depth'],$this->MOD_MENU['depth']);
533 $this->content.=$this->doc->section('',$code);
534 $this->content.=$this->doc->spacer(5);
535
536 // Initialize tree object:
537 $tree = t3lib_div::makeInstance('t3lib_pageTree');
538 $tree->init('AND '.$this->perms_clause);
539
540 $tree->addField('perms_user',1);
541 $tree->addField('perms_group',1);
542 $tree->addField('perms_everybody',1);
543 $tree->addField('perms_userid',1);
544 $tree->addField('perms_groupid',1);
545 $tree->addField('hidden');
546 $tree->addField('fe_group');
547 $tree->addField('starttime');
548 $tree->addField('endtime');
549 $tree->addField('editlock');
550
551 // Creating top icon; the current page
552 $HTML=t3lib_iconWorks::getSpriteIconForRecord('pages',$this->pageinfo);
553 $tree->tree[] = array('row'=>$this->pageinfo,'HTML'=>$HTML);
554
555 // Create the tree from $this->id:
556 $tree->getTree($this->id,$this->MOD_SETTINGS['depth'],'');
557
558 // Make header of table:
559 $code='';
560 if ($this->MOD_SETTINGS['mode']=='perms') {
561 $code.='
562 <tr class="t3-row-header">
563 <td colspan="2">&nbsp;</td>
564 <td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
565 <td>' . $GLOBALS['LANG']->getLL('Owner', TRUE) . '</td>
566 <td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
567 <td align="center">' . $GLOBALS['LANG']->getLL('Group', TRUE) . '</td>
568 <td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
569 <td align="center">' . $GLOBALS['LANG']->getLL('Everybody', TRUE) . '</td>
570 <td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
571 <td align="center">' . $GLOBALS['LANG']->getLL('EditLock', TRUE) . '</td>
572 </tr>
573 ';
574 } else {
575 $code.='
576 <tr class="t3-row-header">
577 <td colspan="2">&nbsp;</td>
578 <td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
579 <td align="center" nowrap="nowrap">' . $GLOBALS['LANG']->getLL('User', TRUE) . ': ' . htmlspecialchars($GLOBALS['BE_USER']->user['username']) . '</td>
580 ' . (!$GLOBALS['BE_USER']->isAdmin() ? '<td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
581 <td align="center">' . $GLOBALS['LANG']->getLL('EditLock', TRUE) . '</td>' : '') . '
582 </tr>';
583 }
584
585 // Traverse tree:
586 foreach ($tree->tree as $data) {
587 $cells = array();
588 $pageId = $data['row']['uid'];
589
590 // Background colors:
591 $bgCol = ($this->lastEdited == $pageId ? ' class="bgColor-20"' : '');
592 $lE_bgCol = $bgCol;
593
594 // User/Group names:
595 $userName = $beUserArray[$data['row']['perms_userid']] ? $beUserArray[$data['row']['perms_userid']]['username'] : ($data['row']['perms_userid'] ? $data['row']['perms_userid'] : '');
596 if ($data['row']['perms_userid'] && (!$beUserArray[$data['row']['perms_userid']])) {
597 $userName = SC_mod_web_perm_ajax::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($userName, 20)), FALSE);
598 } else {
599 $userName = SC_mod_web_perm_ajax::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($userName, 20)));
600 }
601
602 $groupName = $beGroupArray[$data['row']['perms_groupid']] ? $beGroupArray[$data['row']['perms_groupid']]['title'] : ($data['row']['perms_groupid'] ? $data['row']['perms_groupid'] : '');
603 if ($data['row']['perms_groupid'] && (!$beGroupArray[$data['row']['perms_groupid']])) {
604 $groupName = SC_mod_web_perm_ajax::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($groupName, 20)), FALSE);
605 } else {
606 $groupName = SC_mod_web_perm_ajax::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($groupName, 20)));
607 }
608
609 // Seeing if editing of permissions are allowed for that page:
610 $editPermsAllowed = ($data['row']['perms_userid'] == $GLOBALS['BE_USER']->user['uid'] || $GLOBALS['BE_USER']->isAdmin());
611
612
613 // First column:
614 $cellAttrib = ($data['row']['_CSSCLASS'] ? ' class="'.$data['row']['_CSSCLASS'].'"' : '');
615 $cells[]='
616 <td align="left" nowrap="nowrap"'.($cellAttrib ? $cellAttrib : $bgCol).'>'.$data['HTML'].htmlspecialchars(t3lib_div::fixed_lgd_cs($data['row']['title'],$tLen)).'&nbsp;</td>';
617
618 // "Edit permissions" -icon
619 if ($editPermsAllowed && $pageId) {
620 $aHref = 'index.php?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';
621 $cells[]='
622 <td' . $bgCol . '><a href="' . htmlspecialchars($aHref) . '" title="' . $GLOBALS['LANG']->getLL('ch_permissions', 1) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a></td>';
623 } else {
624 $cells[]='
625 <td'.$bgCol.'></td>';
626 }
627
628 // Rest of columns (depending on mode)
629 if ($this->MOD_SETTINGS['mode'] == 'perms') {
630 $cells[]='
631 <td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
632 <td'.$bgCol.' nowrap="nowrap">'.($pageId ? SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_user'], $pageId, 'user').' '.$userName : '').'</td>
633
634 <td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
635 <td'.$bgCol.' nowrap="nowrap">'.($pageId ? SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_group'], $pageId, 'group').' '.$groupName : '').'</td>
636
637 <td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
638 <td'.$bgCol.' nowrap="nowrap">'.($pageId ? ' '.SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_everybody'], $pageId, 'everybody') : '').'</td>
639
640 <td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
641 <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', 1) . '">' .
642 t3lib_iconWorks::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>
643 ';
644 } else {
645 $cells[]='
646 <td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>';
647
648 $bgCol = ($GLOBALS['BE_USER']->user['uid'] == $data['row']['perms_userid'] ? ' class="bgColor-20"' : $lE_bgCol);
649
650 // FIXME $owner undefined
651 $cells[]='
652 <td'.$bgCol.' nowrap="nowrap" align="center">'.($pageId ? $owner.SC_mod_web_perm_ajax::renderPermissions($GLOBALS['BE_USER']->calcPerms($data['row']), $pageId, 'user') : '').'</td>
653 ' . (!$GLOBALS['BE_USER']->isAdmin() ? '
654 <td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
655 <td'.$bgCol.' nowrap="nowrap">'.($data['row']['editlock'] ? t3lib_iconWorks::getSpriteIcon('status-warning-lock', array('title' => $GLOBALS['LANG']->getLL('EditLock_descr', TRUE))) : '').'</td>
656 ':'');
657 $bgCol = $lE_bgCol;
658 }
659
660 // Compile table row:
661 $code .= '
662 <tr>
663 '.implode('
664 ',$cells).'
665 </tr>';
666 }
667
668 // Wrap rows in table tags:
669 $code = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-permissionList">' . $code . '</table>';
670
671 // Adding the content as a section:
672 $this->content.=$this->doc->section('',$code);
673
674 // CSH for permissions setting
675 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module', $GLOBALS['BACK_PATH'], '<br />|');
676
677 // Creating legend table:
678 $legendText = '<strong>' . $GLOBALS['LANG']->getLL('1', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('1_t', 1);
679 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('16', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('16_t', 1);
680 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('2', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('2_t', 1);
681 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('4', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('4_t', 1);
682 $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('8', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('8_t', 1);
683
684 $code='<table border="0" id="typo3-legendTable">
685 <tr>
686 <td valign="top">
687 <img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/legend.gif', 'width="86" height="75"') . ' alt="" />
688 </td>
689 <td valign="top" nowrap="nowrap">'.$legendText.'</td>
690 </tr>
691 </table>';
692 $code.='<div id="perm-legend">' . $GLOBALS['LANG']->getLL('def',1 );
693 $code.='<br /><br />' . t3lib_iconWorks::getSpriteIcon('status-status-permission-granted') . ': ' . $GLOBALS['LANG']->getLL('A_Granted', 1);
694 $code.='<br />' . t3lib_iconWorks::getSpriteIcon('status-status-permission-denied') . ': ' . $GLOBALS['LANG']->getLL('A_Denied', 1);
695 $code.='</div>';
696
697 // Adding section with legend code:
698 $this->content.=$this->doc->spacer(20);
699 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('Legend') . ':', $code, 0, 1);
700 }
701
702
703
704
705
706
707
708 /*****************************
709 *
710 * Helper functions
711 *
712 *****************************/
713
714 /**
715 * Print a checkbox for the edit-permission form
716 *
717 * @param string Checkbox name key
718 * @param integer Checkbox number index
719 * @return string HTML checkbox
720 */
721 public function printCheckBox($checkName, $num) {
722 $onclick = 'checkChange(\'check['.$checkName.']\', \'data[pages]['.$GLOBALS['SOBE']->id.']['.$checkName.']\')';
723 return '<input type="checkbox" name="check['.$checkName.']['.$num.']" onclick="'.htmlspecialchars($onclick).'" /><br />';
724 }
725
726
727 /**
728 * Returns the permissions for a group based of the perms_groupid of $row. If the $row[perms_groupid] equals the $firstGroup[uid] then the function returns perms_everybody OR'ed with perms_group, else just perms_everybody
729 *
730 * @param array Row array (from pages table)
731 * @param array First group data
732 * @return integer Integer: Combined permissions.
733 */
734 public function groupPerms($row, $firstGroup) {
735 if (is_array($row)) {
736 $out = intval($row['perms_everybody']);
737 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
738 $out |= intval($row['perms_group']);
739 }
740 return $out;
741 }
742 }
743
744 /**
745 * Finding tree and offer setting of values recursively.
746 *
747 * @param integer Page id.
748 * @param string Select clause
749 * @return string Select form element for recursive levels (if any levels are found)
750 */
751 public function getRecursiveSelect($id,$perms_clause) {
752
753 // Initialize tree object:
754 $tree = t3lib_div::makeInstance('t3lib_pageTree');
755 $tree->init('AND '.$perms_clause);
756 $tree->addField('perms_userid',1);
757 $tree->makeHTML=0;
758 $tree->setRecs = 1;
759
760 // Make tree:
761 $tree->getTree($id,$this->getLevels,'');
762
763 // If there are a hierarchy of page ids, then...
764 if ($GLOBALS['BE_USER']->user['uid'] && count($tree->orig_ids_hierarchy)) {
765
766 // Init:
767 $label_recur = $GLOBALS['LANG']->getLL('recursive');
768 $label_levels = $GLOBALS['LANG']->getLL('levels');
769 $label_pA = $GLOBALS['LANG']->getLL('pages_affected');
770 $theIdListArr=array();
771 $opts='
772 <option value=""></option>';
773
774 // Traverse the number of levels we want to allow recursive setting of permissions for:
775 for ($a=$this->getLevels;$a>0;$a--) {
776 if (is_array($tree->orig_ids_hierarchy[$a])) {
777 foreach($tree->orig_ids_hierarchy[$a] as $theId) {
778 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->user['uid']==$tree->recs[$theId]['perms_userid']) {
779 $theIdListArr[]=$theId;
780 }
781 }
782 $lKey = $this->getLevels-$a+1;
783 $opts.='
784 <option value="'.htmlspecialchars(implode(',',$theIdListArr)).'">'.
785 t3lib_div::deHSCentities(htmlspecialchars($label_recur.' '.$lKey.' '.$label_levels)).' ('.count($theIdListArr).' '.$label_pA.')'.
786 '</option>';
787 }
788 }
789
790 // Put the selector box together:
791 $theRecursiveSelect = '<br />
792 <select name="mirror[pages]['.$id.']">
793 '.$opts.'
794 </select>
795 <br /><br />';
796 } else {
797 $theRecursiveSelect = '';
798 }
799
800 // Return selector box element:
801 return $theRecursiveSelect;
802 }
803 }
804
805
806 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php'])) {
807 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php']);
808 }
809
810
811
812
813 // Make instance:
814 $SOBE = t3lib_div::makeInstance('SC_mod_web_perm_index');
815 $SOBE->init();
816 $SOBE->main();
817 $SOBE->printContent();
818
819 ?>