PHP User::deactivate Examples

PHP User::deactivate - 8 examples found. These are the top rated real world PHP examples of User::deactivate extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 /**
  * actionCheckldap
  *
  * @return void
  */
 public function actionCheckldap()
 {
     $active_user = User::require_admin();
     $this->setLayoutVar('active_user', $active_user);
     $this->setVar('active_user', $active_user);
     if (!empty($this->post['submit'])) {
         if (!empty($this->post['deactivate'])) {
             foreach ($this->post['deactivate'] as $name) {
                 User::deactivate($name);
             }
         }
     }
     $bad_users = Admin::check_all_users();
     $this->setVar('bad_users', $bad_users);
 }
 public function register($data)
 {
     $email_activation = $this->ci->config->item('email_activation');
     $user = new User($data);
     $user->save();
     // run insert model to write data to db
     if ($user->is_valid()) {
         //add a new users to default group
         $default = $this->ci->config->item('default_group');
         $group_default = Group::find_by_name($default);
         $group = new Usersgroup(array('user_id' => $user->id, 'group_id' => $group_default->id));
         $group->save();
         //watch if there is a email activation
         if ($email_activation) {
             $activation_code = User::deactivate($user->id);
             if (!$activation_code) {
                 return FALSE;
             }
             $data = array('identity' => $user->email, 'id' => $user->id, 'email' => $user->email, 'password' => 'password', 'activation' => $activation_code);
             $message = $this->ci->load->view($this->ci->config->item('email_templates') . $this->ci->config->item('email_activate'), $data, true);
             $this->ci->email->clear();
             $this->ci->email->set_newline("\r\n");
             $this->ci->email->from($this->ci->config->item('admin_email'), $this->ci->config->item('site_title'));
             $this->ci->email->to($user->email);
             $this->ci->email->subject($this->ci->config->item('site_title') . ' - ' . lang('web_auth_act'));
             $this->ci->email->message($message);
             if ($this->ci->email->send() == TRUE) {
                 return TRUE;
             } else {
                 return FALSE;
             }
         } else {
             return TRUE;
         }
     }
     if ($user->is_invalid()) {
         return FALSE;
     }
 }
 /**
  * Remove the specified user from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         User::deactivate($id);
     } catch (\Exception $e) {
         return $this->handleError($e);
     }
     return Redirect::route('users.index');
 }
 /**
  * Deactivate the requested user.
  *
  * @return Response
  */
 public function deactivateUser($user_id)
 {
     try {
         if (User::deactivate($user_id)) {
             Session::flash('alert_success', 'User successfully deactivated.');
             return $this->handleResponse(['message' => 'User successfully deactivated.']);
         } else {
             Session::flash('alert_danger', 'Failed to deactivate User.');
             return $this->handleError(new \Exception('Failed to deactivate user.'));
         }
     } catch (\Exception $e) {
         return $this->handleError($e);
     }
 }
Example #5
0
 function deactivate($id = NULL)
 {
     // no funny business, force to integer
     $id = (int) $id;
     if ($this->sangar_auth->is_admin()) {
         $code = User::deactivate($id);
         if ($code) {
             $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('deactivate_successful')));
         } else {
             $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('deactivate_unsuccessful')));
         }
         redirect("/admin/users/", 'refresh');
     } else {
         $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('web_not_do_this')));
         redirect("/admin/users/", 'refresh');
     }
 }
 function test_deactivate_user()
 {
     $user = User::find_by_email($this->m_email_user);
     $deactivate = User::deactivate($user->id);
     $this->_assert_true($deactivate);
 }
Example #7
0
    Redirect::To("users.php");
}
if (Input::get("activate") && $user->hasPermission("admin") && Input::get("checkbox")) {
    try {
        foreach (Input::get("checkbox") as $checkbox) {
            $user->activate($checkbox);
        }
        Session::Flash("usersPage", "success", lang('USERS_ACCOUNT_ACTIVE_SUCCESS'), true);
    } catch (Exception $ex) {
        Session::Flash("usersPage", "danger", $ex->GetMessage(), true);
    }
}
if (Input::get("deactivate") && $user->hasPermission("admin") && Input::get("checkbox")) {
    try {
        foreach (Input::get("checkbox") as $checkbox) {
            $user->deactivate($checkbox);
        }
        Session::Flash("usersPage", "success", lang('USERS_ACCOUNT_DEACTIVE_SUCCESS'), true);
    } catch (Exception $ex) {
        Session::Flash("usersPage", "danger", $ex->GetMessage(), true);
    }
}
$template->header("Users");
if (Session::exists('usersPage')) {
    foreach (Session::Flash('usersPage') as $error) {
        echo "<div class='alert alert-" . $error['type'] . "' role='alert'>";
        echo "<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>";
        echo "<span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span>";
        echo "&nbsp;" . $error['message'];
        echo "</div>";
    }
Example #8
0
         Token::remove($_POST['token']);
     }
     break;
 case 'deactivate':
     # code...
     if (!isset($_POST['token']) || !Token::isExist($_POST['token'])) {
         // VALIDATE ALL
         $alertred[] = TOKEN_NOT_EXIST;
     }
     if (isset($alertred)) {
         # code...
         $data['alertred'] = $alertred;
     } else {
         foreach ($user_id as $id) {
             # code...
             User::deactivate($id);
         }
     }
     if (isset($_POST['token'])) {
         Token::remove($_POST['token']);
     }
     break;
 case 'delete':
     # code...
     if (!isset($_POST['token']) || !Token::isExist($_POST['token'])) {
         // VALIDATE ALL
         $alertred[] = TOKEN_NOT_EXIST;
     }
     if (isset($alertred)) {
         # code...
         $data['alertred'] = $alertred;