mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-14679 towards /admin/user conversion
This commit is contained in:
parent
68dfee6a95
commit
ca8d6e377c
@ -7,18 +7,18 @@ if (!defined('MAX_BULK_USERS')) {
|
||||
}
|
||||
|
||||
function add_selection_all($ufiltering) {
|
||||
global $SESSION;
|
||||
global $SESSION, $DB;
|
||||
|
||||
$guest = get_guest();
|
||||
$sqlwhere = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$guest->id));
|
||||
list($sqlwhere, $params) = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$guest->id));
|
||||
|
||||
if ($rs = get_recordset_select('user', $sqlwhere, 'fullname', 'id,'.sql_fullname().' AS fullname')) {
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if (! isset($SESSION->bulk_users[$user->id])) {
|
||||
if ($rs = $DB->get_recordset_select('user', $sqlwhere, $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname')) {
|
||||
foreach ($rs as $user) {
|
||||
if (!isset($SESSION->bulk_users[$user->id])) {
|
||||
$SESSION->bulk_users[$user->id] = $user->id;
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
$rs->close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ function get_selection_data($ufiltering) {
|
||||
$scount = count($SESSION->bulk_users);
|
||||
|
||||
$userlist = array('acount'=>$acount, 'scount'=>$scount, 'ausers'=>false, 'susers'=>false, 'total'=>$total);
|
||||
$userlist['ausers'] = $DB->get_records_select_menu('user', $sqlwhere, $params, 'fullname', 'id,'.sql_fullname().' AS fullname', 0, MAX_BULK_USERS);
|
||||
$userlist['ausers'] = $DB->get_records_select_menu('user', $sqlwhere, $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname', 0, MAX_BULK_USERS);
|
||||
|
||||
if ($scount) {
|
||||
if ($scount < MAX_BULK_USERS) {
|
||||
@ -43,7 +43,7 @@ function get_selection_data($ufiltering) {
|
||||
$bulkusers = array_slice($SESSION->bulk_users, 0, MAX_BULK_USERS, true);
|
||||
$in = implode(',', $bulkusers);
|
||||
}
|
||||
$userlist['susers'] = $DB->get_records_select_menu('user', "id IN ($in)", null, 'fullname', 'id,'.sql_fullname().' AS fullname');
|
||||
$userlist['susers'] = $DB->get_records_select_menu('user', "id IN ($in)", null, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname');
|
||||
}
|
||||
|
||||
return $userlist;
|
||||
|
@ -23,8 +23,8 @@ admin_externalpage_print_header();
|
||||
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
$in = implode(',', $SESSION->bulk_users);
|
||||
if ($rs = get_recordset_select('user', "id IN ($in)", '', 'id, username, secret, confirmed, auth, firstname, lastname')) {
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if ($rs = $DB->get_recordset_select('user', "id IN ($in)", null, '', 'id, username, secret, confirmed, auth, firstname, lastname')) {
|
||||
foreach ($rs as $user) {
|
||||
if ($user->confirmed) {
|
||||
continue;
|
||||
}
|
||||
@ -34,13 +34,13 @@ if ($confirm and confirm_sesskey()) {
|
||||
notify(get_string('usernotconfirmed', '', fullname($user, true)));
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
$rs->close();
|
||||
}
|
||||
redirect($return, get_string('changessaved'));
|
||||
|
||||
} else {
|
||||
$in = implode(',', $SESSION->bulk_users);
|
||||
$userlist = get_records_select_menu('user', "id IN ($in)", 'fullname', 'id,'.sql_fullname().' AS fullname');
|
||||
$userlist = $DB->get_records_select_menu('user', "id IN ($in)", null, 'fullname', 'id,'.sql_fullname().' AS fullname');
|
||||
$usernames = implode(', ', $userlist);
|
||||
$optionsyes = array();
|
||||
$optionsyes['confirm'] = 1;
|
||||
|
@ -25,21 +25,21 @@ if ($confirm and confirm_sesskey()) {
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
$in = implode(',', $SESSION->bulk_users);
|
||||
if ($rs = get_recordset_select('user', "id IN ($in)")) {
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if ($rs = $DB->get_recordset_select('user', "id IN ($in)", null)) {
|
||||
foreach ($rs as $user) {
|
||||
if ($primaryadmin->id != $user->id and $USER->id != $user->id and delete_user($user)) {
|
||||
unset($SESSION->bulk_users[$user->id]);
|
||||
} else {
|
||||
notify(get_string('deletednot', '', fullname($user, true)));
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
$rs->close;
|
||||
}
|
||||
redirect($return, get_string('changessaved'));
|
||||
|
||||
} else {
|
||||
$in = implode(',', $SESSION->bulk_users);
|
||||
$userlist = get_records_select_menu('user', "id IN ($in)", 'fullname', 'id,'.sql_fullname().' AS fullname');
|
||||
$userlist = $DB->get_records_select_menu('user', "id IN ($in)", null, 'fullname', 'id,'.sql_fullname().' AS fullname');
|
||||
$usernames = implode(', ', $userlist);
|
||||
$optionsyes = array();
|
||||
$optionsyes['confirm'] = 1;
|
||||
|
@ -25,7 +25,7 @@ admin_externalpage_print_header();
|
||||
$countries = get_list_of_countries();
|
||||
|
||||
foreach ($users as $key => $id) {
|
||||
$user = get_record('user', 'id', $id, null, null, null, null, 'id, firstname, lastname, username, email, country, lastaccess, city');
|
||||
$user = $DB->get_record('user', array('id'=>$id), 'id, firstname, lastname, username, email, country, lastaccess, city');
|
||||
$user->fullname = fullname($user, true);
|
||||
$user->country = @$countries[$user->country];
|
||||
unset($user->firstname);
|
||||
|
@ -37,7 +37,7 @@ if ($format) {
|
||||
'msn' => 'msn',
|
||||
'country' => 'country');
|
||||
|
||||
if ($extrafields = get_records_select('user_info_field')) {
|
||||
if ($extrafields = $DB->get_records_select('user_info_field')) {
|
||||
foreach ($extrafields as $n=>$v){
|
||||
$fields['profile_field_'.$v->shortname] = 'profile_field_'.$v->name;
|
||||
}
|
||||
@ -68,7 +68,7 @@ print_continue($return);
|
||||
print_footer();
|
||||
|
||||
function user_download_ods($fields) {
|
||||
global $CFG, $SESSION;
|
||||
global $CFG, $SESSION, $DB;
|
||||
|
||||
require_once("$CFG->libdir/odslib.class.php");
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
@ -89,7 +89,7 @@ function user_download_ods($fields) {
|
||||
|
||||
$row = 1;
|
||||
foreach ($SESSION->bulk_users as $userid) {
|
||||
if (!$user = get_record('user', 'id', $userid)) {
|
||||
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
continue;
|
||||
}
|
||||
$col = 0;
|
||||
@ -106,7 +106,7 @@ function user_download_ods($fields) {
|
||||
}
|
||||
|
||||
function user_download_xls($fields) {
|
||||
global $CFG, $SESSION;
|
||||
global $CFG, $SESSION, $DB;
|
||||
|
||||
require_once("$CFG->libdir/excellib.class.php");
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
@ -127,7 +127,7 @@ function user_download_xls($fields) {
|
||||
|
||||
$row = 1;
|
||||
foreach ($SESSION->bulk_users as $userid) {
|
||||
if (!$user = get_record('user', 'id', $userid)) {
|
||||
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
continue;
|
||||
}
|
||||
$col = 0;
|
||||
@ -144,7 +144,7 @@ function user_download_xls($fields) {
|
||||
}
|
||||
|
||||
function user_download_csv($fields) {
|
||||
global $CFG, $SESSION;
|
||||
global $CFG, $SESSION, $DB;
|
||||
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
|
||||
@ -167,7 +167,7 @@ function user_download_csv($fields) {
|
||||
|
||||
foreach ($SESSION->bulk_users as $userid) {
|
||||
$row = array();
|
||||
if (!$user = get_record('user', 'id', $userid)) {
|
||||
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
continue;
|
||||
}
|
||||
profile_load_data($user);
|
||||
|
@ -24,10 +24,11 @@ if (empty($CFG->messaging)) {
|
||||
|
||||
if ($confirm and !empty($msg) and confirm_sesskey()) {
|
||||
$in = implode(',', $SESSION->bulk_users);
|
||||
if ($rs = get_recordset_select('user', "id IN ($in)")) {
|
||||
while ($user = rs_fetch_next_record($rs)) {
|
||||
if ($rs = $DB->get_recordset_select('user', "id IN ($in)", null)) {
|
||||
foreach ($rs as $user) {
|
||||
message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct');
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
redirect($return);
|
||||
}
|
||||
@ -51,7 +52,7 @@ if ($msgform->is_cancelled()) {
|
||||
$msg = format_text($formdata->messagebody, $formdata->format, $options);
|
||||
|
||||
$in = implode(',', $SESSION->bulk_users);
|
||||
$userlist = get_records_select_menu('user', "id IN ($in)", 'fullname', 'id,'.sql_fullname().' AS fullname');
|
||||
$userlist = $DB->get_records_select_menu('user', "id IN ($in)", null, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname');
|
||||
$usernames = implode(', ', $userlist);
|
||||
$optionsyes = array();
|
||||
$optionsyes['confirm'] = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user