public function deleteAction() { if ($admin_id = $this->getRequest()->getParam('admin_id')) { try { $admin = new Admin_Model_Admin(); $admin->find($admin_id); if (!$admin->getId()) { throw new Exception($this->_("This administrator does not exist")); } $admin->delete(); $html = array('success' => 1, 'admin_id' => $admin_id); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }
public function deleteAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($data["admin_id"])) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $admin = new Admin_Model_Admin(); $admin->find($data["admin_id"]); if (!$admin->getId()) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $admin->delete(); $data = array("success" => 1, "message" => $this->_("User successfully deleted")); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }