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