File modules/cms/action/pageelement/PageelementValueAction.class.php

Last commit: Sat Dec 4 00:18:39 2021 +0100	dankert	Some security enhancements.
1 <?php 2 namespace cms\action\pageelement; 3 use cms\action\Method; 4 use cms\action\PageelementAction; 5 use cms\base\Startup; 6 use cms\model\PageContent; 7 use cms\model\Permission; 8 use cms\model\Page; 9 10 class PageelementValueAction extends PageelementAction implements Method { 11 12 public function view() { 13 14 $this->element->load(); 15 $this->pageContent->load(); 16 17 $this->value->contentid = $this->pageContent->contentId; 18 19 $valueId =$this->request->getNumber('valueid'); 20 21 if ( $valueId ) { 22 $this->ensureValueIdIsInAnyContent( $valueId ); 23 24 $this->value->valueid = $valueId; 25 $this->value->loadWithId(); 26 } 27 else { 28 $this->value->load(); 29 } 30 31 $this->setTemplateVar('name' ,$this->element->name ); 32 $this->setTemplateVar('desc' ,$this->element->desc ); 33 $this->setTemplateVar('elementid' ,$this->element->elementid); 34 $this->setTemplateVar('languageid',$this->pageContent->languageid ); 35 $this->setTemplateVar('type' ,$this->element->getTypeName() ); 36 $this->setTemplateVar('value_time',Startup::getStartTime() ); 37 38 $this->setTemplateVar( 'objectid' ,$this->page->objectid ); 39 40 if ( $this->page->hasRight(Permission::ACL_RELEASE) ) 41 $this->setTemplateVar( 'release',true ); 42 43 if ( $this->page->hasRight(Permission::ACL_PUBLISH) ) 44 $this->setTemplateVar( 'publish',false ); 45 46 $methodName = 'edit'.ucfirst($this->element->getTypeName()); 47 48 if ( ! method_exists($this,$methodName) ) 49 throw new \LogicException('Method does not exist: PageElementAction#'.$methodName ); 50 51 $this->$methodName(); // Call method "edit<Elementtyp>()". 52 } 53 54 55 public function post() { 56 57 $this->element->load(); 58 59 $type = $this->element->getTypeName(); 60 61 $methodName = 'save'.ucfirst($type); 62 63 if ( !method_exists($this,$methodName)) 64 throw new \InvalidArgumentException('Method not available: '.$methodName); 65 66 $this->$methodName(); // Call method "save<ElementType>()" 67 } 68 }
Download modules/cms/action/pageelement/PageelementValueAction.class.php
History Sat, 4 Dec 2021 00:18:39 +0100 dankert Some security enhancements. Sat, 27 Nov 2021 23:31:32 +0100 Jan Dankert Fix: Saving values for unauthenticated users. Sat, 27 Nov 2021 01:52:24 +0100 Jan Dankert New: Releasing and Restoring for file and template values. Tue, 9 Nov 2021 00:35:42 +0100 Jan Dankert Fixes: Reading and writing template sources with the new content table. Sat, 6 Mar 2021 03:42:38 +0100 Jan Dankert New: Better permission checks. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Thu, 25 Feb 2021 01:22:10 +0100 Jan Dankert New: Edit all page elements in 1 view. Mon, 4 Jan 2021 19:03:18 +0100 Jan Dankert Refactoring: ACL class is renamed to Permission, because most RBAC/DMAC concepts are calling it a permission. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.