Example #1
0
 /** Edit a help topic
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $form = new HelpForm();
         $form->submit->setLabel('Submit changes');
         $form->author->setValue($this->getIdentityForForms());
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $where = array();
                 $where[] = $this->_help->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $this->_help->update($form->getValues(), $where);
                 $this->_flashMessenger->addMessage('You updated: <em>' . $form->getValue('title') . '</em> successfully. It is now available for use.');
                 $this->_redirect('admin/help/');
             } else {
                 $form->populate($form->getValues());
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 if (count($content)) {
                     $form->populate($this->_help->fetchRow('id=' . (int) $id)->toArray());
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }
Example #2
0
 /** Edit a help topic
  * @access public
  * @return void
  * @throws Pas_Exception_Param
  */
 public function editAction()
 {
     if ($this->getParam('id', false)) {
         $form = new HelpForm();
         $form->submit->setLabel('Submit changes');
         $form->author->setValue($this->getIdentityForForms());
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $where = array();
                 $where[] = $this->_help->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
                 $this->_help->update($form->getValues(), $where);
                 $this->getFlash()->addMessage('You updated: <em>' . $form->getValue('title') . '</em> successfully. It is now available for use.');
                 $this->redirect('admin/help/');
             } else {
                 $form->populate($form->getValues());
             }
         } else {
             $form->populate($this->_help->fetchRow('id= ' . $this->getParam('id'))->toArray());
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }