File modules/cms/action/ElementAction.class.php

Last commit: Sun Mar 14 22:29:56 2021 +0100	Jan Dankert	Refactoring: Clearer access check.
1 <?php 2 3 namespace cms\action; 4 5 6 use cms\base\Configuration; 7 use cms\model\BaseObject; 8 use cms\model\Element; 9 use cms\model\Folder; 10 use cms\model\Permission; 11 use cms\model\Project; 12 use cms\model\Template; 13 use ReflectionClass; 14 use ReflectionProperty; 15 use util\exception\SecurityException; 16 use util\Text; 17 18 19 /** 20 * Action-Klasse fuer die Bearbeitung eines Template-Elementes. 21 * 22 * @author Jan Dankert 23 */ 24 class ElementAction extends BaseAction 25 { 26 /** 27 * @var Element 28 */ 29 protected $element; 30 31 private $template; 32 33 /** 34 * Konstruktor 35 */ 36 function __construct() 37 { 38 parent::__construct(); 39 40 } 41 42 43 public function init() 44 { 45 if ( $this->request->getId() == 0 ) 46 throw new \util\exception\ValidationException('no element-id available'); 47 48 $this->element = new Element( $this->request->getId() ); 49 $this->element->load(); 50 51 $this->setTemplateVar( 'elementid' ,$this->element->elementid ); 52 } 53 54 55 /** 56 * User must be an project administrator. 57 */ 58 public function checkAccess() { 59 $template = new Template( $this->element->templateid ); 60 $template->load(); 61 $project = new Project( $template->projectid ); 62 $rootFolderId = $project->getRootObjectId(); 63 64 $rootFolder = new Folder( $rootFolderId ); 65 $rootFolder->load(); 66 67 if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) 68 throw new SecurityException(); 69 } 70 71 } 72
Download modules/cms/action/ElementAction.class.php
History Sun, 14 Mar 2021 22:29:56 +0100 Jan Dankert Refactoring: Clearer access check. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Wed, 18 Nov 2020 00:18:10 +0100 Jan Dankert Refactoring Part 2: Removing all unnecessary methods in the action base classes. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class. Sun, 1 Nov 2020 00:36:50 +0100 Jan Dankert Refactoring: Only using the configuration object. Wed, 7 Oct 2020 23:28:20 +0200 Jan Dankert Fix: Langauge keys must not contain the '-'. Wed, 7 Oct 2020 23:01:31 +0200 Jan Dankert Cleanup: Refactored file seperator char with an unicode char. Fri, 2 Oct 2020 23:11:48 +0200 Jan Dankert Cleanup: No '.inputholder' any more, notices with links to objects. Tue, 29 Sep 2020 22:17:11 +0200 Jan Dankert Refactoring: Do not use global constants. Sat, 26 Sep 2020 12:20:43 +0200 Jan Dankert Refactoring: No global variables like $SESS any more. All constants are capsulated by classes. Sat, 26 Sep 2020 10:32:02 +0200 Jan Dankert Refactoring: No global $conf array any more. Sat, 26 Sep 2020 04:26:55 +0200 Jan Dankert Refactoring: read configuration values with a class. Sat, 26 Sep 2020 04:03:53 +0200 Jan Dankert Refactoring: read language keys with a class. Sat, 28 Mar 2020 00:43:25 +0100 Jan Dankert Fix: File path to macros. Sun, 23 Feb 2020 04:49:34 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 2. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.