openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

FileReleaseAction.class.php (1104B)


      1 <?php
      2 namespace cms\action\file;
      3 use cms\action\ContentAction;
      4 use cms\action\FileAction;
      5 use cms\action\Method;
      6 use cms\action\PageelementAction;
      7 use cms\model\Content;
      8 use cms\model\Permission;
      9 use cms\model\Value;
     10 use language\Messages;
     11 use LogicException;
     12 use util\exception\SecurityException;
     13 
     14 class FileReleaseAction extends FileAction implements Method {
     15 
     16 	public function getRequiredPermission()
     17 	{
     18 		return Permission::ACL_RELEASE;
     19 	}
     20 
     21 	public function view() {
     22     }
     23 
     24     public function post() {
     25 
     26 		$content = new Content( $this->file->contentid );
     27 		$versionList = $content->getVersionList();
     28 
     29 		$value = new Value();
     30 		$value->valueid = $this->request->getRequiredNumber('valueid');
     31 
     32 		if   ( ! in_array( $value->valueid, $versionList ))
     33 			throw new SecurityException( 'value-id is not contained in the version list of this file' );
     34 
     35 		$value->loadWithId( $value->valueid );
     36 
     37 		// Inhalt wieder herstellen, in dem er neu gespeichert wird.
     38 		$value->valueid = null;
     39 		$value->publish = true;
     40 		$value->persist();
     41 
     42 		$this->addNoticeFor( $this->file,Messages::PAGEELEMENT_RELEASED );
     43     }
     44 }