MDL-15108 Upgrade finished, preliminary tests successful. Please continue testing.

This commit is contained in:
nicolasconnault 2008-06-05 20:16:09 +00:00
parent a656d95103
commit 4e44535526
17 changed files with 976 additions and 831 deletions

View File

@ -34,12 +34,12 @@
function forum_backup_mods($bf,$preferences) {
global $CFG;
global $CFG, $DB;
$status = true;
//Iterate over forum table
$forums = get_records ("forum","course",$preferences->backup_course,"id");
$forums = $DB->get_records ("forum",array("course" => $preferences->backup_course),"id");
if ($forums) {
foreach ($forums as $forum) {
if (backup_mod_selected($preferences,'forum',$forum->id)) {
@ -54,10 +54,10 @@
function forum_backup_one_mod($bf,$preferences,$forum) {
global $CFG;
global $CFG, $DB;
if (is_numeric($forum)) {
$forum = get_record('forum','id',$forum);
$forum = $DB->get_record('forum',array('id'=>$forum));
}
$instanceid = $forum->id;
@ -144,11 +144,11 @@
//Backup forum_subscriptions contents (executed from forum_backup_mods)
function backup_forum_subscriptions ($bf,$preferences,$forum) {
global $CFG;
global $CFG, $DB;
$status = true;
$forum_subscriptions = get_records("forum_subscriptions","forum",$forum,"id");
$forum_subscriptions = $DB->get_records("forum_subscriptions",array("forum" => $forum),"id");
//If there is subscriptions
if ($forum_subscriptions) {
//Write start tag
@ -172,11 +172,11 @@
//Backup forum_discussions contents (executed from forum_backup_mods)
function backup_forum_discussions ($bf,$preferences,$forum) {
global $CFG;
global $CFG, $DB;
$status = true;
$forum_discussions = get_records("forum_discussions","forum",$forum,"id");
$forum_discussions = $DB->get_records("forum_discussions",array("forum" => $forum),"id");
//If there are discussions
if ($forum_discussions) {
//Write start tag
@ -210,11 +210,11 @@
//Backup forum_read contents (executed from forum_backup_mods)
function backup_forum_read ($bf,$preferences,$forum) {
global $CFG;
global $CFG, $DB;
$status = true;
$forum_read = get_records("forum_read","forumid",$forum,"id");
$forum_read = $DB->get_records("forum_read",array("forumid" => $forum),"id");
//If there are read
if ($forum_read) {
//Write start tag
@ -242,11 +242,11 @@
//Backup forum_posts contents (executed from backup_forum_discussions)
function backup_forum_posts ($bf,$preferences,$discussion) {
global $CFG;
global $CFG, $DB;
$status = true;
$forum_posts = get_records("forum_posts","discussion",$discussion,"id");
$forum_posts = $DB->get_records("forum_posts",array("discussion" => $discussion),"id");
//If there are posts
if ($forum_posts) {
//Write start tag
@ -284,11 +284,11 @@
//Backup forum_ratings contents (executed from backup_forum_posts)
function backup_forum_ratings ($bf,$preferences,$post) {
global $CFG;
global $CFG, $DB;
$status = true;
$forum_ratings = get_records("forum_ratings","post",$post,"id");
$forum_ratings = $DB->get_records("forum_ratings",array("post" => $post),"id");
//If there are ratings
if ($forum_ratings) {
//Write start tag
@ -458,110 +458,110 @@
//Returns an array of forums id
function forum_ids ($course) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT a.id, a.course
FROM {$CFG->prefix}forum a
WHERE a.course = '$course'");
return $DB->get_records_sql ("SELECT a.id, a.course
FROM {forum} a
WHERE a.course = ?", array($course));
}
//Returns an array of forum subscriptions id
function forum_subscription_ids_by_course ($course) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_subscriptions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
s.forum = a.id");
return $DB->get_records_sql ("SELECT s.id , s.forum
FROM {forum_subscriptions} s,
{forum} a
WHERE a.course = ? AND
s.forum = a.id", array($course));
}
//Returns an array of forum subscriptions id
function forum_subscription_ids_by_instance($instanceid) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_subscriptions s
WHERE s.forum = $instanceid");
return $DB->get_records_sql ("SELECT s.id , s.forum
FROM {forum_subscriptions} s
WHERE s.forum = ?", array($instanceid));
}
//Returns an array of forum discussions id
function forum_discussion_ids_by_course ($course) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_discussions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
s.forum = a.id");
return $DB->get_records_sql ("SELECT s.id , s.forum
FROM {forum_discussions} s,
{forum} a
WHERE a.course = ? AND
s.forum = a.id", array($course));
}
//Returns an array of forum discussions id
function forum_discussion_ids_by_instance ($instanceid) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_discussions s
WHERE s.forum = $instanceid");
return $DB->get_records_sql ("SELECT s.id , s.forum
FROM {forum_discussions} s
WHERE s.forum = ?", array($instanceid));
}
//Returns an array of forum posts id
function forum_post_ids_by_course ($course) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT p.id , p.discussion, s.forum
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
return $DB->get_records_sql ("SELECT p.id , p.discussion, s.forum
FROM {forum_posts} p,
{forum_discussions} s,
{forum} a
WHERE a.course = ? AND
s.forum = a.id AND
p.discussion = s.id");
p.discussion = s.id", array($course));
}
//Returns an array of forum posts id
function forum_post_ids_by_instance ($instanceid) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT p.id , p.discussion, s.forum
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s
WHERE s.forum = $instanceid AND
p.discussion = s.id");
return $DB->get_records_sql ("SELECT p.id , p.discussion, s.forum
FROM {forum_posts} p,
{forum_discussions} s
WHERE s.forum = ? AND
p.discussion = s.id", array($instanceid));
}
//Returns an array of ratings posts id
function forum_rating_ids_by_course ($course) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT r.id, r.post, p.discussion, s.forum
FROM {$CFG->prefix}forum_ratings r,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s,
{$CFG->prefix}forum a
WHERE a.course = '$course' AND
return $DB->get_records_sql ("SELECT r.id, r.post, p.discussion, s.forum
FROM {forum_ratings} r,
{forum_posts} p,
{forum_discussions} s,
{forum} a
WHERE a.course = ? AND
s.forum = a.id AND
p.discussion = s.id AND
r.post = p.id");
r.post = p.id", array($course));
}
//Returns an array of ratings posts id
function forum_rating_ids_by_instance ($instanceid) {
global $CFG;
global $CFG, $DB;
return get_records_sql ("SELECT r.id, r.post, p.discussion, s.forum
FROM {$CFG->prefix}forum_ratings r,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s
WHERE s.forum = $instanceid AND
return $DB->get_records_sql ("SELECT r.id, r.post, p.discussion, s.forum
FROM {forum_ratings} r,
{forum_posts} p,
{forum_discussions} s
WHERE s.forum = ? AND
p.discussion = s.id AND
r.post = p.id");
r.post = p.id", array($instanceid));
}
?>

View File

@ -51,17 +51,17 @@ function xmldb_forum_upgrade($oldversion=0) {
$roles = get_roles_with_capability('moodle/course:view', CAP_ALLOW);
$roles = array_keys($roles);
$roles = implode(',', $roles);
list($usql, $params) = $DB->get_in_or_equal($roles);
$sql = "SELECT fs.userid, f.id AS forumid
FROM {forum} f
JOIN {course} c ON c.id = f.course
JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = ".CONTEXT_COURSE.")
JOIN {forum_subscriptions} fs ON fs.forum = f.id
LEFT JOIN {role_assignments} ra ON (ra.contextid = ctx.id AND ra.userid = fs.userid AND ra.roleid IN ($roles))
LEFT JOIN {role_assignments} ra ON (ra.contextid = ctx.id AND ra.userid = fs.userid AND ra.roleid $usql)
WHERE ra.id IS NULL";
if ($rs = $DB->get_recordset_sql($sql)) {
if ($rs = $DB->get_recordset_sql($sql, $params)) {
$DB->set_debug(false);
foreach ($rs as $remove) {
$DB->delete_records('forum_subscriptions', array('userid'=>$remove->userid, 'forum'=>$remove->forumid));

View File

@ -13,15 +13,15 @@
$mark = optional_param('mark', '', PARAM_ALPHA); // Used for tracking read posts if user initiated.
$postid = optional_param('postid', 0, PARAM_INT); // Used for tracking read posts if user initiated.
if (!$discussion = get_record('forum_discussions', 'id', $d)) {
if (!$discussion = $DB->get_record('forum_discussions', array('id' => $d))) {
error("Discussion ID was incorrect or no longer exists");
}
if (!$course = get_record('course', 'id', $discussion->course)) {
if (!$course = $DB->get_record('course', array('id' => $discussion->course))) {
error("Course ID is incorrect - discussion is faulty");
}
if (!$forum = get_record('forum', 'id', $discussion->forum)) {
if (!$forum = $DB->get_record('forum', array('id' => $discussion->forum))) {
notify("Bad forum ID stored in this discussion");
}
@ -52,7 +52,7 @@
error('Cannot move discussion from a simple single discussion forum', $return);
}
if (!$forumto = get_record('forum', 'id', $move)) {
if (!$forumto = $DB->get_record('forum', array('id' => $move))) {
error('You can\'t move to that forum - it doesn\'t exist!', $return);
}
@ -67,8 +67,8 @@
if (!forum_move_attachments($discussion, $forumto->id)) {
notify("Errors occurred while moving attachment directories - check your file permissions");
}
set_field('forum_discussions', 'forum', $forumto->id, 'id', $discussion->id);
set_field('forum_read', 'forumid', $forumto->id, 'discussionid', $discussion->id);
$DB->set_field('forum_discussions', 'forum', $forumto->id, array('id' => $discussion->id));
$DB->set_field('forum_read', 'forumid', $forumto->id, array('discussionid' => $discussion->id));
add_to_log($course->id, 'forum', 'move discussion', "discuss.php?d=$discussion->id", $discussion->id, $cmto->id);
require_once($CFG->libdir.'/rsslib.php');

View File

@ -8,7 +8,7 @@
$subscribe = optional_param('subscribe', null, PARAM_INT); // Subscribe/Unsubscribe all forums
if ($id) {
if (! $course = get_record('course', 'id', $id)) {
if (! $course = $DB->get_record('course', array('id' => $id))) {
error("Course ID is incorrect");
}
} else {
@ -80,7 +80,7 @@
// some special ones are not. These get placed in the general forums
// category with the forums in section 0.
$forums = get_records('forum', 'course', $course->id);
$forums = $DB->get_records('forum', array('course' => $course->id));
$generalforums = array();
$learningforums = array();

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,11 @@
$d = optional_param('d',0,PARAM_INT); // Discussion to mark.
$returnpage = optional_param('returnpage', 'index.php', PARAM_FILE); // Page to return to.
if (! $forum = get_record("forum", "id", $f)) {
if (! $forum = $DB->get_record("forum", array("id" => $f))) {
error("Forum ID was incorrect");
}
if (! $course = get_record("course", "id", $forum->course)) {
if (! $course = $DB->get_record("course", array("id" => $forum->course))) {
error("Forum doesn't belong to a course!");
}
@ -52,7 +52,7 @@
if ($mark == 'read') {
if (!empty($d)) {
if (! $discussion = get_record('forum_discussions', 'id', $d, 'forum', $forum->id)) {
if (! $discussion = $DB->get_record('forum_discussions', array('id'=> $d, 'forum'=> $forum->id))) {
error("Discussion ID was incorrect");
}

View File

@ -29,21 +29,21 @@
}
if (!empty($forum)) { // User is starting a new discussion in a forum
if (! $forum = get_record('forum', 'id', $forum)) {
if (! $forum = $DB->get_record('forum', array('id' => $forum))) {
error('The forum number was incorrect');
}
} else if (!empty($reply)) { // User is writing a new reply
if (! $parent = forum_get_post_full($reply)) {
error('Parent post ID was incorrect');
}
if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) {
if (! $discussion = $DB->get_record('forum_discussions', array('id' => $parent->discussion))) {
error('This post is not part of a discussion!');
}
if (! $forum = get_record('forum', 'id', $discussion->forum)) {
if (! $forum = $DB->get_record('forum', array('id' => $discussion->forum))) {
error('The forum number was incorrect');
}
}
if (! $course = get_record('course', 'id', $forum->course)) {
if (! $course = $DB->get_record('course', array('id' => $forum->course))) {
error('The course number was incorrect');
}
@ -69,10 +69,10 @@
require_login(0, false); // Script is useless unless they're logged in
if (!empty($forum)) { // User is starting a new discussion in a forum
if (! $forum = get_record("forum", "id", $forum)) {
if (! $forum = $DB->get_record("forum", array("id" => $forum))) {
error("The forum number was incorrect ($forum)");
}
if (! $course = get_record("course", "id", $forum->course)) {
if (! $course = $DB->get_record("course", array("id" => $forum->course))) {
error("The course number was incorrect ($forum->course)");
}
if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
@ -126,13 +126,13 @@
if (! $parent = forum_get_post_full($reply)) {
error("Parent post ID was incorrect");
}
if (! $discussion = get_record("forum_discussions", "id", $parent->discussion)) {
if (! $discussion = $DB->get_record("forum_discussions", array("id" => $parent->discussion))) {
error("This post is not part of a discussion!");
}
if (! $forum = get_record("forum", "id", $discussion->forum)) {
if (! $forum = $DB->get_record("forum", array("id" => $discussion->forum))) {
error("The forum number was incorrect ($discussion->forum)");
}
if (! $course = get_record("course", "id", $discussion->course)) {
if (! $course = $DB->get_record("course", array("id" => $discussion->course))) {
error("The course number was incorrect ($discussion->course)");
}
if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
@ -198,13 +198,13 @@
}
}
if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
if (! $discussion = $DB->get_record("forum_discussions", array("id" => $post->discussion))) {
error("This post is not part of a discussion! ($edit)");
}
if (! $forum = get_record("forum", "id", $discussion->forum)) {
if (! $forum = $DB->get_record("forum", array("id" => $discussion->forum))) {
error("The forum number was incorrect ($discussion->forum)");
}
if (! $course = get_record("course", "id", $discussion->course)) {
if (! $course = $DB->get_record("course", array("id" => $discussion->course))) {
error("The course number was incorrect ($discussion->course)");
}
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
@ -240,16 +240,16 @@
if (! $post = forum_get_post_full($delete)) {
error("Post ID was incorrect");
}
if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
if (! $discussion = $DB->get_record("forum_discussions", array("id" => $post->discussion))) {
error("This post is not part of a discussion!");
}
if (! $forum = get_record("forum", "id", $discussion->forum)) {
if (! $forum = $DB->get_record("forum", array("id" => $discussion->forum))) {
error("The forum number was incorrect ($discussion->forum)");
}
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) {
error('Could not get the course module for the forum instance.');
}
if (!$course = get_record('course', 'id', $forum->course)) {
if (!$course = $DB->get_record('course', array('id' => $forum->course))) {
error('Incorrect course');
}
@ -346,10 +346,10 @@
if (!$post = forum_get_post_full($prune)) {
error("Post ID was incorrect");
}
if (!$discussion = get_record("forum_discussions", "id", $post->discussion)) {
if (!$discussion = $DB->get_record("forum_discussions", array("id" => $post->discussion))) {
error("This post is not part of a discussion!");
}
if (!$forum = get_record("forum", "id", $discussion->forum)) {
if (!$forum = $DB->get_record("forum", array("id" => $discussion->forum))) {
error("The forum number was incorrect ($discussion->forum)");
}
if ($forum->type == 'single') {
@ -381,7 +381,7 @@
$newdiscussion->timestart = $discussion->timestart;
$newdiscussion->timeend = $discussion->timeend;
if (!$newid = insert_record('forum_discussions', $newdiscussion)) {
if (!$newid = $DB->insert_record('forum_discussions', $newdiscussion)) {
error('Could not create new discussion');
}
@ -390,7 +390,7 @@
$newpost->parent = 0;
$newpost->subject = $name;
if (!update_record("forum_posts", $newpost)) {
if (!$DB->update_record("forum_posts", $newpost)) {
error('Could not update the original post');
}
@ -407,7 +407,7 @@
} else { // User just asked to prune something
$course = get_record('course', 'id', $forum->course);
$course = $DB->get_record('course', array('id' => $forum->course));
$navlinks = array();
$navlinks[] = array('name' => format_string($post->subject, true), 'link' => "discuss.php?d=$discussion->id", 'type' => 'title');
@ -464,7 +464,7 @@
$message = '';
//fix for bug #4314
if (!$realpost = get_record('forum_posts', 'id', $fromform->id)) {
if (!$realpost = $DB->get_record('forum_posts', array('id' => $fromform->id))) {
$realpost = new object;
$realpost->userid = -1;
}
@ -490,7 +490,7 @@
if (($forum->type == 'single') && ($updatepost->parent == '0')){ // updating first post of single discussion type -> updating forum intro
$forum->intro = $updatepost->message;
$forum->timemodified = time();
if (!update_record("forum", $forum)) {
if (!$DB->update_record("forum", $forum)) {
print_error("couldnotupdate", "forum", $errordestination);
}
}
@ -630,7 +630,7 @@
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($post->discussion) {
if (! $toppost = get_record("forum_posts", "discussion", $post->discussion, "parent", 0)) {
if (! $toppost = $DB->get_record("forum_posts", array("discussion" => $post->discussion, "parent" => 0))) {
error("Could not find top parent of post $post->id");
}
} else {
@ -691,7 +691,7 @@
forum_check_throttling($forum, $cm);
if (!empty($parent)) {
if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) {
if (! $discussion = $DB->get_record('forum_discussions', array('id' => $parent->discussion))) {
error('This post is not part of a discussion!');
}

View File

@ -8,11 +8,11 @@
$forumid = required_param('forumid', PARAM_INT); // The forum the rated posts are from
if (!$forum = get_record('forum', 'id', $forumid)) {
if (!$forum = $DB->get_record('forum', array('id' => $forumid))) {
print_error('invalidforumid', 'forum');
}
if (!$course = get_record('course', 'id', $forum->course)) {
if (!$course = $DB->get_record('course', array('id' => $forum->course))) {
print_error('invalidcourseid');
}
@ -46,10 +46,10 @@
// following query validates the submitted postid too
$sql = "SELECT fp.*
FROM {$CFG->prefix}forum_posts fp, {$CFG->prefix}forum_discussions fd
WHERE fp.id = '$postid' AND fp.discussion = fd.id AND fd.forum = $forum->id";
FROM {forum_posts} fp, {forum_discussions} fd
WHERE fp.id = ? AND fp.discussion = fd.id AND fd.forum = ?";
if (!$post = get_record_sql($sql)) {
if (!$post = $DB->get_record_sql($sql, array($postid, $forum->id))) {
print_error('invalidpostid', 'forum', '', $postid);
}
@ -63,14 +63,14 @@
}
if ($rating == FORUM_UNSET_POST_RATING) {
delete_records('forum_ratings', 'post', $postid, 'userid', $USER->id);
$DB->delete_records('forum_ratings', array('post' => $postid, 'userid' => $USER->id));
forum_update_grades($forum, $post->userid);
} else if ($oldrating = get_record('forum_ratings', 'userid', $USER->id, 'post', $post->id)) {
} else if ($oldrating = $DB->get_record('forum_ratings', 'userid', $USER->id, 'post', $post->id)) {
if ($rating != $oldrating->rating) {
$oldrating->rating = $rating;
$oldrating->time = time();
if (! update_record('forum_ratings', $oldrating)) {
if (!$DB->update_record('forum_ratings', $oldrating)) {
print_error('cannotupdaterate', 'forum', '',
array($post->id, $rating));
}
@ -84,7 +84,7 @@
$newrating->post = $post->id;
$newrating->rating = $rating;
if (! insert_record('forum_ratings', $newrating)) {
if (! $DB->insert_record('forum_ratings', $newrating)) {
print_error('cannotinsertrate', 'forum', '',
array($postid, $rating));
}

View File

@ -8,19 +8,19 @@
$id = required_param('id', PARAM_INT);
$sort = optional_param('sort', '', PARAM_ALPHA);
if (! $post = get_record('forum_posts', 'id', $id)) {
if (! $post = $DB->get_record('forum_posts', array('id' => $id))) {
print_error('invalidpostid','forum');
}
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
if (! $discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion))) {
print_error('invaliddiscussion', 'forum');
}
if (! $forum = get_record('forum', 'id', $discussion->forum)) {
if (! $forum = $DB->get_record('forum', array('id' => $discussion->forum))) {
print_error('invalidforumid', 'forum');
}
if (! $course = get_record('course', 'id', $forum->course)) {
if (! $course = $DB->get_record('course', array('id' => $forum->course))) {
print_error('invalidcourseid');
}

View File

@ -6,7 +6,7 @@
//build one XML rss structure.
function forum_rss_feeds() {
global $CFG;
global $CFG, $DB;
$status = true;
@ -19,7 +19,7 @@
//It's working so we start...
} else {
//Iterate over all forums
if ($forums = get_records("forum")) {
if ($forums = $DB->get_records("forum")) {
foreach ($forums as $forum) {
if (!empty($forum->rsstype) && !empty($forum->rssarticles) && $status) {
@ -149,7 +149,7 @@
//for a Type=discussions forum
function forum_rss_feed_discussions($forum, $newsince=0) {
global $CFG;
global $CFG, $DB;
$items = array();
@ -159,7 +159,7 @@
$newsince = "";
}
if ($recs = get_records_sql ("SELECT d.id AS discussionid,
if ($recs = $DB->get_records_sql ("SELECT d.id AS discussionid,
d.name AS discussionname,
u.id AS userid,
u.firstname AS userfirstname,
@ -167,14 +167,15 @@
p.message AS postmessage,
p.created AS postcreated,
p.format AS postformat
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
FROM {forum_discussions} d,
{forum_posts} p,
{user} u
WHERE d.forum = '$forum->id' AND
p.discussion = d.id AND
p.parent = 0 AND
u.id = p.userid $newsince
ORDER BY p.created desc", 0, $forum->rssarticles)) {
ORDER BY p.created desc",
array($forum->id, $newsince), 0, $forum->rssarticles)) {
$item = NULL;
$user = NULL;
@ -202,7 +203,7 @@
//for a Type=posts forum
function forum_rss_feed_posts($forum, $newsince=0) {
global $CFG;
global $CFG, $DB;
$items = array();
@ -212,7 +213,7 @@
$newsince = "";
}
if ($recs = get_records_sql ("SELECT p.id AS postid,
if ($recs = $DB->get_records_sql ("SELECT p.id AS postid,
d.id AS discussionid,
d.name AS discussionname,
u.id AS userid,
@ -222,13 +223,13 @@
p.message AS postmessage,
p.created AS postcreated,
p.format AS postformat
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}user u
WHERE d.forum = '$forum->id' AND
FROM {forum_discussions} d,
{forum_posts} p,
{user} u
WHERE d.forum = ? AND
p.discussion = d.id AND
u.id = p.userid $newsince
ORDER BY p.created desc", 0, $forum->rssarticles)) {
u.id = p.userid ?
ORDER BY p.created desc", array($forum->id, $newsince), 0, $forum->rssarticles)) {
$item = NULL;
$user = NULL;

View File

@ -181,10 +181,10 @@
// Replace the simple subject with the three items forum name -> thread name -> subject
// (if all three are appropriate) each as a link.
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
if (! $discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion))) {
error('Discussion ID was incorrect');
}
if (! $forum = get_record('forum', 'id', "$discussion->forum")) {
if (! $forum = $DB->get_record('forum', array('id' => "$discussion->forum"))) {
error("Could not find forum $discussion->forum");
}

View File

@ -8,11 +8,11 @@
$id = required_param('id',PARAM_INT); // The forum to subscribe or unsubscribe to
$returnpage = optional_param('returnpage', 'index.php', PARAM_FILE); // Page to return to.
if (! $forum = get_record("forum", "id", $id)) {
if (! $forum = $DB->get_record("forum", array("id" => $id))) {
error("Forum ID was incorrect");
}
if (! $course = get_record("course", "id", $forum->course)) {
if (! $course = $DB->get_record("course", array("id" => $forum->course))) {
error("Forum doesn't belong to a course!");
}

View File

@ -9,11 +9,11 @@
$force = optional_param('force','',PARAM_ALPHA); // Force everyone to be subscribed to this forum?
$user = optional_param('user',0,PARAM_INT);
if (! $forum = get_record("forum", "id", $id)) {
if (! $forum = $DB->get_record("forum", array("id" => $id))) {
error("Forum ID was incorrect");
}
if (! $course = get_record("course", "id", $forum->course)) {
if (! $course = $DB->get_record("course", array("id" => $forum->course))) {
error("Forum doesn't belong to a course!");
}
@ -28,7 +28,7 @@
if (!has_capability('mod/forum:managesubscriptions', $context)) {
error('You do not have the permission to subscribe/unsubscribe other people!');
}
if (!$user = get_record("user", "id", $user)) {
if (!$user = $DB->get_record("user", array("id" => $user))) {
error("User ID was incorrect");
}
} else {

View File

@ -17,11 +17,11 @@
$id = $USER->id;
}
if (! $user = get_record("user", "id", $id)) {
if (! $user = $DB->get_record("user", array("id" => $id))) {
error("User ID is incorrect");
}
if (! $course = get_record("course", "id", $course)) {
if (! $course = $DB->get_record("course", array("id" => $course))) {
error("Course id is incorrect.");
}
@ -29,7 +29,7 @@
$usercontext = get_context_instance(CONTEXT_USER, $id);
// do not force parents to enrol
if (!get_record('role_assignments', 'userid', $USER->id, 'contextid', $usercontext->id)) {
if (!$DB->get_record('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id))) {
require_course_login($course);
}
@ -99,7 +99,7 @@
foreach ($posts as $post) {
if (!isset($discussions[$post->discussion])) {
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
if (! $discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion))) {
error('Discussion ID was incorrect');
}
$discussions[$post->discussion] = $discussion;
@ -108,7 +108,7 @@
}
if (!isset($forums[$discussion->forum])) {
if (! $forum = get_record('forum', 'id', $discussion->forum)) {
if (! $forum = $DB->get_record('forum', array('id' => $discussion->forum))) {
error("Could not find forum $discussion->forum");
}
$forums[$discussion->forum] = $forum;
@ -144,7 +144,7 @@
}
if ($course->id == SITEID && has_capability('moodle/site:config', $syscontext)) {
$postcoursename = get_field('course', 'shortname', 'id', $forum->course);
$postcoursename = $DB->get_field('course', array('shortname' => 'id'), $forum->course);
$fullsubject = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$forum->course.'">'.$postcoursename.'</a> -> '. $fullsubject;
}

View File

@ -20,10 +20,10 @@
if (! $cm = get_coursemodule_from_id('forum', $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
error("Course is misconfigured");
}
if (! $forum = get_record("forum", "id", $cm->instance)) {
if (! $forum = $DB->get_record("forum", array("id" => $cm->instance))) {
error("Forum ID was incorrect");
}
$strforums = get_string("modulenameplural", "forum");
@ -32,10 +32,10 @@
} else if ($f) {
if (! $forum = get_record("forum", "id", $f)) {
if (! $forum = $DB->get_record("forum", array("id" => $f))) {
error("Forum ID was incorrect or no longer exists");
}
if (! $course = get_record("course", "id", $forum->course)) {
if (! $course = $DB->get_record("course", array("id" => $forum->course))) {
error("Forum is misconfigured - don't know what course it's from");
}
@ -94,8 +94,8 @@
// If it's a simple single discussion forum, we need to print the display
// mode control.
if ($forum->type == 'single') {
if (! $discussion = get_record("forum_discussions", "forum", $forum->id)) {
if ($discussions = get_records("forum_discussions", "forum", $forum->id, "timemodified ASC")) {
if (! $discussion = $DB->get_record("forum_discussions", array("forum" => $forum->id))) {
if ($discussions = $DB->get_records("forum_discussions", array("forum", $forum->id), "timemodified ASC")) {
$discussion = array_pop($discussions);
}
}
@ -205,8 +205,8 @@
switch ($forum->type) {
case 'single':
if (! $discussion = get_record("forum_discussions", "forum", $forum->id)) {
if ($discussions = get_records("forum_discussions", "forum", $forum->id, "timemodified ASC")) {
if (! $discussion = $DB->get_record("forum_discussions", array("forum" => $forum->id))) {
if ($discussions = $DB->get_records("forum_discussions", array("forum" => $forum->id), "timemodified ASC")) {
notify("Warning! There is more than one discussion in this forum - using the most recent");
$discussion = array_pop($discussions);
} else {