/** Edit a record
  *
  * @todo move update logic to model finds.php
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new FindForm();
         $form->submit->setLabel('Update record');
         $this->view->form = $form;
         if (in_array($this->getRole(), $this->_restricted)) {
             $form->removeDisplayGroup('discoverers');
             $form->removeElement('finder');
             $form->removeElement('secondfinder');
             $form->removeElement('idBy');
             $form->recordername->setAttrib('disabled', true);
             $form->removeElement('id2by');
         }
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $updateData = $form->getValues();
                 $updateData = array_filter($updateData);
                 $id2by = $form->getValue('id2by');
                 if ($id2by === "" || is_null($id2by)) {
                     $updateData['identifier2ID'] = NULL;
                 }
                 unset($updateData['recordername']);
                 unset($updateData['finder']);
                 unset($updateData['idBy']);
                 unset($updateData['id2by']);
                 unset($updateData['secondfinder']);
                 $oldData = $this->_finds->fetchRow('id=' . $this->_getParam('id'))->toArray();
                 $where = array();
                 $where[] = $this->_finds->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $this->_finds->update($updateData, $where);
                 $solr = new Pas_Solr_Updater();
                 $solr->add($this->_getParam('id'), 'beowulf');
                 $this->_helper->audit($updateData, $oldData, 'FindsAudit', $this->_getParam('id'), $this->_getParam('id'));
                 $this->_helper->solrUpdater->update('beowulf', $this->_getParam('id'));
                 $this->_flashMessenger->addMessage('Artefact information updated and audited!');
                 $this->_redirect(self::REDIRECT . 'record/id/' . $this->_getParam('id'));
             } else {
                 $find = $this->_finds->fetchRow('id=' . $this->_getParam('id'));
                 $this->view->find = $this->_finds->fetchRow('id=' . $this->_getParam('id'));
                 $form->populate($this->_request->getPost());
             }
         } else {
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $formData = $this->_finds->getEditData($id);
                 if (count($formData)) {
                     $form->populate($formData['0']);
                     $this->view->find = $this->_finds->fetchRow('id=' . $id);
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }
示例#2
0
 public function actionGroup($id)
 {
     $list = explode(",", $id);
     $model = new Bb('search');
     $this->pageTit = $this->maketit($id);
     $ffmodel = new FindForm();
     if (isset($_POST['FindForm'])) {
         $ffmodel->attributes = $_POST['FindForm'];
         if ($bb = $ffmodel->valid()) {
             if (!is_null($bb)) {
                 header("Location:" . Yii::app()->request->baseUrl . "/index.php?r=bb/views&id=" . $bb[0] . "&side=" . $bb[1]);
                 //					Yii::app()->runController('/bb/views/id/'.$bb->id.'/side/1');
                 //					$this->render('end',array('model'=>$bb));/**/
                 return;
             }
         }
     }
     $this->render('viewb', array('model' => $model, 'list' => $list, 'fmodel' => $ffmodel));
 }
示例#3
0
 public function actionMap()
 {
     $model = new Regions('search');
     $model->unsetAttributes();
     // clear any default values
     $dataProvider = new CActiveDataProvider('Regions');
     $cfmodel = new FindForm();
     if (isset($_POST['FindForm'])) {
         $cfmodel->attributes = $_POST['FindForm'];
         if ($bb = $cfmodel->valid()) {
             if (!is_null($bb)) {
                 header("Location:" . Yii::app()->request->baseUrl . "/index.php?r=bb/views&id=" . $bb[0] . "&side=" . $bb[1]);
                 return;
             }
         }
     }
     $this->render('map', array('dataProvider' => $dataProvider, 'model' => $model, 'fmodel' => $cfmodel));
 }