/** * Action zum Editieren einer Person, die mit einem Dokument verknüpft ist. * * Wird über den Edit-Link für eine Person im Metadatenformular eines Dokuments aufgerufen. */ public function editlinkedAction() { $docId = $this->getRequest()->getParam('document'); $document = $this->__documentsHelper->getDocumentForId($docId); if (!isset($document)) { return $this->_redirectTo('index', array('failure' => 'admin_document_error_novalidid'), 'documents', 'admin'); } $form = new Admin_Form_Person(); if (!$this->getRequest()->isPost()) { // Formular anzeigen $personId = $this->getRequest()->getParam('personId'); if (strlen(trim($personId)) == 0 || is_null($personId)) { $this->getLogger()->err(__METHOD__ . ' No personId parameter.'); return $this->returnToMetadataForm($docId); } if (!is_numeric($personId)) { $this->getLogger()->err(__METHOD__ . " Bad personId = '{$personId}' parameter."); return $this->returnToMetadataForm($docId); } try { $person = new Opus_Person($personId); } catch (Opus_Model_NotFoundException $omnfe) { $this->getLogger()->err(__METHOD__ . ' ' . $omnfe->getMessage()); return $this->returnToMetadataForm($docId); } $form->populateFromModel($person); $this->view->form = $form; } else { // POST verarbeiten $post = $this->getRequest()->getPost(); $form->populate($post); $result = $form->processPost($post, $post); switch ($result) { case Admin_Form_Person::RESULT_SAVE: if ($form->isValid($post)) { $person = $form->getModel(); $person->store(); return $this->_redirectToAndExit('edit', null, 'document', 'admin', array('id' => $docId, 'continue' => 'updateperson', 'person' => $person->getId())); } else { // TODO Validierungsfehlernachricht für Formular anzeigen (notwendig?) } break; case Admin_Form_Person::RESULT_CANCEL: // Person nicht speichern return $this->returnToMetadataForm($docId); break; default: break; } $this->view->form = $form; } $this->view->document = $document; $this->view->documentAdapter = new Util_DocumentAdapter($this->view, $document); // Beim wechseln der Sprache würden Änderungen in editierten Felder verloren gehen $this->view->languageSelectorDisabled = true; $this->view->breadcrumbsDisabled = true; }