/** * Allows users to logically delete other users * (should be reserved for administrators) * * @access public * @return void */ public function deleteAction() { $this->title = 'Delete this user'; $form = new DeleteForm(); $userModel = new BackofficeUser(); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $userModel->deleteById($form->getValue('id')); $this->_helper->FlashMessenger(array('msg-success' => 'The item was successfully deleted.')); App_FlagFlippers_Manager::save(); $this->_redirect('/users/'); } } else { $id = $this->_getParam('id'); if (!is_numeric($id)) { $this->_helper->FlashMessenger(array('msg-error' => 'The id you provided is invalid.')); $this->_redirect('/users/'); } if ($id == 1) { $this->_helper->FlashMessenger(array('msg-error' => 'It is forbidden to mess with the admin account in this release.')); $this->_redirect('/users/'); } $row = $userModel->findById($id); if (empty($row)) { $this->_helper->FlashMessenger(array('msg-error' => 'The requested item cannot be found.')); $this->_redirect('/users/'); } $this->view->item = $row; $form->populate($row->toArray()); } $this->view->form = $form; }