Permalink
Browse files

Merge branch 'MDL-25708' of git://github.com/stronk7/moodle

  • Loading branch information...
skodak committed Jan 31, 2011
2 parents 43bbf28 + cc65dc3 commit 8afc38bd39afada5b76e426ec99243291007352c
Showing with 513 additions and 525 deletions.
  1. +26 −27 admin/multilangupgrade.php
  2. +5 −6 admin/user/lib.php
  3. +10 −11 admin/user/user_bulk_confirm.php
  4. +7 −8 admin/user/user_bulk_delete.php
  5. +8 −9 admin/user/user_bulk_forcepasswordchange.php
  6. +7 −8 admin/user/user_bulk_message.php
  7. +8 −9 course/lib.php
  8. +4 −3 course/user.php
  9. +4 −2 enrol/authorize/localfuncs.php
  10. +4 −5 grade/report/user/lib.php
  11. +17 −18 group/overview.php
  12. +38 −46 lib/accesslib.php
  13. +5 −7 lib/completion/completion_criteria_activity.php
  14. +5 −7 lib/completion/completion_criteria_course.php
  15. +5 −8 lib/completion/completion_criteria_date.php
  16. +9 −12 lib/completion/completion_criteria_duration.php
  17. +5 −8 lib/completion/completion_criteria_grade.php
  18. +9 −3 lib/completion/cron.php
  19. +33 −37 lib/datalib.php
  20. +23 −24 lib/db/upgradelib.php
  21. +4 −6 lib/dml/moodle_database.php
  22. +6 −7 lib/dml/oci_native_moodle_database.php
  23. +6 −2 lib/dml/pdo_moodle_database.php
  24. +16 −17 lib/eventslib.php
  25. +4 −1 lib/filestorage/file_storage.php
  26. +3 −2 lib/grade/grade_category.php
  27. +6 −7 lib/grade/grade_grade.php
  28. +3 −2 lib/grade/grade_item.php
  29. +17 −20 lib/gradelib.php
  30. +4 −1 lib/grouplib.php
  31. +16 −19 lib/moodlelib.php
  32. +15 −20 message/lib.php
  33. +3 −4 mod/assignment/db/upgrade.php
  34. +3 −2 mod/assignment/lib.php
  35. +35 −33 mod/data/db/upgrade.php
  36. +34 −33 mod/data/lib.php
  37. +5 −2 mod/folder/db/upgradelib.php
  38. +3 −2 mod/forum/db/upgrade.php
  39. +3 −2 mod/forum/lib.php
  40. +24 −23 mod/glossary/db/upgrade.php
  41. +6 −4 mod/glossary/lib.php
  42. +3 −2 mod/imscp/db/upgradelib.php
  43. +3 −2 mod/lesson/lib.php
  44. +13 −15 mod/page/db/upgradelib.php
  45. +3 −2 mod/quiz/lib.php
  46. +10 −10 mod/resource/db/upgrade.php
  47. +3 −1 mod/resource/db/upgradelib.php
  48. +3 −2 mod/scorm/db/upgrade.php
  49. +3 −2 mod/scorm/lib.php
  50. +9 −7 mod/survey/lib.php
  51. +4 −2 mod/url/db/upgradelib.php
  52. +7 −8 tag/lib.php
  53. +4 −5 user/selector/lib.php
