当前位置: 首页>>代码示例>>PHP>>正文


PHP delete_user函数代码示例

本文整理汇总了PHP中delete_user函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_user函数的具体用法?PHP delete_user怎么用?PHP delete_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delete_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_are_notification_preferences_configured

 /**
  * Test are_notification_preferences_configured
  */
 public function test_are_notification_preferences_configured()
 {
     $this->resetAfterTest(true);
     $user1 = self::getDataGenerator()->create_user();
     $user2 = self::getDataGenerator()->create_user();
     $user3 = self::getDataGenerator()->create_user();
     self::setUser($user1);
     set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user1);
     set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'airnotifier', $user1);
     set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user2);
     set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user3);
     $params = array($user1->id, $user2->id, $user3->id);
     $preferences = message_airnotifier_external::are_notification_preferences_configured($params);
     $expected = array(array('userid' => $user1->id, 'configured' => 1));
     $this->assertEquals(1, count($preferences['users']));
     $this->assertEquals($expected, $preferences['users']);
     $this->assertEquals(2, count($preferences['warnings']));
     // Now, remove one user.
     delete_user($user2);
     $preferences = message_airnotifier_external::are_notification_preferences_configured($params);
     $this->assertEquals(1, count($preferences['users']));
     $this->assertEquals($expected, $preferences['users']);
     $this->assertEquals(2, count($preferences['warnings']));
     // Now, remove one user1 preference (the user still has one prefernce for airnotifier).
     unset_user_preference('message_provider_moodle_instantmessage_loggedin', $user1);
     $preferences = message_airnotifier_external::are_notification_preferences_configured($params);
     $this->assertEquals($expected, $preferences['users']);
     // Delete the last user1 preference.
     unset_user_preference('message_provider_moodle_instantmessage_loggedoff', $user1);
     $preferences = message_airnotifier_external::are_notification_preferences_configured($params);
     $expected = array(array('userid' => $user1->id, 'configured' => 0));
     $this->assertEquals($expected, $preferences['users']);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:36,代码来源:externallib_test.php

示例2: admin_test_main

function admin_test_main()
{
    // Create user
    echo '<br><h3>Creating User.</h3><br>';
    $user_1 = user_1();
    user\add_user($user_1);
    echo '<br><h3>User created!</h3><br>';
    // Verify
    $user_1_db = user\authenticate_user($user_1['email_address'], $user_1['password']);
    $user_1_id = $user_1_db['id'];
    echo "<br><h3>User ID: {$user_1_id}</h3><br>";
    // Update user
    echo "<br><h3>Updating User.</h3><br>";
    $user_1_db['email_address'] = 'User@Two.com';
    $user_1_db['last_name'] = 'Two';
    update_user($user_1_db);
    echo "<br><h3>User Updated!</h3><br>";
    // Verify
    $user_2_db = user\authenticate_user('User@Two.com', $user_1['password']);
    $new_last_name = $user_2_db['last_name'];
    echo "<br><h3>New User Last Name: {$user_2_db}";
    // Delete user
    echo "<br><h3>Deleting User.</h3><br>";
    delete_user(array("user_id" => $user_1_id));
    echo "<br><h3>User deleted!</h3><br>";
}
开发者ID:strall,项目名称:easy-ride,代码行数:26,代码来源:admin_test.php

