File modules/cms/action/object/ObjectPropAction.class.php

Last commit: Wed Mar 9 13:28:52 2022 +0100	dankert	Refactoring: Checkbox values are always sent to the server. In the actions we must test the value with 'isTrue()'
1 <?php 2 namespace cms\action\object; 3 use cms\action\Method; 4 use cms\action\ObjectAction; 5 use cms\action\RequestParams; 6 use cms\model\BaseObject; 7 use cms\model\Permission; 8 use cms\model\Project; 9 use language\Messages; 10 use util\exception\ValidationException; 11 12 13 class ObjectPropAction extends ObjectAction implements Method { 14 15 public function getRequiredPermission() 16 { 17 return Permission::ACL_PROP; 18 } 19 20 public function view() { 21 $this->setTemplateVar( 'filename', $this->baseObject->filename ); 22 $alias = $this->baseObject->getAliasForLanguage(null ); 23 $this->setTemplateVar( 'alias_filename', $alias->filename ); 24 $this->setTemplateVar( 'alias_folderid', $alias->parentid ); 25 26 $project = Project::create( $this->baseObject->projectid ); 27 $this->setTemplateVar( 'folders' , $project->getAllFlatFolders() ); 28 } 29 30 31 public function post() { 32 33 $this->baseObject->filename = BaseObject::urlify( $this->request->getRequiredText('filename') ); 34 $this->baseObject->save(); 35 36 $alias = $this->baseObject->getAliasForLanguage(null); 37 $alias->filename = BaseObject::urlify( $this->request->getText( 'alias_filename') ); 38 $alias->parentid = $this->request->getNumber('alias_folderid'); 39 40 // If no alias, remove the alias 41 if ( ! $alias->filename ) 42 $alias->delete(); 43 else 44 $alias->persist(); 45 46 47 // Should we do this? 48 if ( $this->userIsAdmin() ) 49 $this->request->handleNumber('creationTimestamp',function($value) { 50 $this->baseObject->createDate = $value; 51 $this->baseObject->setCreationTimestamp(); 52 }); 53 54 55 $this->addNoticeFor( $this->baseObject,Messages::PROP_SAVED); 56 } 57 }
Download modules/cms/action/object/ObjectPropAction.class.php
History Wed, 9 Mar 2022 13:28:52 +0100 dankert Refactoring: Checkbox values are always sent to the server. In the actions we must test the value with 'isTrue()' Wed, 10 Mar 2021 23:51:22 +0100 Jan Dankert Refactoring: Cleaned the Request params. 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, 19 Nov 2020 14:49:58 +0100 Jan Dankert Fix: Action::addNotice() is replaced by Action::addNoticeFor() Wed, 18 Nov 2020 01:46:36 +0100 Jan Dankert Refactoring of model classes: New method persist() and some other cleanups. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.