MDL-25708 recordsets - fix admin dir uses

This commit is contained in:
Eloy Lafuente (stronk7) 2010-12-30 00:41:47 +01:00
parent 8cdc85ac62
commit 755d2c74f6
6 changed files with 63 additions and 69 deletions

View file

@ -56,7 +56,7 @@ foreach ($tables as $table) {
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
// first find candidate records // first find candidate records
$sql = "SELECT id, $column FROM $fulltable WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'"; $sql = "SELECT id, $column FROM $fulltable WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'";
if ($rs = $DB->get_recordset_sql($sql)) { $rs = $DB->get_recordset_sql($sql);
foreach ($rs as $data) { foreach ($rs as $data) {
$text = $data->$column; $text = $data->$column;
$id = $data->id; $id = $data->id;
@ -87,7 +87,6 @@ foreach ($tables as $table) {
} }
} }
} }
}
} }
// set conversion flag - switches to new plugin automatically // set conversion flag - switches to new plugin automatically

View file

@ -11,14 +11,13 @@ function add_selection_all($ufiltering) {
list($sqlwhere, $params) = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$CFG->siteguest)); list($sqlwhere, $params) = $ufiltering->get_sql_filter("id<>:exguest AND deleted <> 1", array('exguest'=>$CFG->siteguest));
if ($rs = $DB->get_recordset_select('user', $sqlwhere, $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname')) { $rs = $DB->get_recordset_select('user', $sqlwhere, $params, 'fullname', 'id,'.$DB->sql_fullname().' AS fullname');
foreach ($rs as $user) { foreach ($rs as $user) {
if (!isset($SESSION->bulk_users[$user->id])) { if (!isset($SESSION->bulk_users[$user->id])) {
$SESSION->bulk_users[$user->id] = $user->id; $SESSION->bulk_users[$user->id] = $user->id;
} }
} }
$rs->close(); $rs->close();
}
} }
function get_selection_data($ufiltering) { function get_selection_data($ufiltering) {

View file

@ -24,7 +24,7 @@ echo $OUTPUT->header();
if ($confirm and confirm_sesskey()) { if ($confirm and confirm_sesskey()) {
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
if ($rs = $DB->get_recordset_select('user', "id $in", $params, '', 'id, username, secret, confirmed, auth, firstname, lastname')) { $rs = $DB->get_recordset_select('user', "id $in", $params, '', 'id, username, secret, confirmed, auth, firstname, lastname');
foreach ($rs as $user) { foreach ($rs as $user) {
if ($user->confirmed) { if ($user->confirmed) {
continue; continue;
@ -36,7 +36,6 @@ if ($confirm and confirm_sesskey()) {
} }
} }
$rs->close(); $rs->close();
}
redirect($return, get_string('changessaved')); redirect($return, get_string('changessaved'));
} else { } else {

View file

@ -25,7 +25,7 @@ echo $OUTPUT->header();
if ($confirm and confirm_sesskey()) { if ($confirm and confirm_sesskey()) {
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
if ($rs = $DB->get_recordset_select('user', "id $in", $params)) { $rs = $DB->get_recordset_select('user', "id $in", $params);
foreach ($rs as $user) { foreach ($rs as $user) {
if (!is_siteadmin($user) and $USER->id != $user->id and delete_user($user)) { if (!is_siteadmin($user) and $USER->id != $user->id and delete_user($user)) {
unset($SESSION->bulk_users[$user->id]); unset($SESSION->bulk_users[$user->id]);
@ -34,7 +34,6 @@ if ($confirm and confirm_sesskey()) {
} }
} }
$rs->close(); $rs->close();
}
session_gc(); // remove stale sessions session_gc(); // remove stale sessions
redirect($return, get_string('changessaved')); redirect($return, get_string('changessaved'));

View file

@ -38,7 +38,7 @@ if ($confirm and confirm_sesskey()) {
$parts = array_chunk($SESSION->bulk_users, 300); $parts = array_chunk($SESSION->bulk_users, 300);
foreach ($parts as $users) { foreach ($parts as $users) {
list($in, $params) = $DB->get_in_or_equal($users); list($in, $params) = $DB->get_in_or_equal($users);
if ($rs = $DB->get_recordset_select('user', "id $in", $params)) { $rs = $DB->get_recordset_select('user', "id $in", $params);
foreach ($rs as $user) { foreach ($rs as $user) {
if (!empty($changeable[$user->auth])) { if (!empty($changeable[$user->auth])) {
set_user_preference('auth_forcepasswordchange', 1, $user->id); set_user_preference('auth_forcepasswordchange', 1, $user->id);
@ -49,7 +49,6 @@ if ($confirm and confirm_sesskey()) {
} }
$rs->close(); $rs->close();
} }
}
echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
echo $OUTPUT->continue_button($return); echo $OUTPUT->continue_button($return);

View file

@ -25,7 +25,7 @@ if (empty($CFG->messaging)) {
if ($confirm and !empty($msg) and confirm_sesskey()) { if ($confirm and !empty($msg) and confirm_sesskey()) {
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users); list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
if ($rs = $DB->get_recordset_select('user', "id $in", $params)) { $rs = $DB->get_recordset_select('user', "id $in", $params);
foreach ($rs as $user) { foreach ($rs as $user) {
//TODO we should probably support all text formats here or only FORMAT_MOODLE //TODO we should probably support all text formats here or only FORMAT_MOODLE
//For now bulk messaging is still using the html editor and its supplying html //For now bulk messaging is still using the html editor and its supplying html
@ -33,7 +33,6 @@ if ($confirm and !empty($msg) and confirm_sesskey()) {
message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct'); message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct');
} }
$rs->close(); $rs->close();
}
redirect($return); redirect($return);
} }