Ejemplo n.º 1
0
    /**
     * Delete an action
     *
     * This method is used to delete an action from the list of actions.
     * Once the action is deleted, the user is sent back to the /actions page.
     *
     * @return Zend_View
     */
    public function deleteAction()
    {
        $id = $this->getRequest()->getParam('id');
        if ($id === null) {
            $this->addErrorMessage($this->tr->_('ACTION_MISSING_ID'));
            return;
        }

        $model = new Default_Model_Action;
        $model->delete($id);
        $this->addMessage($this->tr->_('ACTION_DELETE'));
        $this->_redirect('/action');
    }
Ejemplo n.º 2
0
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     if ($id === null) {
         $this->addErrorMessage('ID parameter is missing.');
         return;
     }
     $model = new Default_Model_Action();
     $model->delete($id);
     $this->addMessage('Action deleted');
     $this->_redirect('/action');
 }
Ejemplo n.º 3
0
 /**
  * Delete an action
  *
  * This is the delete action method. It allows you to delete an action.
  *
  * @return void
  */
 public function deleteAction()
 {
     $this->_helper->viewRenderer->setViewSuffix('txt');
     // The options we are accepting for deleting
     $options = new Zend_Console_Getopt(array('name|n=s' => $this->tr->_('NAME')));
     try {
         $options->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         $this->view->message = $e->getUsageMessage();
         return;
     }
     if ($options->name == '') {
         echo $options->getUsageMessage();
         exit;
     }
     $action_name = ucfirst(strtolower($options->name));
     $model = new Default_Model_Action();
     $tempActions = $model->getList();
     $action_id = null;
     foreach ($tempActions as $hash => $tempName) {
         if ($action_name == $tempName) {
             $action_id = $hash;
             break;
         }
     }
     if (!$action_id) {
         $this->view->message = $this->tr->_('COULD_NOT_DELETE_ACTION') . ': ' . $action_name . '. ' . $this->tr->_('COULD_NOT_FIND_MATCH') . PHP_EOL;
         return;
     }
     try {
         $model->delete($action_id);
         $this->view->message = $this->tr->_('SUCCESS_DELETE_ACTION') . ': ' . $action_name . PHP_EOL;
     } catch (RuntimeException $e) {
         $this->view->message = $this->tr->_('ERROR_DELETING_ACTION') . ': ' . $action_name . '. ' . $e->getMessage() . PHP_EOL;
     }
 }
Ejemplo n.º 4
0
 /**
  * Delete an action
  *
  * This is the delete action method. It allows you to delete an action.
  *
  * @return void
  */
 public function deleteAction()
 {
     $this->_helper->viewRenderer->setViewSuffix('txt');
     // The options we are accepting for deleting
     $options = new Zend_Console_Getopt(array('name|n=s' => 'Name of the action.'));
     try {
         $options->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         $this->view->message = $e->getUsageMessage();
         return;
     }
     if ($options->name == '') {
         echo $options->getUsageMessage();
         exit;
     }
     $action_name = ucfirst(strtolower($options->name));
     $model = new Default_Model_Action();
     $tempActions = $model->getList();
     $action_id = null;
     foreach ($tempActions as $hash => $tempName) {
         if ($action_name == $tempName) {
             $action_id = $hash;
             break;
         }
     }
     if (!$action_id) {
         $this->view->message = 'Could not delete action: ' . $action_name . '. Could not find match.' . PHP_EOL;
         return;
     }
     try {
         $model->delete($action_id);
         $this->view->message = 'Successfully deleted action: ' . $action_name . PHP_EOL;
     } catch (RuntimeException $e) {
         $this->view->message = 'Error deleting action: ' . $action_name . '. ' . $e->getMessage() . PHP_EOL;
     }
 }