public function deleteAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (empty($data["user_id"])) {
                 throw new Exception($this->_("An error occurred while saving. Please try again later."));
             }
             $user = new Backoffice_Model_User();
             $user->find($data["user_id"]);
             if (!$user->getId()) {
                 throw new Exception($this->_("An error occurred while saving. Please try again later."));
             }
             if ($user->findAll()->count() <= 1) {
                 throw new Exception($this->_("How do you want to access the backoffice if you remove the only user remaining?"));
             }
             $user->delete();
             $data = array("success" => 1, "message" => $this->_("User successfully deleted"));
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
 public function deleteAction()
 {
     if ($user_id = $this->getRequest()->getParam('user_id')) {
         try {
             $user = new Backoffice_Model_User();
             $users = $user->findAll();
             if ($users->count() == 1) {
                 throw new Exception($this->_("This account can't be deleted, it's the only one"));
             }
             $user->find($user_id);
             if (!$user->getId()) {
                 throw new Exception($this->_("This administrator does not exist"));
             }
             $user->delete();
             $html = array('success' => 1, 'user_id' => $user_id);
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }