2007-08-07 07:26:58 +00:00
|
|
|
<?php //$Id$
|
|
|
|
/**
|
|
|
|
* script for bulk user delete operations
|
|
|
|
*/
|
|
|
|
|
2007-08-15 05:30:49 +00:00
|
|
|
require_once('../../config.php');
|
2007-08-07 07:26:58 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
|
|
|
|
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
|
|
|
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
|
|
|
|
|
|
|
require_capability('moodle/user:delete', $sitecontext);
|
|
|
|
|
|
|
|
// clean-up users list
|
|
|
|
$primaryadmin = get_admin();
|
|
|
|
$userlist = array();
|
|
|
|
foreach ($SESSION->bulk_susers as $k => $v) {
|
2007-09-28 03:07:03 +00:00
|
|
|
$user = get_record('user', 'id', $v, null, null, null, null, 'id,firstname,lastname,email,auth');
|
2007-08-07 07:26:58 +00:00
|
|
|
if (!empty($user) && $user->id != $primaryadmin->id) {
|
|
|
|
$userlist[$k] = $user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($userlist)) {
|
2007-08-20 08:51:35 +00:00
|
|
|
redirect($CFG->wwwroot . '/admin/user/user_bulk.php');
|
2007-08-07 07:26:58 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 02:36:47 +00:00
|
|
|
admin_externalpage_setup('userbulk');
|
2007-08-07 07:26:58 +00:00
|
|
|
admin_externalpage_print_header();
|
|
|
|
if (empty($confirm)) {
|
|
|
|
$usernames = array();
|
|
|
|
foreach ($userlist as $user) {
|
|
|
|
$usernames[] =& fullname($user, true);
|
|
|
|
}
|
|
|
|
$usernames = implode(', ', $usernames);
|
|
|
|
$optionsyes['confirm'] = 1;
|
|
|
|
$optionsyes['sesskey'] = sesskey();
|
|
|
|
print_heading(get_string('confirmation', 'admin'));
|
|
|
|
notice_yesno(get_string('deletecheckfull', '', $usernames), 'user_bulk_delete.php', 'user_bulk.php', $optionsyes, NULL, 'post', 'get');
|
|
|
|
} else {
|
|
|
|
foreach ($userlist as $k => $user) {
|
2007-09-28 03:07:03 +00:00
|
|
|
if (delete_user($user)) {
|
2007-08-07 07:26:58 +00:00
|
|
|
unset($SESSION->bulk_susers[$k]);
|
|
|
|
} else {
|
|
|
|
notify(get_string('deletednot', '', fullname($user, true)));
|
|
|
|
}
|
|
|
|
}
|
2007-08-15 05:30:49 +00:00
|
|
|
redirect($CFG->wwwroot . '/admin/user/user_bulk.php', get_string('changessaved'));
|
2007-08-07 07:26:58 +00:00
|
|
|
}
|
|
|
|
admin_externalpage_print_footer();
|
2007-09-28 03:07:03 +00:00
|
|
|
?>
|