Example #1
0
 public function deleteAction()
 {
     $request = $this->getRequest();
     $docId = $this->getRequest()->getParam(self::PARAM_DOCUMENT_ID);
     $document = $this->getHelper('documents')->getDocumentForId($docId);
     if (!isset($document)) {
         // missing or bad parameter => go back to main page
         return $this->_redirectTo('index', array('failure' => 'admin_document_error_novalidid'), 'documents', 'admin');
     }
     $fileId = $this->getRequest()->getParam(self::PARAM_FILE_ID);
     $fileHelper = new Admin_Model_FileImport();
     if (!$fileHelper->isValidFileId($fileId)) {
         return $this->_redirectTo('index', array('failure' => 'admin_filemanager_error_novalidid'), 'filemanager', 'admin', array(self::PARAM_DOCUMENT_ID => $docId));
     }
     if (!$fileHelper->isFileBelongsToDocument($docId, $fileId)) {
         return $this->_redirectTo('index', array('failure' => 'admin_filemanager_error_filenotlinkedtodoc'), 'filemanager', 'admin', array(self::PARAM_DOCUMENT_ID => $docId));
     }
     $form = new Application_Form_Confirmation('Opus_File');
     if ($request->isPost()) {
         $post = $request->getPost();
         if ($form->isConfirmed($post)) {
             // Delete file
             $fileId = $form->getModelId();
             try {
                 $fileHelper->deleteFile($docId, $fileId);
             } catch (Opus_Model_Exception $ome) {
                 $this->getLogger()->err(__METHOD__ . ' Error deleting file. (' . $ome->getMessage . ')');
                 return $this->_redirectTo('index', array('failure' => 'admin_filemanager_delete_failure'), 'filemanager', 'admin', array(self::PARAM_DOCUMENT_ID => $docId, 'continue' => 'true'));
             }
             return $this->_redirectTo('index', 'admin_filemanager_delete_success', 'filemanager', 'admin', array(self::PARAM_DOCUMENT_ID => $docId, 'continue' => 'true', self::PARAM_FILE_ID => $fileId));
         } else {
             // Delete cancelled
             return $this->_redirectTo('index', null, 'filemanager', 'admin', array(self::PARAM_DOCUMENT_ID => $docId, 'continue' => 'true'));
         }
     } else {
         // Show confirmation page
         $file = new Opus_File($fileId);
         $form->setModel($file);
         $form->setModelDisplayName($file->getPathName());
     }
     $this->_breadcrumbs->setDocumentBreadcrumb($document);
     $this->_breadcrumbs->setParameters('admin_filemanager_index', array(self::PARAM_DOCUMENT_ID => $docId));
     $this->renderForm($form);
 }
Example #2
0
 /**
  * Erzeugt ein Bestätigunsformular für ein Model.
  *
  * Das Bestätigunsformular ohne Model wird für die Validierung verwendet.
  *
  * @param Opus_Model_AbstractDb $model
  * @return Application_Form_Confirmation
  */
 public function getConfirmationForm($model = null)
 {
     $form = new Application_Form_Confirmation($this->getModelClass());
     if (!$this->getVerifyModelIdIsNumeric()) {
         $form->getElement(Application_Form_Confirmation::ELEMENT_MODEL_ID)->removeValidator('int');
     }
     if (!is_null($model)) {
         $form->setModel($model);
     }
     return $form;
 }
 public function testSetQuestion()
 {
     $form = new Application_Form_Confirmation('Opus_Licence');
     $form->setQuestion('Wollen Sie wirklich das Internet löschen?');
     $this->assertEquals('Wollen Sie wirklich das Internet löschen?', $form->getQuestion());
 }
Example #4
0
 /**
  * Erzeugt ein Bestätigunsformular für ein Model.
  *
  * Das Bestätigunsformular ohne Model wird für die Validierung verwendet.
  *
  * @param Opus_Model_AbstractDb $model
  * @return Application_Form_Confirmation
  */
 public function getConfirmationForm($model = null)
 {
     $form = new Application_Form_Confirmation($this->getModelClass());
     if (!is_null($model)) {
         $form->setModel($model);
     }
     return $form;
 }