/** * stores a delivered form as document in the database * uses check_array */ public function depositAction() { if ($this->getRequest()->isPost() !== true) { return $this->_redirectTo('index', '', 'index'); } //post content is just checked for buttons $post = $this->getRequest()->getPost(); if (array_key_exists('back', $post)) { return $this->_forward('check', 'form'); } if (array_key_exists('abort', $post)) { if (isset($this->session->documentId)) { try { $document = new Opus_Document($this->session->documentId); $document->deletePermanent(); } catch (Opus_Model_Exception $e) { $this->_logger->err("deletion of document # " . $this->session->documentId . " was not successful", $e); } } return $this->_redirectTo('index', '', 'index'); } $this->view->title = 'publish_controller_index'; $this->view->subtitle = $this->view->translate('publish_controller_deposit_successful'); //deposit data is coming from the session if (isset($this->session->elements)) { foreach ($this->session->elements as $element) { $this->depositData[$element['name']] = array('value' => $element['value'], 'datatype' => $element['datatype'], 'subfield' => $element['subfield']); $this->log->debug("STORE DATA: " . $element['name'] . ": " . $element['value'] . ", Typ:" . $element['datatype'] . ", Sub:" . $element['subfield']); } } if (isset($this->depositData['send'])) { unset($this->depositData['send']); } try { $depositData = new Publish_Model_Deposit($this->session->documentId, $this->log, $this->depositData); } catch (Publish_Model_Exception $e) { throw new Application_Exception('publish_error_unexpected'); } $this->document = $depositData->getDocument(); $this->document->setServerState('unpublished'); try { $docId = $this->document->store(); } catch (Exception $e) { // TODO wie sollte die Exception sinnvoll behandelt werden? $this->log->err("Document could not be stored successfully: " . $e->getMessage()); throw new Application_Exception('publish_error_unexpected'); } $this->log->info("Document {$docId} was successfully stored!"); $this->session->documentId = $docId; // Prepare redirect to confirmation action. $this->session->depositConfirmDocumentId = $docId; $targetAction = 'confirm'; $targetController = 'deposit'; $targetModule = 'publish'; $config = Zend_Registry::get('Zend_Config'); if (isset($config) and isset($config->publish->depositComplete)) { $targetAction = $config->publish->depositComplete->action; $targetController = $config->publish->depositComplete->controller; $targetModule = $config->publish->depositComplete->module; } $notification = new Util_Notification($this->log, $config); $url = $this->view->url(array("module" => "admin", "controller" => "document", "action" => "index", "id" => $this->document->getId()), null, true); $notification->prepareMail($this->document, Util_Notification::SUBMISSION, $this->view->serverUrl() . $url); return $this->_redirectToAndExit($targetAction, null, $targetController, $targetModule); }
private function _sendNotification($document, $form = null) { $notification = new Util_Notification(); $url = $this->view->url(array("module" => "frontdoor", "controller" => "index", "action" => "index", "docId" => $document->getId()), null, true); $authorsBitmask = array(); $notifySubmitter = true; if (!is_null($form)) { foreach ($form->getValues() as $key => $val) { $pos = strpos($key, 'author_'); if ($pos !== false && $pos === 0) { array_push($authorsBitmask, $val == '1'); } } $notifySubmitter = $form->getValue('submitter') == '1'; } $notification->prepareMail($document, Util_Notification::PUBLICATION, $this->view->serverUrl() . $url, $notifySubmitter, $authorsBitmask); }