Exemplo n.º 1
0
 /** Edit a vacancy
  * @access public
  * @return void
  * @throws Pas_Exception_Param
  */
 public function editAction()
 {
     if ($this->getParam('id', false)) {
         $form = new VacancyForm();
         $form->submit->setLabel('Submit changes');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $where = array();
                 $where[] = $this->_vacancies->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
                 $insertdata = array('title' => $form->getValue('title'), 'salary' => $form->getValue('salary'), 'specification' => $form->getValue('specification'), 'regionID' => $form->getValue('regionID'), 'status' => $form->getValue('status'), 'live' => $form->getValue('live'), 'expire' => $form->getValue('expire'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms());
                 $this->_vacancies->update($insertdata, $where);
                 $this->getFlash()->addMessage('Vacancy details updated!');
                 ${$this}->redirect('/users/vacancies');
             } else {
                 $form->populate($this->_request->getPost());
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->getParam('id', 0);
             if ($id > 0) {
                 $vac = $this->_vacancies->fetchRow('id = ' . $id);
                 if (count($vac)) {
                     $form->populate($vac->toArray());
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParamter);
     }
 }
Exemplo n.º 2
0
 /** Add a new vacancy
  * @access public
  */
 public function addAction()
 {
     $form = new VacancyForm();
     $form->submit->setLabel('Add a new vacancy');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $this->_vacancies->add($form->getValues());
             $this->getFlash()->addMessage('Vacancy details created: ' . $form->getValue('title'));
             $this->redirect(self::REDIRECT);
         } else {
             $form->populate($form->getValues());
         }
     }
 }