示例#1
0
 public function testContinueEditAddTwoPersons()
 {
     $form = new Admin_Form_Document_Persons();
     $request = $this->getRequest();
     $request->setParams(array('continue' => 'addperson'));
     $session = new Admin_Model_DocumentEditSession(100);
     $session->addPerson(array('person' => 310, 'role' => 'author'));
     $session->addPerson(array('person' => 311, 'role' => 'editor'));
     $this->assertEquals(0, count($form->getSubForm('author')->getSubForms()));
     $this->assertEquals(0, count($form->getSubForm('editor')->getSubForms()));
     $form->continueEdit($request, $session);
     $this->assertEquals(1, count($form->getSubForm('author')->getSubForms()));
     $this->assertEquals(1, count($form->getSubForm('editor')->getSubForms()));
     $author = $form->getSubForm('author')->getSubForm('PersonAuthor0');
     $this->assertNotNull($author);
     $this->assertEquals(310, $author->getElementValue('PersonId'));
     $editor = $form->getSubForm('editor')->getSubForm('PersonEditor0');
     $this->assertNotNull($editor);
     $this->assertEquals(311, $editor->getElementValue('PersonId'));
 }
 public function testEditTwoDocuments()
 {
     $model1 = new Admin_Model_DocumentEditSession(146);
     $model2 = new Admin_Model_DocumentEditSession(100);
     $namespace1 = $model1->getDocumentSessionNamespace();
     $namespace2 = $model2->getDocumentSessionNamespace();
     $this->assertNotEquals($namespace1, $namespace2);
     $model1->addPerson(array('person' => 310));
     $this->assertEquals(1, $model1->getPersonCount());
     $this->assertEquals(0, $model2->getPersonCount());
 }
示例#3
0
 /**
  * Fuegt Person zu Dokument hinzu.
  * 
  * HTTP Parameter:
  * - Dokument-ID (document)
  * - Rolle (role)
  */
 public function assignAction()
 {
     $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');
     }
     if (!$this->getRequest()->isPost()) {
         // Neues Formular anzeigen
         $form = new Admin_Form_Document_PersonAdd();
         $role = $this->getRequest()->getParam('role', 'author');
         $form->setSelectedRole($role);
         $this->view->form = $form;
     } else {
         // POST verarbeiten
         $post = $this->getRequest()->getPost();
         $form = new Admin_Form_Document_PersonAdd();
         $form->populate($post);
         $result = $form->processPost($post, $post);
         switch ($result) {
             case Admin_Form_Document_PersonAdd::RESULT_SAVE:
             case Admin_Form_Document_PersonAdd::RESULT_NEXT:
                 if ($form->isValid($post)) {
                     $person = $form->getModel();
                     $person->store();
                     $linkProps = $form->getPersonLinkProperties($person->getId());
                     $editSession = new Admin_Model_DocumentEditSession($docId);
                     if ($result == Admin_Form_Document_PersonAdd::RESULT_SAVE) {
                         // Zurück zum Metadaten-Formular springen
                         if ($editSession->getPersonCount() > 0) {
                             // Link Informationen durch Session übermitteln
                             $editSession->addPerson($linkProps);
                             return $this->_redirectToAndExit('edit', null, 'document', 'admin', array('id' => $docId, 'continue' => 'addperson'));
                         } else {
                             // Link Informationen direkt als Parameter übergeben
                             return $this->_redirectToAndExit('edit', null, 'document', 'admin', array_merge(array('id' => $docId, 'continue' => 'addperson'), $linkProps));
                         }
                     } else {
                         // Person in Session merken
                         $editSession->addPerson($linkProps);
                         // Neues Formular erzeugen
                         $role = $form->getSelectedRole();
                         $form = new Admin_Form_Document_PersonAdd();
                         $form->setSelectedRole($role);
                     }
                 } else {
                     // TODO Validierungsfehlernachricht für Formular anzeigen
                     $form->addError($this->view->translate('admin_document_error_validation'));
                 }
                 break;
             case Admin_Form_Document_PersonAdd::RESULT_CANCEL:
                 // Aktuelle Person nicht speichern, aber eventuell gemerkte Personen hinzufügen
                 return $this->_redirectToAndExit('edit', null, 'document', 'admin', array('id' => $docId, 'continue' => 'addperson'));
             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;
 }