Example #1
0
function formAction()
{
    global $tpl, $login;
    $commit = isset($_REQUEST['chkcommit']) ? $_REQUEST['chkcommit'] + 0 : 0;
    $delete = isset($_REQUEST['chkdelete']) ? $_REQUEST['chkdelete'] + 0 : 0;
    $disable = isset($_REQUEST['chkdisable']) ? $_REQUEST['chkdisable'] + 0 : 0;
    $userid = isset($_REQUEST['userid']) ? $_REQUEST['userid'] + 0 : 0;
    $user = new user($userid);
    if ($user->exist() == false) {
        $tpl->error(ERROR_UNKNOWN);
    }
    $username = $user->getUsername();
    if ($delete == 1 && $disable == 1) {
        $tpl->error('You cannot delete and disable the same time!');
    }
    if ($commit == 0) {
        $tpl->error('You have to check that you are sure!');
    }
    if ($disable == 1) {
        if ($user->disable() == false) {
            $tpl->error(ERROR_UNKNOWN);
        }
    } else {
        if ($delete == 1) {
            if ($user->delete() == false) {
                $tpl->error(ERROR_UNKNOWN);
            }
        }
    }
    $tpl->redirect('adminuser.php?action=searchuser&username=' . urlencode($username));
}
 /**
 	Deletes one user	*/
 public function delete()
 {
     global $__in, $__out;
     try {
         $user = new user();
         $user->delete($__in['id']);
         return dispatcher::redirect("getall", "deleted_successfully");
     } catch (ValidationException $ex) {
         $ex->publish_errors();
         return dispatcher::redirect("getall");
     } catch (Exception $ex) {
         throw $ex;
     }
 }
function formAction()
{
    global $tpl, $login, $translate;
    $commit = isset($_REQUEST['chkcommit']) ? $_REQUEST['chkcommit'] + 0 : 0;
    $delete = isset($_REQUEST['chkdelete']) ? $_REQUEST['chkdelete'] + 0 : 0;
    $disable = isset($_REQUEST['chkdisable']) ? $_REQUEST['chkdisable'] + 0 : 0;
    $emailproblem = isset($_REQUEST['chkemail']) ? $_REQUEST['chkemail'] + 0 : 0;
    $datalicense = isset($_REQUEST['chkdl']) ? $_REQUEST['chkdl'] + 0 : 0;
    $userid = isset($_REQUEST['userid']) ? $_REQUEST['userid'] + 0 : 0;
    $disduelicense = isset($_REQUEST['chkdisduelicense']) ? $_REQUEST['chkdisduelicense'] + 0 : 0;
    $user = new user($userid);
    if ($user->exist() == false) {
        $tpl->error(ERROR_UNKNOWN);
    }
    $username = $user->getUsername();
    if ($delete + $disable + $disduelicense > 1) {
        $tpl->error($translate->t('Please select only one of the delete/disable options!', '', '', 0));
    }
    if ($commit == 0) {
        $tpl->error($translate->t('You have to check that you are sure!', '', '', 0));
    }
    if ($disduelicense == 1) {
        $errmesg = $user->disduelicense();
        if ($errmesg !== true) {
            $tpl->error($errmesg);
        }
    } else {
        if ($disable == 1) {
            if ($user->disable() == false) {
                $tpl->error(ERROR_UNKNOWN);
            }
        } else {
            if ($delete == 1) {
                if ($user->delete() == false) {
                    $tpl->error(ERROR_UNKNOWN);
                }
            } else {
                if ($emailproblem == 1) {
                    $user->addEmailProblem($datalicense);
                }
            }
        }
    }
    $tpl->redirect('adminuser.php?action=searchuser&username='******'&success=' . ($disduelicense + $disable));
}
 function setup()
 {
     //Grab the user
     if (isset($_GET['cid'])) {
         $confirm_id = $_GET['cid'];
     } else {
         header("HTTP/1.0 404 Not Found");
         exit;
     }
     $user = new user();
     if ($user->load_from_confirm_id($confirm_id)) {
         //Grab the postcode and area
         $this->postcode = $user->postcode;
         $this->alert_area_size = alert_size_to_meters($user->alert_area_size);
         //delete the user
         $user->delete();
     } else {
         header("HTTP/1.0 404 Not Found");
         exit;
     }
 }
Example #5
0
        } elseif (!empty($_POST['email'])) {
            // email change request
            $result = user::change_email($_SESSION['user']['id'], $_POST['email']);
            if ($result) {
                redirect('?p=account&action=email&ok');
                die;
            } else {
                echo '<p>Impossible to change email!</p>';
            }
        }
    } elseif ($action == 'delete') {
        if (!empty($_POST['csrf_token'])) {
            $token = $_POST['csrf_token'];
            $valid = csrf::check($token, $_SESSION['token']);
            if ($valid) {
                $result = user::delete($_SESSION['user']['id']);
                if ($result) {
                    redirect('?p=disconnect&delete');
                    die;
                } else {
                    echo '<p>Impossible to delete this account!</p>';
                }
            } else {
                echo '<p style="color:red;">Wrong CSRF token!</p>';
            }
        }
    } else {
        // unknown action
    }
}
?>
Example #6
0
                ?>
&action=user_deleted">Yes, delete this user.</a> |
					<a href="<?php 
                echo RAPID_DIR;
                ?>
">No, take me back!</a>
				</p>
				
				<?php 
                include "footer.php";
                break;
            case 'user_deleted':
                include_once "includes/class.user.php";
                $u = new user();
                $u->username = $_GET['name'];
                if ($u->delete()) {
                    include "header.php";
                    ?>
					
					<h1>User Deleted</h1>
					<p>The user has been deleted successfully.</p>
					<p><a href="<?php 
                    echo RAPID_DIR;
                    ?>
">Return to the Main Page</a><p>
					
					<?php 
                    include "footer.php";
                } else {
                    include "header.php";
                    ?>
Example #7
0
 function maintainUsers()
 {
     $three_months_in_past = strtotime('-3 months');
     $three_months_in_past = strftime('%Y-%m-%d %H:%M:%S', $three_months_in_past);
     // get ids of all users in system
     $uids = user::getAllUserIds();
     // look at each user closely
     foreach ($uids as $uid) {
         $user = new user($uid);
         // did user log in within last 3 months?
         if ($user->getLastLoginTimestampStr() < $three_months_in_past) {
             // is user member of a team?
             $teamIds = $user->getTeamIds();
             if ($teamIds !== false) {
                 // check if teams of user are not deleted
                 // assume all teams are deleted by default then check status of each team
                 // this will work better with a very high number of teams because it avoids
                 // to load a huge list of deleted team ids into memory first
                 $teamsDeleted = count($teamIds) > 0 ? true : false;
                 foreach ($teamIds as $teamid) {
                     $team = new team($teamid);
                     // if getting status of team failed or status is not deleted then do not delete user
                     if ($team->getStatus() !== 'deleted') {
                         $teamsDeleted = false;
                     }
                 }
                 if ($teamsDeleted) {
                     $this->maintainPMs($uid);
                     $user->delete();
                 }
             }
         }
     }
 }
Example #8
0
 $user = new user(null, $_log);
 $salt = hash::salt(32);
 if ($data = $_db->get('Users', array('Username', '=', $username))) {
     //var_dump($data);
     if ($data->counts() > 0) {
         if ($data->first()->User_Verified == 0) {
             if ($data->first()->Confirm_Hash == $confirmCode) {
                 $oldUser = $data->first()->Old_User;
                 try {
                     $user->updateUser(array('Password' => hash::make(input::get('Password'), $salt), 'Salt' => $salt, 'User_Verified' => 1, 'Confirm_Hash' => null, 'Old_User' => null), $_GET['Username']);
                     session::flash('home', 'Your password has been created');
                     $_log->info('Username verified: ' . $username);
                     // Will be logged
                     if ($oldUser !== null) {
                         try {
                             if ($user->delete($oldUser)) {
                                 $_log->info('Old user deleted: ' . (string) $oldUser);
                             } else {
                                 $_log->warning('Old user NOT deleted: ' . (string) $oldUser);
                             }
                         } catch (Exception $e) {
                             var_dump($e->getMessage());
                             $_log->info($e->getMessage());
                             die($e->getMessage());
                         }
                     }
                     if ($user->login($username, input::get('Password'))) {
                         redirect::to('../index.php');
                     }
                 } catch (Exception $e) {
                     $_log->info('Could not update verify user in DB', $fields);
 function action_delete()
 {
     global $CURMAN;
     require_once CURMAN_DIRLOCATION . '/lib/user.class.php';
     $users = explode(',', $this->required_param('selectedusers', PARAM_TEXT));
     // make sure everything is an int
     foreach ($users as $key => $val) {
         $users[$key] = (int) $val;
         if (empty($users[$key])) {
             unset($users[$key]);
         }
     }
     $result = true;
     foreach ($users as $userid) {
         $userobj = new user($userid);
         if (!($result = $userobj->delete())) {
             break;
         }
     }
     $tmppage = new bulkuserpage();
     if ($result) {
         redirect($tmppage->get_url(), get_string('success_bulk_delete', 'block_curr_admin'));
     } else {
         print_error('error_bulk_delete', 'block_curr_admin', $tmppage->get_url());
     }
 }
Example #10
0
    # fill user with submitted data
    $userInst->id = tool::securePost('id');
    $userInst->fill(tool::securePostAll());
    if (!DEMO_MODE) {
        $status = $userInst->update();
    } else {
        $toolInst->errorStatus("not allowed in this demo. Sorry ;)");
    }
} elseif (tool::securePost('action') && tool::securePost('action') == "save") {
    $userInst->fill(tool::securePostAll());
    $status = $userInst->insert();
}
if (tool::securePost('action') && tool::securePost('action') == "delete" && tool::securePost('id') && tool::securePost('id') != "") {
    $userInst->id = tool::securePost('id');
    if (!DEMO_MODE) {
        $userInst->delete();
    } else {
        $toolInst->errorStatus("not allowed in this demo. Sorry ;)");
    }
}
if (tool::securePost('action') && tool::securePost('action') == "edit" && tool::securePost('id') && tool::securePost('id') != "") {
    $status = 0;
    $userInst->activate(tool::securePost('id'));
}
#######################################################################
## make edit / new form
if (!$status) {
    echo "<h2>" . $lang['common_editRecord'] . " (<a href=\"" . $toolInst->encodeUrl("index.php?content=" . $content) . "\">" . $lang['common_newRecord'] . "</a>)</h2>\n";
} else {
    $userInst->clear();
    echo "<h2>" . $lang['common_newRecord'] . "</h2>\n";
Example #11
0
 function do_delete()
 {
     // action_delete()
     require_once elispm::lib('data/user.class.php');
     $this->session_selection_deletion();
     $users = explode(',', $this->required_param('selectedusers', PARAM_TEXT));
     // make sure everything is an int
     foreach ($users as $key => $val) {
         $users[$key] = (int) $val;
         if (empty($users[$key])) {
             unset($users[$key]);
         }
     }
     foreach ($users as $userid) {
         $userobj = new user($userid);
         $userobj->delete();
         // TBD: try {} catch () {} ???
     }
     $tmppage = new bulkuserpage();
     redirect($tmppage->url, get_string('success_bulk_delete', 'local_elisprogram'));
 }
Example #12
0
<?php

if (isset($_REQUEST['i']) && !empty($_REQUEST['i'])) {
    $user = new user();
    $user->setId($_REQUEST['i']);
    if ($user->delete()) {
        print 'sucess';
    } else {
        print 'error';
    }
} else {
    print 'error';
}
Example #13
0
<?php

include_once 'config/db_conn.php';
include_once 'db_config/db_gigs.php';
include_once 'db_config/db_user.php';
$user = new user();
$rs_user = $user->user_list();
if ($_REQUEST['id']) {
    $user->delete($_REQUEST['id']);
    reDirect('users.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Orders - Admin </title>
<link rel="stylesheet" type="text/css" href="css/theme.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script>
   var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
   document.writeln('<link rel="stylesheet" type="text/css" href="css/' + StyleFile + '">');
</script>
<script>
function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete")) {
    document.location = delUrl;
  }
}
</script>
<!--[if IE]>
Example #14
0
 /**
  * test
  * 
  * tests almost all functions in the class
  * 
  * @return boolean
  */
 public function test()
 {
     $pass = true;
     $user1 = new user();
     $user1->create('testuser4', 'Passw0rd', '*****@*****.**', 'TEST');
     $user2 = new user();
     $user2->create('testuser5', 'Passw0rd', '*****@*****.**', 'TEST');
     //create
     $pass = $this->testRun($this->create($user2->id, $user1->id, "this is a test message." . time()));
     echo "|create\n";
     //getOutgoing
     $outmess = $this->getOutgoing($user1->id);
     $pass = $this->testRun($outmess);
     echo "|getOutgoing\n";
     //getIncoming
     $this->create($user1->id, $user2->id, "this is a second test message." . time());
     $inmess = $this->getIncoming($user1->id);
     $pass = $this->testRun($inmess);
     echo "|getIncomming\n";
     //delete
     $delpass = true;
     foreach ($inmess as $mess) {
         if (!$this->delete($mess['id'])) {
             $delpass = false;
         }
     }
     foreach ($outmess as $mess) {
         if (!$this->delete($mess['id'])) {
             $delpass = false;
         }
     }
     $pass = $this->testRun($delpass);
     echo "|delete\n";
     $user1->delete();
     $user2->delete();
     return $pass;
 }
Example #15
0
function run()
{
    global $user;
    global $layout;
    global $DB;
    $out = '';
    $item = new user();
    switch ($_REQUEST['act']) {
        case 1:
            // json data retrieval & operations
            switch ($_REQUEST['oper']) {
                case 'del':
                    // remove rows
                    $ids = $_REQUEST['ids'];
                    $deleted = 0;
                    foreach ($ids as $id) {
                        $item = new user();
                        $item->load($id);
                        $deleted = $deleted + $item->delete();
                    }
                    echo json_encode(count($ids) == $deleted);
                    break;
                default:
                    // list or search
                    $page = intval($_REQUEST['page']);
                    $max = intval($_REQUEST['rows']);
                    $offset = ($page - 1) * $max;
                    $orderby = $_REQUEST['sidx'] . ' ' . $_REQUEST['sord'];
                    $where = " 1=1 ";
                    if ($_REQUEST['_search'] == 'true' || isset($_REQUEST['quicksearch'])) {
                        if (isset($_REQUEST['quicksearch'])) {
                            $where .= $item->quicksearch($_REQUEST['quicksearch']);
                        } else {
                            if (isset($_REQUEST['filters'])) {
                                $where .= navitable::jqgridsearch($_REQUEST['filters']);
                            } else {
                                // single search
                                $where .= ' AND ' . navitable::jqgridcompare($_REQUEST['searchField'], $_REQUEST['searchOper'], $_REQUEST['searchString']);
                            }
                        }
                    }
                    $DB->queryLimit('id,username,email,profile,language,blocked', 'nv_users', $where, $orderby, $offset, $max);
                    $dataset = $DB->result();
                    $total = $DB->foundRows();
                    //echo $DB->get_last_error();
                    $out = array();
                    $profiles = profile::profile_names();
                    $languages = language::language_names();
                    for ($i = 0; $i < count($dataset); $i++) {
                        $out[$i] = array(0 => $dataset[$i]['id'], 1 => '<strong>' . $dataset[$i]['username'] . '</strong>', 2 => $dataset[$i]['email'], 3 => $profiles[$dataset[$i]['profile']], 4 => $languages[$dataset[$i]['language']], 5 => $dataset[$i]['blocked'] == 1 ? '<img src="img/icons/silk/cancel.png" />' : '');
                    }
                    navitable::jqgridJson($out, $page, $offset, $max, $total);
                    break;
            }
            session_write_close();
            exit;
            break;
        case 2:
            // edit/new form
            if (!empty($_REQUEST['id'])) {
                $item->load(intval($_REQUEST['id']));
            }
            if (isset($_REQUEST['form-sent'])) {
                $item->load_from_post();
                try {
                    $item->save();
                    permission::update_permissions(json_decode($_REQUEST['navigate_permissions_changes'], true), 0, $item->id);
                    $layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check');
                } catch (Exception $e) {
                    $layout->navigate_notification($e->getMessage(), true, true);
                }
            }
            $out = users_form($item);
            break;
        case 4:
            // remove
            if (!empty($_REQUEST['id'])) {
                $item->load(intval($_REQUEST['id']));
                if ($item->delete() > 0) {
                    $layout->navigate_notification(t(55, 'Item removed successfully.'), false);
                    $out = users_list();
                } else {
                    $layout->navigate_notification(t(56, 'Unexpected error.'), false);
                    $out = users_form($item);
                }
            }
            break;
        case 0:
            // list / search result
        // list / search result
        default:
            $out = users_list();
            break;
    }
    return $out;
}
Example #16
0
<?php

$ci =& get_instance();
$l = new user();
$l->get_by_id($ci->uri->segment(5));
if (!$l->exists()) {
    $ci->app->add_error("User not found");
} else {
    $l->delete();
    $ci->app->add_info(" user deleted ");
}
Example #17
0
 /**
  * Delete a user
  *
  * @param object $record One record of import data
  * @param string $filename The import file name, used for logging
  * @return boolean true on success, otherwise false
  */
 function user_delete($record, $filename)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/lib.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/user.class.php');
     $params = array();
     $errors = array();
     $error = false;
     $errsuffix = '';
     $uid = $this->get_userid_for_user_actions($record, $filename, $error, $errors, $errsuffix);
     if ($error) {
         $this->fslogger->log_failure(implode($errors, ", ") . $errsuffix, 0, $filename, $this->linenumber, $record, "user");
         return false;
     }
     if ($user = new user($uid)) {
         $user->delete();
     }
     //string to describe the user
     $user_descriptor = $this->get_user_descriptor($record);
     //log success
     $success_message = "User with {$user_descriptor} successfully deleted.";
     $this->fslogger->log_success($success_message, 0, $filename, $this->linenumber);
     return true;
 }
Example #18
0
 public function delete($thepage, $id)
 {
     $result = 0;
     switch ($thepage) {
         case 'user':
             $user = new user();
             $result = $user->delete($id);
             break;
         default:
             $obj = new $thepage();
             $result = $obj->delete($id);
             break;
     }
     if (!$id) {
         $arr = array('statusCode' => 300, 'message' => "请选中后删除", 'navTabId' => "", 'rel' => "", 'callbackType' => "forward", "forwardUrl" => "");
     } else {
         if ($result) {
             $arr = array('statusCode' => 200, 'message' => "删除成功", 'navTabId' => "", 'rel' => "", 'callbackType' => "forward", "forwardUrl" => "");
         } else {
             $arr = array('statusCode' => 300, 'message' => "操作失败", 'navTabId' => "", 'rel' => "", 'callbackType' => "forward", "forwardUrl" => "");
         }
     }
     return $arr;
 }
Example #19
0
 public function delete()
 {
     user::delete('evan');
 }
Example #20
0
 public function delete($thepage, $id)
 {
     $result = 0;
     switch ($thepage) {
         case 'user':
             $user = new user();
             $result = $user->delete($id);
             break;
         case 'test':
             $test = new test();
             $result = $test->delete($id);
             break;
         default:
             //$this->common_add($_POST,$thepage);
             break;
     }
     if (!$id) {
         $arr = array('statusCode' => 300, 'message' => "请选中后删除", 'navTabId' => "", 'rel' => "", 'callbackType' => "forward", "forwardUrl" => "");
     } else {
         if ($result) {
             $arr = array('statusCode' => 200, 'message' => "删除成功", 'navTabId' => "", 'rel' => "", 'callbackType' => "forward", "forwardUrl" => "");
         } else {
             $arr = array('statusCode' => 300, 'message' => "操作失败", 'navTabId' => "", 'rel' => "", 'callbackType' => "forward", "forwardUrl" => "");
         }
     }
     return $arr;
 }
Example #21
0
 /**
  * Performs user deletion
  * @throws moodle_exception If there was an error in passed parameters.
  * @throws data_object_exception If there was an error deleting the entity.
  * @param array $data The incoming data parameter.
  * @return array An array of parameters, if successful.
  */
 public static function user_delete(array $data)
 {
     global $USER, $DB;
     if (static::require_elis_dependencies() !== true) {
         throw new moodle_exception('ws_function_requires_elis', 'local_datahub');
     }
     // Parameter validation.
     $params = self::validate_parameters(self::user_delete_parameters(), array('data' => $data));
     // Context validation.
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     // Initialize version1elis importplugin for utility functions.
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     // Get the user we're updating via identifying fields.
     $idfields = array('idnumber', 'username', 'email');
     $userid = null;
     foreach ($idfields as $field) {
         if (isset($data[$field])) {
             $user = $DB->get_record(user::TABLE, array($field => $data[$field]));
             if (!empty($user)) {
                 if (!empty($userid) && $userid !== $user->id) {
                     // If we already have a userid from a previous field and this user doesn't match that user, throw exception.
                     throw new moodle_exception('ws_user_delete_fail_conflictingidfields', 'local_datahub');
                 } else {
                     $userid = $user->id;
                 }
             }
         }
     }
     if (empty($userid)) {
         // No valid identifying fields found.
         throw new moodle_exception('ws_user_delete_fail_noidfields', 'local_datahub');
     }
     // Capability checking.
     require_capability('local/elisprogram:user_delete', \local_elisprogram\context\user::instance($userid));
     // Delete the user.
     $user = new user($userid);
     $user->delete();
     // Verify user deleted & respond
     if (!$DB->record_exists(user::TABLE, array('id' => $userid))) {
         return array('messagecode' => get_string('ws_user_delete_success_code', 'local_datahub'), 'message' => get_string('ws_user_delete_success_msg', 'local_datahub'));
     } else {
         throw new data_object_exception('ws_user_delete_fail', 'local_datahub');
     }
 }
Example #22
0
require 'path.php';
init_cobalt('Delete user');
if (isset($_GET['username'])) {
    $username = urldecode($_GET['username']);
    require 'form_data_user.php';
}
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_delete']);
    require 'components/query_string_standard.php';
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_user.php?{$query_string}");
    } elseif ($_POST['btn_delete']) {
        log_action('Pressed delete button');
        require 'subclasses/user.php';
        $dbh_user = new user();
        $object_name = 'dbh_user';
        require 'components/create_form_data.php';
        $dbh_user->delete($arr_form_data);
        redirect("listview_user.php?{$query_string}");
    }
}
require 'subclasses/user_html.php';
$html = new user_html();
$html->draw_header('Delete User', $message, $message_type);
$html->draw_listview_referrer_info($filter_field_used, $filter_used, $page_from, $filter_sort_asc, $filter_sort_desc);
$html->draw_hidden('username');
$html->detail_view = TRUE;
$html->draw_controls('delete');
$html->draw_footer();