View
@@ -56,35 +56,34 @@
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();
}
}
}
View
@@ -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 @@
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 @@
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 @@
$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 ($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);
}
View
@@ -1757,17 +1757,16 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
@set_time_limit(0); // this could take a while! MDL-10954
}
- if ($rs = $DB->get_recordset("course", $select,'','id,fullname')) {
- foreach ($rs as $course) {
- $modinfo = serialize(get_array_of_activities($course->id));
- $DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id));
- // update cached global COURSE too ;-)
- if ($course->id == $COURSE->id) {
- $COURSE->modinfo = $modinfo;
- }
+ $rs = $DB->get_recordset("course", $select,'','id,fullname');
+ foreach ($rs as $course) {
+ $modinfo = serialize(get_array_of_activities($course->id));
+ $DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id));
+ // update cached global COURSE too ;-)
+ if ($course->id == $COURSE->id) {
+ $COURSE->modinfo = $modinfo;
}
- $rs->close();
}
+ $rs->close();
// reset the fast modinfo cache
$reset = 'reset';
get_fast_modinfo($reset);
View
@@ -400,7 +400,8 @@
}
// Check if result is empty
- if (!$rs = $DB->get_recordset_sql($sql)) {
+ $rs = $DB->get_recordset_sql($sql);
+ if (!$rs->valid()) {
if ($course->id != 1) {
$error = get_string('nocompletions', 'coursereport_completion');
@@ -409,6 +410,7 @@
}
echo $OUTPUT->notification($error);
+ $rs->close(); // not going to loop (but break), close rs
break;
}
@@ -437,8 +439,7 @@
$courses['unstarted'][] = $c_info;
}
}
-
- $rs->close();
+ $rs->close(); // after loop, close rs
// Loop through course status groups
foreach ($courses as $type => $infos) {
@@ -194,7 +194,9 @@ function send_welcome_messages($orderdata) {
WHERE e.id IN(" . implode(',', $orderdata) . ")
ORDER BY e.userid";
- if (!$rs = $DB->get_recordset_sql($sql)) {
+ $rs = $DB->get_recordset_sql($sql);
+ if (!$rs->valid()) {
+ $rs->close(); // Not going to iterate (but exit), close rs
return;
}
@@ -247,7 +249,7 @@ function send_welcome_messages($orderdata) {
}
while ($ei);
- $rs->close();
+ $rs->close(); // end of iteration, close rs
}
}
@@ -634,12 +634,11 @@ function calculate_averages() {
GROUP BY gg.itemid";
$sum_array = array();
- if ($sums = $DB->get_recordset_sql($sql, $params)) {
- foreach ($sums as $itemid => $csum) {
- $sum_array[$itemid] = $csum->sum;
- }
- $sums->close();
+ $sums = $DB->get_recordset_sql($sql, $params);
+ foreach ($sums as $itemid => $csum) {
+ $sum_array[$itemid] = $csum->sum;
}
+ $sums->close();
$columncount=0;
View
@@ -80,26 +80,25 @@
WHERE g.courseid = :courseid $groupwhere $groupingwhere
ORDER BY g.name, u.lastname, u.firstname";
-if ($rs = $DB->get_recordset_sql($sql, $params)) {
- foreach ($rs as $row) {
- $user = new stdClass();
- $user->id = $row->userid;
- $user->firstname = $row->firstname;
- $user->lastname = $row->lastname;
- $user->username = $row->username;
- $user->idnumber = $row->idnumber;
- if (!$row->groupingid) {
- $row->groupingid = -1;
- }
- if (!array_key_exists($row->groupid, $members[$row->groupingid])) {
- $members[$row->groupingid][$row->groupid] = array();
- }
- if(isset($user->id)){
- $members[$row->groupingid][$row->groupid][] = $user;
- }
+$rs = $DB->get_recordset_sql($sql, $params);
+foreach ($rs as $row) {
+ $user = new stdClass();
+ $user->id = $row->userid;
+ $user->firstname = $row->firstname;
+ $user->lastname = $row->lastname;
+ $user->username = $row->username;
+ $user->idnumber = $row->idnumber;
+ if (!$row->groupingid) {
+ $row->groupingid = -1;
+ }
+ if (!array_key_exists($row->groupid, $members[$row->groupingid])) {
+ $members[$row->groupingid][$row->groupid] = array();
+ }
+ if(isset($user->id)){
+ $members[$row->groupingid][$row->groupid][] = $user;
}
- $rs->close();
}
+$rs->close();
navigation_node::override_active_url(new moodle_url('/group/index.php', array('id'=>$courseid)));
$PAGE->navbar->add(get_string('overview', 'group'));
Oops, something went wrong.

0 comments on commit 8afc38b

Please sign in to comment.