File modules/cms/action/TemplateAction.class.php
Last commit: Sat Nov 27 01:52:24 2021 +0100 Jan Dankert New: Releasing and Restoring for file and template values.
1 <?php 2 3 namespace cms\action; 4 5 namespace cms\action; 6 use cms\model\Content; 7 use cms\model\Folder; 8 use cms\model\Permission; 9 use cms\model\Element; 10 use cms\model\Page; 11 use cms\model\Project; 12 use cms\model\Template; 13 use cms\model\TemplateModel; 14 use cms\model\Value; 15 use language\Messages; 16 use util\exception\SecurityException; 17 use util\exception\ValidationException; 18 use util\Html; 19 use util\Session; 20 21 22 // OpenRat Content Management System 23 // Copyright (C) 2002-2009 Jan Dankert 24 // 25 // This program is free software; you can redistribute it and/or 26 // modify it under the terms of the GNU General Public License 27 // as published by the Free Software Foundation; either version 2 28 // of the License, or (at your option) any later version. 29 // 30 // This program is distributed in the hope that it will be useful, 31 // but WITHOUT ANY WARRANTY; without even the implied warranty of 32 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 // GNU General Public License for more details. 34 // 35 // You should have received a copy of the GNU General Public License 36 // along with this program; if not, write to the Free Software 37 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 38 39 /** 40 * Action-Klasse zum Bearbeiten einer Seitenvorlage. 41 * 42 * @author Jan Dankert 43 * @package openrat.actions 44 */ 45 46 class TemplateAction extends BaseAction 47 { 48 /** 49 * @var Template 50 */ 51 protected $template; 52 private $element; 53 54 55 function __construct() 56 { 57 parent::__construct(); 58 59 } 60 61 62 public function init() 63 { 64 $this->template = new Template( $this->request->getId() ); 65 66 $this->template->load(); 67 68 $this->setTemplateVar( 'templateid',$this->template->templateid ); 69 70 if ( intval($this->request->getText('elementid')) != 0 ) 71 { 72 $this->element = new Element( $this->request->getText('elementid') ); 73 $this->element->load(); 74 $this->setTemplateVar( 'elementid',$this->element->elementid ); 75 } 76 } 77 78 79 80 81 /** 82 * User must be an project administrator. 83 */ 84 public function checkAccess() { 85 $project = new Project( $this->template->projectid ); 86 $rootFolderId = $project->getRootObjectId(); 87 88 $rootFolder = new Folder( $rootFolderId ); 89 $rootFolder->load(); 90 91 if ( ! $rootFolder->hasRight( Permission::ACL_PROP ) ) 92 throw new SecurityException(); 93 } 94 95 96 protected function getTemplateModels() 97 { 98 $project = new Project($this->template->projectid); 99 $versions = []; 100 101 $templatemodels = []; 102 foreach ($project->getModels() as $modelId => $modelName) { 103 $templatemodels[] = new TemplateModel($this->template->templateid, $modelId); 104 } 105 106 return $templatemodels; 107 } 108 109 110 111 protected function ensureValueIdIsInAnyTemplate( $valueId ) { 112 113 $versions = []; 114 115 foreach( $this->getTemplateModels() as $templateModel ) 116 { 117 $templateModel->load(); 118 119 $content = new Content( $templateModel->getContentid() ); 120 121 $versions = array_merge( $versions, $content->getVersionList() ); 122 } 123 124 if ( ! in_array( $valueId, $versions )) 125 throw new SecurityException( 'value-id is not contained in the version list of this file' ); 126 } 127 }
Downloadmodules/cms/action/TemplateAction.class.php
History Sat, 27 Nov 2021 01:52:24 +0100 Jan Dankert New: Releasing and Restoring for file and template values. 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. 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. 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. Wed, 11 Nov 2020 23:24:28 +0100 Jan Dankert Fixing editing value of files,images,texts. Wed, 11 Nov 2020 21:47:40 +0100 Jan Dankert Fix: Templatemodel-extensions are now editable. 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 04:03:53 +0200 Jan Dankert Refactoring: read language keys with a class. Wed, 23 Sep 2020 01:04:05 +0200 Jan Dankert Cleanup of deprecated methods and deprecated class attributes. Fri, 18 Sep 2020 23:04:13 +0200 Jan Dankert Refactoring: Renaming module "cms/publish" to "cms/generator" Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.