ElementAction.class.php (1378B)
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