(bugfix) Fixed Image Generation bug. Call in t3lib_div now uses the IM wrapper to...
[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 if ($BE_USER->workspace!=0) {
325 // Adding section with the permission setting matrix:
326 $this->content.=$this->doc->divider(5);
327 $this->content.=$this->doc->section('WORKSPACE WARNING','<div style="border: solid 2px black; background-color: yellow; padding: 2px 2px 2px 2px;margin: 3px 0px 20px 0px;">Permissions you set in the workspace is effective on the elements only <em>after</em> they are published! If you need to set permissions which are effective right now, you must do so in the Live workspace. (Permissions are always evaluated on the Live workspace record/placeholder of a draft version)</div>',0,1,3);
328 }
329
330 // Get usernames and groupnames
331 $be_group_Array=t3lib_BEfunc::getListGroupNames('title,uid');
332 $groupArray=array_keys($be_group_Array);
333
334 $be_user_Array = t3lib_BEfunc::getUserNames();
335 if (!$GLOBALS['BE_USER']->isAdmin()) $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,1);
336 $be_group_Array_o = $be_group_Array = t3lib_BEfunc::getGroupNames();
337 if (!$GLOBALS['BE_USER']->isAdmin()) $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o,$groupArray,1);
338 $firstGroup = $groupArray[0] ? $be_group_Array[$groupArray[0]] : ''; // data of the first group, the user is member of
339
340
341 // Owner selector:
342 $options='';
343 $userset=0; // flag: is set if the page-userid equals one from the user-list
344 foreach($be_user_Array as $uid => $row) {
345 if ($uid==$this->pageinfo['perms_userid']) {
346 $userset = 1;
347 $selected=' selected="selected"';
348 } else {$selected='';}
349 $options.='
350 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['username']).'</option>';
351 }
352 $options='
353 <option value="0"></option>'.$options;
354 $selector='
355 <select name="data[pages]['.$this->id.'][perms_userid]">
356 '.$options.'
357 </select>';
358
359 $this->content.=$this->doc->section($LANG->getLL('Owner').':',$selector);
360
361
362 // Group selector:
363 $options='';
364 $userset=0;
365 foreach($be_group_Array as $uid => $row) {
366 if ($uid==$this->pageinfo['perms_groupid']) {
367 $userset = 1;
368 $selected=' selected="selected"';
369 } else {$selected='';}
370 $options.='
371 <option value="'.$uid.'"'.$selected.'>'.htmlspecialchars($row['title']).'</option>';
372 }
373 if (!$userset && $this->pageinfo['perms_groupid']) { // If the group was not set AND there is a group for the page
374 $options='
375 <option value="'.$this->pageinfo['perms_groupid'].'" selected="selected">'.
376 htmlspecialchars($be_group_Array_o[$this->pageinfo['perms_groupid']]['title']).
377 '</option>'.
378 $options;
379 }
380 $options='
381 <option value="0"></option>'.$options;
382 $selector='
383 <select name="data[pages]['.$this->id.'][perms_groupid]">
384 '.$options.'
385 </select>';
386
387 $this->content.=$this->doc->divider(5);
388 $this->content.=$this->doc->section($LANG->getLL('Group').':',$selector);
389
390 // Permissions checkbox matrix:
391 $code='
392 <table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix">
393 <tr>
394 <td></td>
395 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('1',1)).'</td>
396 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('16',1)).'</td>
397 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('2',1)).'</td>
398 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('4',1)).'</td>
399 <td class="bgColor2">'.str_replace(' ','<br />',$LANG->getLL('8',1)).'</td>
400 </tr>
401 <tr>
402 <td align="right" class="bgColor2">'.$LANG->getLL('Owner',1).'</td>
403 <td class="bgColor-20">'.$this->printCheckBox('perms_user',1).'</td>
404 <td class="bgColor-20">'.$this->printCheckBox('perms_user',5).'</td>
405 <td class="bgColor-20">'.$this->printCheckBox('perms_user',2).'</td>
406 <td class="bgColor-20">'.$this->printCheckBox('perms_user',3).'</td>
407 <td class="bgColor-20">'.$this->printCheckBox('perms_user',4).'</td>
408 </tr>
409 <tr>
410 <td align="right" class="bgColor2">'.$LANG->getLL('Group',1).'</td>
411 <td class="bgColor-20">'.$this->printCheckBox('perms_group',1).'</td>
412 <td class="bgColor-20">'.$this->printCheckBox('perms_group',5).'</td>
413 <td class="bgColor-20">'.$this->printCheckBox('perms_group',2).'</td>
414 <td class="bgColor-20">'.$this->printCheckBox('perms_group',3).'</td>
415 <td class="bgColor-20">'.$this->printCheckBox('perms_group',4).'</td>
416 </tr>
417 <tr>
418 <td align="right" class="bgColor2">'.$LANG->getLL('Everybody',1).'</td>
419 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',1).'</td>
420 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',5).'</td>
421 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',2).'</td>
422 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',3).'</td>
423 <td class="bgColor-20">'.$this->printCheckBox('perms_everybody',4).'</td>
424 </tr>
425 </table>
426 <br />
427
428 <input type="hidden" name="data[pages]['.$this->id.'][perms_user]" value="'.$this->pageinfo['perms_user'].'" />
429 <input type="hidden" name="data[pages]['.$this->id.'][perms_group]" value="'.$this->pageinfo['perms_group'].'" />
430 <input type="hidden" name="data[pages]['.$this->id.'][perms_everybody]" value="'.$this->pageinfo['perms_everybody'].'" />
431 '.$this->getRecursiveSelect($this->id,$this->perms_clause).'
432 <input type="submit" name="submit" value="'.$LANG->getLL('Save',1).'" />'.
433 '<input type="submit" value="'.$LANG->getLL('Abort',1).'" onclick="'.htmlspecialchars('jumpToUrl(\'index.php?id='.$this->id.'\'); return false;').'" />
434 <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).'" />
435 ';
436
437 // Adding section with the permission setting matrix:
438 $this->content.=$this->doc->divider(5);
439 $this->content.=$this->doc->section($LANG->getLL('permissions').':',$code);
440
441 // CSH for permissions setting
442 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'],'<br/><br/>');
443
444 // Adding help text:
445 if ($BE_USER->uc['helpText']) {
446 $this->content.=$this->doc->divider(20);
447 $legendText = '<b>'.$LANG->getLL('1',1).'</b>: '.$LANG->getLL('1_t',1);
448 $legendText.= '<br /><b>'.$LANG->getLL('16',1).'</b>: '.$LANG->getLL('16_t',1);
449 $legendText.= '<br /><b>'.$LANG->getLL('2',1).'</b>: '.$LANG->getLL('2_t',1);
450 $legendText.= '<br /><b>'.$LANG->getLL('4',1).'</b>: '.$LANG->getLL('4_t',1);
451 $legendText.= '<br /><b>'.$LANG->getLL('8',1).'</b>: '.$LANG->getLL('8_t',1);
452
453 $code=$legendText.'<br /><br />'.$LANG->getLL('def',1);
454 $this->content.=$this->doc->section($LANG->getLL('Legend',1).':',$code);
455 }
456 }
457
458 /**
459 * Showing the permissions in a tree ($this->edit = false)
460 * (Adding content to internal content variable)
461 *
462 * @return void
463 */
464 function notEdit() {
465 global $BE_USER,$LANG,$BACK_PATH;
466
467 // 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
468 $groupArray = $BE_USER->userGroupsUID;
469 $be_user_Array = t3lib_BEfunc::getUserNames();
470 if (!$GLOBALS['BE_USER']->isAdmin()) $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array,$groupArray,0);
471 $be_group_Array = t3lib_BEfunc::getGroupNames();
472 if (!$GLOBALS['BE_USER']->isAdmin()) $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array,$groupArray,0);
473
474 // Length of strings:
475 $tLen= ($this->MOD_SETTINGS['mode']=='perms' ? 20 : 30);
476
477
478 // Selector for depth:
479 $code.=$LANG->getLL('Depth').': ';
480 $code.=t3lib_BEfunc::getFuncMenu($this->id,'SET[depth]',$this->MOD_SETTINGS['depth'],$this->MOD_MENU['depth']);
481 $this->content.=$this->doc->section('',$code);
482 $this->content.=$this->doc->spacer(5);
483
484 // Initialize tree object:
485 $tree = t3lib_div::makeInstance('t3lib_pageTree');
486 $tree->init('AND '.$this->perms_clause);
487
488 $tree->addField('perms_user',1);
489 $tree->addField('perms_group',1);
490 $tree->addField('perms_everybody',1);
491 $tree->addField('perms_userid',1);
492 $tree->addField('perms_groupid',1);
493 $tree->addField('hidden');
494 $tree->addField('fe_group');
495 $tree->addField('starttime');
496 $tree->addField('endtime');
497 $tree->addField('editlock');
498
499 // Creating top icon; the current page
500 $HTML=t3lib_iconWorks::getIconImage('pages',$this->pageinfo,$BACK_PATH,'align="top"');
501 $tree->tree[]=Array('row'=>$this->pageinfo,'HTML'=>$HTML);
502
503 // Create the tree from $this->id:
504 $tree->getTree($this->id,$this->MOD_SETTINGS['depth'],'');
505
506 // Make header of table:
507 $code='';
508 if ($this->MOD_SETTINGS['mode']=='perms') {
509 $code.='
510 <tr>
511 <td class="bgColor2" colspan="2">&nbsp;</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('Owner',1).'</b></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"><b>'.$LANG->getLL('Group',1).'</b></td>
516 <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('Everybody',1).'</b></td>
518 <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
519 <td class="bgColor2" align="center"><b>'.$LANG->getLL('EditLock',1).'</b></td>
520 </tr>
521 ';
522 } else {
523 $code.='
524 <tr>
525 <td class="bgColor2" colspan="2">&nbsp;</td>
526 <td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
527 <td class="bgColor2" align="center" nowrap="nowrap"><b>'.$LANG->getLL('User',1).':</b> '.$BE_USER->user['username'].'</td>
528 '.(!$BE_USER->isAdmin()?'<td class="bgColor2"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
529 <td class="bgColor2" align="center"><b>'.$LANG->getLL('EditLock',1).'</b></td>':'').'
530 </tr>';
531 }
532
533 // Traverse tree:
534 foreach($tree->tree as $data) {
535 $cells = array();
536
537 // Background colors:
538 if ($this->lastEdited==$data['row']['uid']) {$bgCol = ' class="bgColor-20"';} else {$bgCol = '';}
539 $lE_bgCol = $bgCol;
540
541 // User/Group names:
542 $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>' : '');
543 $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>' : '');
544 $groupN = t3lib_div::fixed_lgd_cs($groupN,20);
545
546 // Seeing if editing of permissions are allowed for that page:
547 $editPermsAllowed=($data['row']['perms_userid']==$BE_USER->user['uid'] || $BE_USER->isAdmin());
548
549 // First column:
550 $cellAttrib = ($data['row']['_CSSCLASS'] ? ' class="'.$data['row']['_CSSCLASS'].'"' : '');
551 $cells[]='
552 <td align="left" nowrap="nowrap"'.($cellAttrib ? $cellAttrib : $bgCol).'>'.$data['HTML'].htmlspecialchars(t3lib_div::fixed_lgd($data['row']['title'],$tLen)).'&nbsp;</td>';
553
554 // "Edit permissions" -icon
555 if ($editPermsAllowed && $data['row']['uid']) {
556 $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';
557 $cells[]='
558 <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>';
559 } else {
560 $cells[]='
561 <td'.$bgCol.'></td>';
562 }
563
564 // Rest of columns (depending on mode)
565 if ($this->MOD_SETTINGS['mode']=='perms') {
566 $cells[]='
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_user']).' '.$userN:'').'</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']['uid']?$this->printPerms($data['row']['perms_group']).' '.$groupN:'').'</td>
572
573 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
574 <td'.$bgCol.' nowrap="nowrap">'.($data['row']['uid']?' '.$this->printPerms($data['row']['perms_everybody']):'').'</td>
575
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 } else {
580 $cells[]='
581 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>';
582
583 if ($BE_USER->user['uid']==$data['row']['perms_userid']) {$bgCol = ' class="bgColor-20"';} else {$bgCol = $lE_bgCol;}
584 // FIXME $owner undefined
585 $cells[]='
586 <td'.$bgCol.' nowrap="nowrap" align="center">'.($data['row']['uid']?$owner.$this->printPerms($BE_USER->calcPerms($data['row'])):'').'</td>
587 '.(!$BE_USER->isAdmin()?'
588 <td'.$bgCol.'><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/line.gif','width="5" height="16"').' alt="" /></td>
589 <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>
590 ':'');
591 $bgCol = $lE_bgCol;
592 }
593
594 // Compile table row:
595 $code.='
596 <tr>
597 '.implode('
598 ',$cells).'
599 </tr>';
600 }
601
602 // Wrap rows in table tags:
603 $code='<table border="0" cellspacing="0" cellpadding="0" id="typo3-permissionList">'.$code.'</table>';
604
605 // Adding the content as a section:
606 $this->content.=$this->doc->section('',$code);
607
608 // CSH for permissions setting
609 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module', $GLOBALS['BACK_PATH'],'<br/>|');
610
611 // Creating legend table:
612 $legendText = '<b>'.$LANG->getLL('1',1).'</b>: '.$LANG->getLL('1_t',1);
613 $legendText.= '<br /><b>'.$LANG->getLL('16',1).'</b>: '.$LANG->getLL('16_t',1);
614 $legendText.= '<br /><b>'.$LANG->getLL('2',1).'</b>: '.$LANG->getLL('2_t',1);
615 $legendText.= '<br /><b>'.$LANG->getLL('4',1).'</b>: '.$LANG->getLL('4_t',1);
616 $legendText.= '<br /><b>'.$LANG->getLL('8',1).'</b>: '.$LANG->getLL('8_t',1);
617
618 $code='<table border="0" id="typo3-legendTable">
619 <tr>
620 <td valign="top"><img src="legend.gif" width="86" height="75" alt="" /></td>
621 <td valign="top" nowrap="nowrap">'.$legendText.'</td>
622 </tr>
623 </table>';
624 $code.='<br />'.$LANG->getLL('def',1);
625 $code.='<br /><br /><span class="perm-allowed">*</span>: '.$LANG->getLL('A_Granted',1);
626 $code.='<br /><span class="perm-denied">x</span>: '.$LANG->getLL('A_Denied',1);
627
628 // Adding section with legend code:
629 $this->content.=$this->doc->spacer(20);
630 $this->content.=$this->doc->section($LANG->getLL('Legend').':',$code,0,1);
631 }
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646 /*****************************
647 *
648 * Helper functions
649 *
650 *****************************/
651
652 /**
653 * Print a checkbox for the edit-permission form
654 *
655 * @param string Checkbox name key
656 * @param integer Checkbox number index
657 * @return string HTML checkbox
658 */
659 function printCheckBox($checkName,$num) {
660 $onClick = 'checkChange(\'check['.$checkName.']\', \'data[pages]['.$GLOBALS['SOBE']->id.']['.$checkName.']\')';
661 return '<input type="checkbox" name="check['.$checkName.']['.$num.']" onclick="'.htmlspecialchars($onClick).'" /><br />';
662 }
663
664 /**
665 * Print a set of permissions
666 *
667 * @param integer Permission integer (bits)
668 * @return string HTML marked up x/* indications.
669 */
670 function printPerms($int) {
671 $str='';
672 $str.= (($int&1)?'*':'<span class="perm-denied">x</span>');
673 $str.= (($int&16)?'*':'<span class="perm-denied">x</span>');
674 $str.= (($int&2)?'*':'<span class="perm-denied">x</span>');
675 $str.= (($int&4)?'*':'<span class="perm-denied">x</span>');
676 $str.= (($int&8)?'*':'<span class="perm-denied">x</span>');
677
678 return '<span class="perm-allowed">'.$str.'</span>';
679 }
680
681 /**
682 * 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
683 *
684 * @param array Row array (from pages table)
685 * @param array First group data
686 * @return integer Integer: Combined permissions.
687 */
688 function groupPerms($row,$firstGroup) {
689 if (is_array($row)) {
690 $out=intval($row['perms_everybody']);
691 if ($row['perms_groupid'] && $firstGroup['uid']==$row['perms_groupid']) {
692 $out|= intval($row['perms_group']);
693 }
694 return $out;
695 }
696 }
697
698 /**
699 * Finding tree and offer setting of values recursively.
700 *
701 * @param integer Page id.
702 * @param string Select clause
703 * @return string Select form element for recursive levels (if any levels are found)
704 */
705 function getRecursiveSelect($id,$perms_clause) {
706
707 // Initialize tree object:
708 $tree = t3lib_div::makeInstance('t3lib_pageTree');
709 $tree->init('AND '.$perms_clause);
710 $tree->addField('perms_userid',1);
711 $tree->makeHTML=0;
712 $tree->setRecs = 1;
713
714 // Make tree:
715 $tree->getTree($id,$this->getLevels,'');
716
717 // If there are a hierarchy of page ids, then...
718 if ($GLOBALS['BE_USER']->user['uid'] && count($tree->orig_ids_hierarchy)) {
719
720 // Init:
721 $label_recur = $GLOBALS['LANG']->getLL('recursive');
722 $label_levels = $GLOBALS['LANG']->getLL('levels');
723 $label_pA = $GLOBALS['LANG']->getLL('pages_affected');
724 $theIdListArr=array();
725 $opts='
726 <option value=""></option>';
727
728 // Traverse the number of levels we want to allow recursive setting of permissions for:
729 for ($a=$this->getLevels;$a>0;$a--) {
730 if (is_array($tree->orig_ids_hierarchy[$a])) {
731 foreach($tree->orig_ids_hierarchy[$a] as $theId) {
732 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->user['uid']==$tree->recs[$theId]['perms_userid']) {
733 $theIdListArr[]=$theId;
734 }
735 }
736 $lKey = $this->getLevels-$a+1;
737 $opts.='
738 <option value="'.htmlspecialchars(implode(',',$theIdListArr)).'">'.
739 t3lib_div::deHSCentities(htmlspecialchars($label_recur.' '.$lKey.' '.$label_levels)).' ('.count($theIdListArr).' '.$label_pA.')'.
740 '</option>';
741 }
742 }
743
744 // Put the selector box together:
745 $theRecursiveSelect = '<br />
746 <select name="mirror[pages]['.$id.']">
747 '.$opts.'
748 </select>
749
750 <br /><br />';
751 } else {
752 $theRecursiveSelect = '';
753 }
754
755 // Return selector box element:
756 return $theRecursiveSelect;
757 }
758 }
759
760 // Include extension?
761 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php']) {
762 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/web/perm/index.php']);
763 }
764
765
766
767
768
769
770
771
772
773
774
775
776 // Make instance:
777 $SOBE = t3lib_div::makeInstance('SC_mod_web_perm_index');
778 $SOBE->init();
779 $SOBE->main();
780 $SOBE->printContent();
781
782 if ($TYPO3_CONF_VARS['BE']['compressionLevel']) {
783 new gzip_encode($TYPO3_CONF_VARS['BE']['compressionLevel']);
784 }
785 ?>