コード例 #1
0
 /**
  * Delete a user from ol_admins table
  */
 public function deleteAdminAsyncAction()
 {
     // No need to render
     $this->_helper->viewRenderer->setNoRender();
     // Create json object
     $json = new stdClass();
     $json->error = 0;
     $json->message = "";
     // The entire process
     try {
         // Get parameters
         $userName = $this->_getParam("username");
         $where = array("user = ?" => $userName);
         // Current logged user cannot be removed
         if ($this->view->currentUser == $userName) {
             throw new Exception('You cannot remove your own username');
         }
         // Create instance and insert user
         $users = new OneLogin_Acl_Users();
         $users->delete($where);
         $json->message = "User removed";
     } catch (Exception $e) {
         $json->error = 1;
         $json->message = str_replace("'", '', trim($e->getMessage()));
     }
     echo $this->_helper->json($json);
     // Send response
 }