示例3: tearDown

 public function tearDown()
 {
     global $DB;
     if ($user = $DB->get_record('user', array('username' => 'simpletest'))) {
         delete_user($user);
         $DB->delete_records('user', array('id' => $user->id));
     }
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:8,代码来源:testfixtureuser.php

示例4: delete_teacher

function delete_teacher($id)
{
    $teacher = get_userdata($id);
    if ($teacher->type != 'teacher') {
        return false;
    }
    delete_user($id);
}
开发者ID:HaThuy92,项目名称:hathithuy_quanlytinchi,代码行数:8,代码来源:user.php

示例5: account_delete_submit

function account_delete_submit(Pieform $form, $values)
{
    global $SESSION, $USER;
    $userid = $USER->get('id');
    $USER->logout();
    delete_user($userid);
    $SESSION->add_ok_msg(get_string('accountdeleted', 'account'));
    redirect('/index.php');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:9,代码来源:delete.php

示例6: buttons_submit_delete

function buttons_submit_delete(Pieform $form, $values)
{
    global $SESSION;
    $ids = get_user_ids_from_post();
    foreach ($ids as $userid) {
        delete_user($userid);
    }
    $SESSION->add_ok_msg(get_string('usersdeletedsuccessfully', 'admin'));
    redirect('/admin/users/suspended.php');
}
开发者ID:Br3nda,项目名称:mahara,代码行数:10,代码来源:suspended.php

示例7: execute

 /**
  * Do the job.
  * Throw exceptions on errors (the job will be retried).
  */
 public function execute()
 {
     global $CFG, $DB;
     $timenow = time();
     // Delete users who haven't completed profile within required period.
     if (!empty($CFG->deleteincompleteusers)) {
         $cuttime = $timenow - $CFG->deleteincompleteusers * 3600;
         $rs = $DB->get_recordset_sql("SELECT *\n                                               FROM {user}\n                                           WHERE confirmed = 1 AND lastaccess > 0\n                                               AND lastaccess < ? AND deleted = 0\n                                               AND (lastname = '' OR firstname = '' OR email = '')", array($cuttime));
         foreach ($rs as $user) {
             if (isguestuser($user) or is_siteadmin($user)) {
                 continue;
             }
             delete_user($user);
             mtrace(" Deleted not fully setup user {$user->username} ({$user->id})");
         }
         $rs->close();
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:22,代码来源:delete_incomplete_users_task.php

示例8: execute

 /**
  * Do the job.
  * Throw exceptions on errors (the job will be retried).
  */
 public function execute()
 {
     global $CFG, $DB;
     $timenow = time();
     // Delete users who haven't confirmed within required period.
     if (!empty($CFG->deleteunconfirmed)) {
         $cuttime = $timenow - $CFG->deleteunconfirmed * 3600;
         $rs = $DB->get_recordset_sql("SELECT *\n                                             FROM {user}\n                                            WHERE confirmed = 0 AND firstaccess > 0\n                                                  AND firstaccess < ? AND deleted = 0", array($cuttime));
         foreach ($rs as $user) {
             delete_user($user);
             // We MUST delete user properly first.
             $DB->delete_records('user', array('id' => $user->id));
             // This is a bloody hack, but it might work.
             mtrace(" Deleted unconfirmed user for " . fullname($user, true) . " ({$user->id})");
         }
         $rs->close();
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:22,代码来源:delete_unconfirmed_users_task.php

示例9: possibly_delete_user

function possibly_delete_user($user)
{
    if ($user->total_credit > 0.0) {
        admin_error_page("Cannot delete user: User has credit.");
    }
    // Don't delete user if they have any outstanding Results
    //
    if (BoincResult::count("userid={$user->id}")) {
        admin_error_page("Cannot delete user: User has count results in the database.");
    }
    // Don't delete user if they have posted to the forums
    //
    if (BoincPost::count("user={$user->id}")) {
        admin_error_page("Cannot delete user: User has forum posts.");
    }
    if ($user->teamid) {
        user_quit_team($user);
    }
    delete_user($user);
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:20,代码来源:manage_user.php

示例10: unset

     }
 }
 // delete user
 if (!empty($user->deleted)) {
     if (!$allowdeletes) {
         $usersskipped++;
         $upt->track('status', $strusernotdeletedoff, 'warning');
         continue;
     }
     if ($existinguser) {
         if (is_siteadmin($existinguser->id)) {
             $upt->track('status', $strusernotdeletedadmin, 'error');
             $deleteerrors++;
             continue;
         }
         if (delete_user($existinguser)) {
             $upt->track('status', $struserdeleted);
             $deletes++;
         } else {
             $upt->track('status', $strusernotdeletederror, 'error');
             $deleteerrors++;
         }
     } else {
         $upt->track('status', $strusernotdeletedmissing, 'error');
         $deleteerrors++;
     }
     continue;
 }
 // we do not need the deleted flag anymore
 unset($user->deleted);
 // renaming requested?
开发者ID:richheath,项目名称:moodle,代码行数:31,代码来源:uploaduser.php

示例11: mysql_query

    mysql_query($sql, $db);
    write_to_log(AT_ADMIN_LOG_DELETE, 'users_online', mysql_affected_rows($db), $sql);
    $sql = "DELETE FROM " . TABLE_PREFIX . "members WHERE member_id={$id}";
    mysql_query($sql, $db);
    write_to_log(AT_ADMIN_LOG_DELETE, 'members', mysql_affected_rows($db), $sql);
    $sql = "DELETE FROM " . TABLE_PREFIX . "member_track WHERE member_id={$id}";
    mysql_query($sql, $db);
    write_to_log(AT_ADMIN_LOG_DELETE, 'member_track', mysql_affected_rows($db), $sql);
    // delete personal files from file storage
    fs_delete_workspace(WORKSPACE_PERSONAL, $id);
    return;
}
$ids = explode(',', $_REQUEST['id']);
if (isset($_POST['submit_yes'])) {
    foreach ($ids as $id) {
        delete_user(intval($id));
    }
    $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
    if (isset($_POST['ml']) && $_REQUEST['ml']) {
        header('Location: ' . AT_BASE_HREF . 'mods/_core/users/master_list.php');
    } else {
        header('Location: ' . AT_BASE_HREF . 'mods/_core/users/users.php');
    }
    exit;
} else {
    if (isset($_POST['submit_no'])) {
        $msg->addFeedback('CANCELLED');
        if (isset($_POST['ml']) && $_REQUEST['ml']) {
            header('Location: ' . AT_BASE_HREF . 'mods/_core/users/master_list.php');
        } else {
            header('Location: ' . AT_BASE_HREF . 'mods/_core/users/users.php');
开发者ID:vicentborja,项目名称:ATutor,代码行数:31,代码来源:admin_delete.php

示例12: cron_run

/**
 * Execute cron tasks
 */
function cron_run()
{
    global $DB, $CFG, $OUTPUT;
    if (CLI_MAINTENANCE) {
        echo "CLI maintenance mode active, cron execution suspended.\n";
        exit(1);
    }
    if (moodle_needs_upgrading()) {
        echo "Moodle upgrade pending, cron execution suspended.\n";
        exit(1);
    }
    require_once $CFG->libdir . '/adminlib.php';
    require_once $CFG->libdir . '/gradelib.php';
    if (!empty($CFG->showcronsql)) {
        $DB->set_debug(true);
    }
    if (!empty($CFG->showcrondebugging)) {
        set_debugging(DEBUG_DEVELOPER, true);
    }
    set_time_limit(0);
    $starttime = microtime();
    // Increase memory limit
    raise_memory_limit(MEMORY_EXTRA);
    // Emulate normal session - we use admin accoutn by default
    cron_setup_user();
    // Start output log
    $timenow = time();
    mtrace("Server Time: " . date('r', $timenow) . "\n\n");
    // Run cleanup core cron jobs, but not every time since they aren't too important.
    // These don't have a timer to reduce load, so we'll use a random number
    // to randomly choose the percentage of times we should run these jobs.
    $random100 = rand(0, 100);
    if ($random100 < 20) {
        // Approximately 20% of the time.
        mtrace("Running clean-up tasks...");
        cron_trace_time_and_memory();
        // Delete users who haven't confirmed within required period
        if (!empty($CFG->deleteunconfirmed)) {
            $cuttime = $timenow - $CFG->deleteunconfirmed * 3600;
            $rs = $DB->get_recordset_sql("SELECT *\n                                             FROM {user}\n                                            WHERE confirmed = 0 AND firstaccess > 0\n                                                  AND firstaccess < ?", array($cuttime));
            foreach ($rs as $user) {
                delete_user($user);
                // we MUST delete user properly first
                $DB->delete_records('user', array('id' => $user->id));
                // this is a bloody hack, but it might work
                mtrace(" Deleted unconfirmed user for " . fullname($user, true) . " ({$user->id})");
            }
            $rs->close();
        }
        // Delete users who haven't completed profile within required period
        if (!empty($CFG->deleteincompleteusers)) {
            $cuttime = $timenow - $CFG->deleteincompleteusers * 3600;
            $rs = $DB->get_recordset_sql("SELECT *\n                                             FROM {user}\n                                            WHERE confirmed = 1 AND lastaccess > 0\n                                                  AND lastaccess < ? AND deleted = 0\n                                                  AND (lastname = '' OR firstname = '' OR email = '')", array($cuttime));
            foreach ($rs as $user) {
                if (isguestuser($user) or is_siteadmin($user)) {
                    continue;
                }
                delete_user($user);
                mtrace(" Deleted not fully setup user {$user->username} ({$user->id})");
            }
            $rs->close();
        }
        // Delete old logs to save space (this might need a timer to slow it down...)
        if (!empty($CFG->loglifetime)) {
            // value in days
            $loglifetime = $timenow - $CFG->loglifetime * 3600 * 24;
            $DB->delete_records_select("log", "time < ?", array($loglifetime));
            mtrace(" Deleted old log records");
        }
        // Delete old backup_controllers and logs.
        $loglifetime = get_config('backup', 'loglifetime');
        if (!empty($loglifetime)) {
            // Value in days.
            $loglifetime = $timenow - $loglifetime * 3600 * 24;
            // Delete child records from backup_logs.
            $DB->execute("DELETE FROM {backup_logs}\n                           WHERE EXISTS (\n                               SELECT 'x'\n                                 FROM {backup_controllers} bc\n                                WHERE bc.backupid = {backup_logs}.backupid\n                                  AND bc.timecreated < ?)", array($loglifetime));
            // Delete records from backup_controllers.
            $DB->execute("DELETE FROM {backup_controllers}\n                          WHERE timecreated < ?", array($loglifetime));
            mtrace(" Deleted old backup records");
        }
        // Delete old cached texts
        if (!empty($CFG->cachetext)) {
            // Defined in config.php
            $cachelifetime = time() - $CFG->cachetext - 60;
            // Add an extra minute to allow for really heavy sites
            $DB->delete_records_select('cache_text', "timemodified < ?", array($cachelifetime));
            mtrace(" Deleted old cache_text records");
        }
        if (!empty($CFG->usetags)) {
            require_once $CFG->dirroot . '/tag/lib.php';
            tag_cron();
            mtrace(' Executed tag cron');
        }
        // Context maintenance stuff
        context_helper::cleanup_instances();
        mtrace(' Cleaned up context instances');
        context_helper::build_all_paths(false);
//.........这里部分代码省略.........
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:101,代码来源:cronlib.php

示例13: user_delete_user

/**
 * Marks user deleted in internal user database and notifies the auth plugin.
 * Also unenrols user from all roles and does other cleanup.
 *
 * @todo Decide if this transaction is really needed (look for internal TODO:)
 * @param object $user Userobject before delete    (without system magic quotes)
 * @return boolean success
 */
function user_delete_user($user)
{
    return delete_user($user);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:12,代码来源:lib.php

示例14: session_start

    session_start();
}
$op = "";
if (isset($_POST['op'])) {
    $op = $_POST['op'];
} elseif (isset($_GET['op'])) {
    $op = $_GET['op'];
}
if ($op != "register" && (!check_session_user() || !check_admin_user())) {
    header('Location: index.php?error=Invalid User' . $op);
} else {
    if (strlen($op) > 0) {
        if ($op == "delete") {
            if (isset($_GET['id'])) {
                $username = $_GET['id'];
                $err = delete_user($username);
                if (strlen($err) > 0) {
                    header('Location: error.php?msg=' . urlencode($err));
                } else {
                    header('Location: user_list.php');
                }
            } else {
                header('Location: error.php?msg=No id');
            }
        } elseif ($op == "password") {
            $username = $_SESSION["user"];
            $password = $_POST['password'];
            $password2 = $_POST['password2'];
            $err = "";
            if (strlen(trim($password)) > 0) {
                if (trim($password) != trim($password2)) {
开发者ID:grycap,项目名称:im-web,代码行数:31,代码来源:userinfo.php

示例15: delete_submit

function delete_submit(Pieform $form, $values)
{
    global $users, $editable, $SESSION;
    db_begin();
    foreach ($users as $user) {
        delete_user($user->id);
    }
    db_commit();
    $SESSION->add_ok_msg(get_string('bulkdeleteuserssuccess', 'admin', count($users)));
    redirect('/admin/users/search.php');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:11,代码来源:bulk.php


注:本文中的delete_user函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。