]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14679 towards /admin/user conversion
authorskodak <skodak>
Sat, 31 May 2008 09:50:46 +0000 (09:50 +0000)
committerskodak <skodak>
Sat, 31 May 2008 09:50:46 +0000 (09:50 +0000)
admin/user/lib.php
admin/user/user_bulk_confirm.php
admin/user/user_bulk_delete.php
admin/user/user_bulk_display.php
admin/user/user_bulk_download.php
admin/user/user_bulk_message.php

index 3167b40eb3665210b9a8a5fb1a4287bd4a509513..d0c84777001b1296c51f8f520ecbafe321f8a63b 100644 (file)
@@ -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;
index fe0a8bfbaa7b60f0d3a0732fe1047a89ac0673ba..1bf5af41aff8e3723cf24f55d6443b43199aa22a 100755 (executable)
@@ -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;
index 413c8330781e43241252400086e60b4e88886275..6880cbc7bd4e7ba0de9c814cb75a9231e0c1de73 100755 (executable)
@@ -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;
index 97d36f3f479e6310f91042b28de1d60a4f695212..2adbc7ec21f81051880bf25d44cdc1965e42ced1 100755 (executable)
@@ -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);
index 5eac189c2f0c0739a7beae0541692b7f4ab7648c..a93ba17786eadad347477282e7d41c698396e9da 100755 (executable)
@@ -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);
index d32ee227d4fd81f6d976c4ac2ad23250073cfae9..bac02b6c7146d1e4b222592c2671686e2d3dbfc1 100755 (executable)
@@ -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;