mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-25708 recordsets - fix admin dir uses
This commit is contained in:
parent
8cdc85ac62
commit
755d2c74f6
@ -56,35 +56,34 @@ foreach ($tables as $table) {
|
||||
if (in_array($data->type, array('text','mediumtext','longtext','varchar'))) { // Text stuff only
|
||||
// first find candidate records
|
||||
$sql = "SELECT id, $column FROM $fulltable WHERE $column LIKE '%</lang>%' OR $column LIKE '%<span lang=%'";
|
||||
if ($rs = $DB->get_recordset_sql($sql)) {
|
||||
foreach ($rs as $data) {
|
||||
$text = $data->$column;
|
||||
$id = $data->id;
|
||||
if ($i % 600 == 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
if ($i % 10 == 0) {
|
||||
echo '.';
|
||||
}
|
||||
$i++;
|
||||
|
||||
if (empty($text) or is_numeric($text)) {
|
||||
continue; // nothing to do
|
||||
}
|
||||
|
||||
$search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)(\s*<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)+/is';
|
||||
$newtext = preg_replace_callback($search, 'multilangupgrade_impl', $text);
|
||||
|
||||
if (is_null($newtext)) {
|
||||
continue; // regex error
|
||||
}
|
||||
|
||||
if ($newtext != $text) {
|
||||
$DB->execute("UPDATE $fulltable SET $column=? WHERE id=?", array($newtext, $id));
|
||||
}
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $data) {
|
||||
$text = $data->$column;
|
||||
$id = $data->id;
|
||||
if ($i % 600 == 0) {
|
||||
echo '<br />';
|
||||
}
|
||||
if ($i % 10 == 0) {
|
||||
echo '.';
|
||||
}
|
||||
$i++;
|
||||
|
||||
if (empty($text) or is_numeric($text)) {
|
||||
continue; // nothing to do
|
||||
}
|
||||
|
||||
$search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)(\s*<(?:lang|span) lang="[a-zA-Z0-9_-]*".*?>.+?<\/(?:lang|span)>)+/is';
|
||||
$newtext = preg_replace_callback($search, 'multilangupgrade_impl', $text);
|
||||
|
||||
if (is_null($newtext)) {
|
||||
continue; // regex error
|
||||
}
|
||||
|
||||
if ($newtext != $text) {
|
||||
$DB->execute("UPDATE $fulltable SET $column=? WHERE id=?", array($newtext, $id));
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
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 = $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->close();
|
||||
}
|
||||
|
||||
function get_selection_data($ufiltering) {
|
||||
|
@ -24,19 +24,18 @@ echo $OUTPUT->header();
|
||||
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
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')) {
|
||||
foreach ($rs as $user) {
|
||||
if ($user->confirmed) {
|
||||
continue;
|
||||
}
|
||||
$auth = get_auth_plugin($user->auth);
|
||||
$result = $auth->user_confirm($user->username, $user->secret);
|
||||
if ($result != AUTH_CONFIRM_OK && $result != AUTH_CONFIRM_ALREADY) {
|
||||
echo $OUTPUT->notification(get_string('usernotconfirmed', '', fullname($user, true)));
|
||||
}
|
||||
$rs = $DB->get_recordset_select('user', "id $in", $params, '', 'id, username, secret, confirmed, auth, firstname, lastname');
|
||||
foreach ($rs as $user) {
|
||||
if ($user->confirmed) {
|
||||
continue;
|
||||
}
|
||||
$auth = get_auth_plugin($user->auth);
|
||||
$result = $auth->user_confirm($user->username, $user->secret);
|
||||
if ($result != AUTH_CONFIRM_OK && $result != AUTH_CONFIRM_ALREADY) {
|
||||
echo $OUTPUT->notification(get_string('usernotconfirmed', '', fullname($user, true)));
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
$rs->close();
|
||||
redirect($return, get_string('changessaved'));
|
||||
|
||||
} else {
|
||||
|
@ -25,16 +25,15 @@ echo $OUTPUT->header();
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
|
||||
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
|
||||
if ($rs = $DB->get_recordset_select('user', "id $in", $params)) {
|
||||
foreach ($rs as $user) {
|
||||
if (!is_siteadmin($user) and $USER->id != $user->id and delete_user($user)) {
|
||||
unset($SESSION->bulk_users[$user->id]);
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('deletednot', '', fullname($user, true)));
|
||||
}
|
||||
$rs = $DB->get_recordset_select('user', "id $in", $params);
|
||||
foreach ($rs as $user) {
|
||||
if (!is_siteadmin($user) and $USER->id != $user->id and delete_user($user)) {
|
||||
unset($SESSION->bulk_users[$user->id]);
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('deletednot', '', fullname($user, true)));
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
$rs->close();
|
||||
session_gc(); // remove stale sessions
|
||||
redirect($return, get_string('changessaved'));
|
||||
|
||||
|
@ -38,17 +38,16 @@ if ($confirm and confirm_sesskey()) {
|
||||
$parts = array_chunk($SESSION->bulk_users, 300);
|
||||
foreach ($parts as $users) {
|
||||
list($in, $params) = $DB->get_in_or_equal($users);
|
||||
if ($rs = $DB->get_recordset_select('user', "id $in", $params)) {
|
||||
foreach ($rs as $user) {
|
||||
if (!empty($changeable[$user->auth])) {
|
||||
set_user_preference('auth_forcepasswordchange', 1, $user->id);
|
||||
unset($SESSION->bulk_users[$user->id]);
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('forcepasswordchangenot', '', fullname($user, true)));
|
||||
}
|
||||
$rs = $DB->get_recordset_select('user', "id $in", $params);
|
||||
foreach ($rs as $user) {
|
||||
if (!empty($changeable[$user->auth])) {
|
||||
set_user_preference('auth_forcepasswordchange', 1, $user->id);
|
||||
unset($SESSION->bulk_users[$user->id]);
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('forcepasswordchangenot', '', fullname($user, true)));
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($return);
|
||||
|
@ -25,15 +25,14 @@ if (empty($CFG->messaging)) {
|
||||
|
||||
if ($confirm and !empty($msg) and confirm_sesskey()) {
|
||||
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
|
||||
if ($rs = $DB->get_recordset_select('user', "id $in", $params)) {
|
||||
foreach ($rs as $user) {
|
||||
//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
|
||||
//so we have to use html format for it to be displayed correctly
|
||||
message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct');
|
||||
}
|
||||
$rs->close();
|
||||
$rs = $DB->get_recordset_select('user', "id $in", $params);
|
||||
foreach ($rs as $user) {
|
||||
//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
|
||||
//so we have to use html format for it to be displayed correctly
|
||||
message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct');
|
||||
}
|
||||
$rs->close();
|
||||
redirect($return);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user