예제 #1
0
 /** Action for editing findspots
  * @access public
  * @return void
  * @throws Exception
  */
 public function editAction()
 {
     if ($this->getParam('id', false)) {
         $form = new FindSpotForm();
         $form->submit->setLabel('Update find spot');
         $this->view->form = $form;
         $returnID = (int) $this->_findspots->getFindNumber($this->getParam('id'), $this->getParam('recordtype'));
         $this->view->returnID = $returnID;
         //Check if POST
         if ($this->getRequest()->isPost()) {
             // Check if valid
             if ($form->isValid($this->_request->getPost())) {
                 $updateData = $form->getValues();
                 $oldData = $this->_findspots->fetchRow('id=' . $this->getParam('id'))->toArray();
                 $where = array();
                 $where[] = $this->_findspots->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
                 $insertData = $this->_findspots->updateAndProcess($updateData);
                 $this->_findspots->update($insertData, $where);
                 $returnID = (int) $this->_findspots->getFindNumber($this->getParam('id'), $this->getController());
                 $this->_helper->audit($insertData, $oldData, 'FindspotsAudit', $this->getParam('id'), $returnID);
                 $this->_helper->solrUpdater->update('objects', $returnID, $this->getParam('recordtype'));
                 $this->getFlash()->addMessage('Findspot updated!');
                 $this->redirect($this->getRedirect() . 'record/id/' . $returnID);
             } else {
                 // If error fill with posted values
                 $where[] = $this->_findspots->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
                 $findSpot = $this->_findspots->fetchRow($where);
                 $this->view->findspot = $findSpot;
                 $form->populate($this->_request->getPost());
                 $this->_helper->findspotFailedOptions($this->_request->getPost());
             }
         } else {
             // As GET, refill from db
             $where = array();
             $where[] = $this->_findspots->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
             $findSpot = $this->_findspots->fetchRow($where);
             if (!is_null($findSpot)) {
                 $this->view->findspot = $findSpot;
                 $fill = new Pas_Form_Findspot();
                 $fill->populate($findSpot->toArray());
             } else {
                 throw new Pas_Exception('No row found in database', 500);
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }
예제 #2
0
 /** Action for editing findspots
  * 
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new FindSpotForm();
         $form->submit->setLabel('Update findspot');
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $updateData = $form->getValues();
                 $oldData = $this->_findspots->fetchRow('id=' . $this->_getParam('id'))->toArray();
                 $where = array();
                 $where[] = $this->_findspots->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $insertData = $this->_findspots->updateAndProcess($updateData);
                 $update = $this->_findspots->update($insertData, $where);
                 $returnID = (int) $this->_findspots->getFindNumber($this->_getParam('id'));
                 $this->_helper->audit($insertData, $oldData, 'FindSpotsAudit', $this->_getParam('id'), $returnID);
                 $this->_helper->solrUpdater->update('beowulf', $returnID);
                 $this->_flashMessenger->addMessage('Findspot updated!');
                 $this->_redirect(self::REDIRECT . 'record/id/' . $returnID);
             } else {
                 $id = (int) $this->_request->getParam('id', 0);
                 if ($id > 0) {
                     $where = array();
                     $where[] = $this->_findspots->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                     $findspot = $this->_findspots->fetchRow($where);
                     $this->_helper->findspotFormOptions();
                     $form->populate($formData);
                 }
             }
         } else {
             $id = (int) $this->_getParam('id', 0);
             if ($id > 0) {
                 $where = array();
                 $where[] = $this->_findspots->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $findspot = $this->_findspots->fetchRow($where);
                 $this->_helper->findspotFormOptions();
                 $this->view->findspot = $findspot->toArray();
                 $form->populate($findspot->toArray());
             }
         }
     } else {
         throw new Exception($this->_missingParameter, 500);
     }
 }