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