openrat-cms

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

FileRestoreAction.class.php (1159B)


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