mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-15108 Upgrade finished, preliminary tests successful. Please continue testing.
This commit is contained in:
parent
a656d95103
commit
4e44535526
@ -4,10 +4,10 @@
|
||||
|
||||
//This is the "graphical" structure of the forum mod:
|
||||
//
|
||||
// forum
|
||||
// forum
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// ---------------------------------------------------
|
||||
// ---------------------------------------------------
|
||||
// | |
|
||||
// subscriptions forum_discussions
|
||||
//(UL,pk->id, fk->forum) ---------------(UL,pk->id, fk->forum)
|
||||
@ -16,7 +16,7 @@
|
||||
// | |
|
||||
// | forum_posts
|
||||
// |-------------(UL,pk->id,fk->discussion,
|
||||
// | nt->parent,files)
|
||||
// | nt->parent,files)
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
@ -33,13 +33,13 @@
|
||||
//-----------------------------------------------------------
|
||||
|
||||
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)) {
|
||||
@ -53,19 +53,19 @@
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
$status = true;
|
||||
|
||||
|
||||
//Start mod
|
||||
fwrite ($bf,start_tag("MOD",3,true));
|
||||
|
||||
|
||||
//Print forum data
|
||||
fwrite ($bf,full_tag("ID",4,false,$forum->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"forum"));
|
||||
@ -85,7 +85,7 @@
|
||||
fwrite ($bf,full_tag("WARNAFTER",4,false,$forum->warnafter));
|
||||
fwrite ($bf,full_tag("BLOCKAFTER",4,false,$forum->blockafter));
|
||||
fwrite ($bf,full_tag("BLOCKPERIOD",4,false,$forum->blockperiod));
|
||||
|
||||
|
||||
//if we've selected to backup users info, then execute backup_forum_suscriptions and
|
||||
//backup_forum_discussions
|
||||
if (backup_userdata_selected($preferences,'forum',$forum->id)) {
|
||||
@ -141,14 +141,14 @@
|
||||
return $info;
|
||||
}
|
||||
|
||||
//Backup forum_subscriptions contents (executed from forum_backup_mods)
|
||||
function backup_forum_subscriptions ($bf,$preferences,$forum) {
|
||||
//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
|
||||
@ -207,14 +207,14 @@
|
||||
return $status;
|
||||
}
|
||||
|
||||
//Backup forum_read contents (executed from forum_backup_mods)
|
||||
function backup_forum_read ($bf,$preferences,$forum) {
|
||||
//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
|
||||
@ -368,7 +368,7 @@
|
||||
|
||||
////Return an array of info (name,value)
|
||||
function forum_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
|
||||
|
||||
|
||||
if (!empty($instances) && is_array($instances) && count($instances)) {
|
||||
$info = array();
|
||||
foreach ($instances as $id => $instance) {
|
||||
@ -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
|
||||
//Returns an array of forum subscriptions id
|
||||
function forum_subscription_ids_by_instance($instanceid) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.forum
|
||||
FROM {$CFG->prefix}forum_subscriptions s
|
||||
WHERE s.forum = $instanceid");
|
||||
|
||||
global $CFG, $DB;
|
||||
|
||||
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) {
|
||||
//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
|
||||
s.forum = a.id 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) {
|
||||
//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));
|
||||
}
|
||||
?>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php //$Id$
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// This file keeps track of upgrades to
|
||||
// the forum module
|
||||
//
|
||||
// Sometimes, changes between versions involve
|
||||
@ -23,8 +23,8 @@ function xmldb_forum_upgrade($oldversion=0) {
|
||||
|
||||
$result = true;
|
||||
|
||||
/// And upgrade begins here. For each one, you'll need one
|
||||
/// block of code similar to the next one. Please, delete
|
||||
/// And upgrade begins here. For each one, you'll need one
|
||||
/// block of code similar to the next one. Please, delete
|
||||
/// this comment lines once this file start handling proper
|
||||
/// upgrade code.
|
||||
|
||||
@ -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));
|
||||
|
@ -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');
|
||||
|
@ -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();
|
||||
|
1392
mod/forum/lib.php
1392
mod/forum/lib.php
File diff suppressed because it is too large
Load Diff
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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!');
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
//This is the "graphical" structure of the forum mod:
|
||||
//
|
||||
// forum
|
||||
// forum
|
||||
// (CL,pk->id)
|
||||
// |
|
||||
// ---------------------------------------------------
|
||||
// ---------------------------------------------------
|
||||
// | |
|
||||
// subscriptions forum_discussions
|
||||
//(UL,pk->id, fk->forum) ---------------(UL,pk->id, fk->forum)
|
||||
@ -16,7 +16,7 @@
|
||||
// | |
|
||||
// | forum_posts
|
||||
// |-------------(UL,pk->id,fk->discussion,
|
||||
// | nt->parent,files)
|
||||
// | nt->parent,files)
|
||||
// | |
|
||||
// | |
|
||||
// | |
|
||||
@ -56,7 +56,7 @@
|
||||
$forum->type = backup_todb($info['MOD']['#']['TYPE']['0']['#']);
|
||||
$forum->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
|
||||
$forum->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
|
||||
|
||||
|
||||
// These get dropped in Moodle 1.7 when the new Roles System gets
|
||||
// set up. Therefore they might or not be there depending on whether
|
||||
// we are restoring a 1.6+ forum or a 1.7 or later forum backup.
|
||||
@ -66,8 +66,8 @@
|
||||
if (isset($info['MOD']['#']['ASSESSPUBLIC']['0']['#'])) {
|
||||
$forum->assesspublic = backup_todb($info['MOD']['#']['ASSESSPUBLIC']['0']['#']);
|
||||
}
|
||||
|
||||
$forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
|
||||
|
||||
$forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
|
||||
$forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
|
||||
$forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
|
||||
$forum->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
|
||||
@ -89,7 +89,7 @@
|
||||
$forum->scale = -($scale->new_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$newid = $DB->insert_record("forum", $forum);
|
||||
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
$DB->set_field ('forum_posts','mailed', '1', array('discussion'=>$sdid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
@ -159,7 +159,7 @@
|
||||
if (isset($forum->open) && isset($forum->assesspublic)) {
|
||||
|
||||
$forummod = $DB->get_record('modules', array('name'=>'forum'));
|
||||
|
||||
|
||||
if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
|
||||
notice('Default teacher role was not found. Roles and permissions '.
|
||||
'for all your forums will have to be manually set.');
|
||||
@ -177,7 +177,7 @@
|
||||
$teacherroles, $studentroles, $guestroles,
|
||||
$restore->mods['forum']->instances[$mod->id]->restored_as_course_module);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$status = false;
|
||||
}
|
||||
@ -252,7 +252,7 @@
|
||||
|
||||
//Get the discussions array
|
||||
$discussions = array();
|
||||
|
||||
|
||||
if (!empty($info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'])) {
|
||||
$discussions = $info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'];
|
||||
}
|
||||
@ -279,7 +279,7 @@
|
||||
$discussion->assessed = backup_todb($dis_info['#']['ASSESSED']['0']['#']);
|
||||
$discussion->timemodified = backup_todb($dis_info['#']['TIMEMODIFIED']['0']['#']);
|
||||
$discussion->timemodified += $restore->course_startdateoffset;
|
||||
$discussion->usermodified = backup_todb($dis_info['#']['USERMODIFIED']['0']['#']);
|
||||
$discussion->usermodified = backup_todb($dis_info['#']['USERMODIFIED']['0']['#']);
|
||||
$discussion->timestart = backup_todb($dis_info['#']['TIMESTART']['0']['#']);
|
||||
$discussion->timestart += $restore->course_startdateoffset;
|
||||
$discussion->timeend = backup_todb($dis_info['#']['TIMEEND']['0']['#']);
|
||||
@ -460,11 +460,11 @@
|
||||
//Now, build the FORUM_POSTS record structure
|
||||
$post->discussion = $discussion_id;
|
||||
$post->parent = backup_todb($pos_info['#']['PARENT']['0']['#']);
|
||||
$post->userid = backup_todb($pos_info['#']['USERID']['0']['#']);
|
||||
$post->userid = backup_todb($pos_info['#']['USERID']['0']['#']);
|
||||
$post->created = backup_todb($pos_info['#']['CREATED']['0']['#']);
|
||||
$post->created += $restore->course_startdateoffset;
|
||||
$post->modified = backup_todb($pos_info['#']['MODIFIED']['0']['#']);
|
||||
$post->modified += $restore->course_startdateoffset;
|
||||
$post->modified += $restore->course_startdateoffset;
|
||||
$post->mailed = backup_todb($pos_info['#']['MAILED']['0']['#']);
|
||||
$post->subject = backup_todb($pos_info['#']['SUBJECT']['0']['#']);
|
||||
$post->message = backup_todb($pos_info['#']['MESSAGE']['0']['#']);
|
||||
@ -1125,7 +1125,7 @@
|
||||
function forum_decode_content_links_caller($restore) {
|
||||
global $CFG, $DB, $DB;
|
||||
$status = true;
|
||||
|
||||
|
||||
//Process every POST (message) in the course
|
||||
if ($posts = $DB->get_records_sql("SELECT p.id, p.message
|
||||
FROM {forum_posts} p,
|
||||
|
@ -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,22 +159,23 @@
|
||||
$newsince = "";
|
||||
}
|
||||
|
||||
if ($recs = get_records_sql ("SELECT d.id AS discussionid,
|
||||
d.name AS discussionname,
|
||||
u.id AS userid,
|
||||
if ($recs = $DB->get_records_sql ("SELECT d.id AS discussionid,
|
||||
d.name AS discussionname,
|
||||
u.id AS userid,
|
||||
u.firstname AS userfirstname,
|
||||
u.lastname AS userlastname,
|
||||
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;
|
||||
@ -251,16 +252,16 @@
|
||||
|
||||
$post_file_area_name = str_replace('//', '/', "$forum->course/$CFG->moddata/forum/$forum->id/$rec->postid");
|
||||
$post_files = get_directory_list("$CFG->dataroot/$post_file_area_name");
|
||||
|
||||
if (!empty($post_files)) {
|
||||
|
||||
if (!empty($post_files)) {
|
||||
$item->attachments = array();
|
||||
foreach ($post_files as $file) {
|
||||
foreach ($post_files as $file) {
|
||||
$attachment = new stdClass;
|
||||
if ($CFG->slasharguments) {
|
||||
$attachment->url = "{$CFG->wwwroot}/file.php/$post_file_area_name/$file";
|
||||
} else {
|
||||
$attachment->url = "{$CFG->wwwroot}/file.php?file=/$post_file_area_name/$file";
|
||||
}
|
||||
}
|
||||
$attachment->length = filesize("$CFG->dataroot/$post_file_area_name/$file");
|
||||
$item->attachments[] = $attachment;
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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!");
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ if (!defined('MOODLE_INTERNAL')) {
|
||||
require_once($CFG->dirroot . '/mod/forum/lib.php');
|
||||
|
||||
class modforumlib_test extends UnitTestCase {
|
||||
|
||||
|
||||
function setUp() {
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
@ -50,18 +50,18 @@
|
||||
if (!empty($CFG->loginhttps)) {
|
||||
$wwwroot = str_replace('http:','https:', $wwwroot);
|
||||
}
|
||||
|
||||
|
||||
$navigation = build_navigation('', $cm);
|
||||
print_header($course->shortname, $course->fullname, $navigation, '', '', true, "", navmenu($course, $cm));
|
||||
|
||||
|
||||
notice_yesno(get_string('noguestsubscribe', 'forum').'<br /><br />'.get_string('liketologin'),
|
||||
$wwwroot, $_SERVER['HTTP_REFERER']);
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
||||
$returnto = optional_param('backtoindex',0,PARAM_INT)
|
||||
? "index.php?id=".$course->id
|
||||
$returnto = optional_param('backtoindex',0,PARAM_INT)
|
||||
? "index.php?id=".$course->id
|
||||
: "view.php?f=$id";
|
||||
|
||||
if ($force and has_capability('mod/forum:managesubscriptions', $context)) {
|
||||
|
@ -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,12 +29,12 @@
|
||||
$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);
|
||||
}
|
||||
|
||||
add_to_log($course->id, "forum", "user report",
|
||||
"user.php?course=$course->id&id=$user->id&mode=$mode", "$user->id");
|
||||
"user.php?course=$course->id&id=$user->id&mode=$mode", "$user->id");
|
||||
|
||||
$strforumposts = get_string('forumposts', 'forum');
|
||||
$strparticipants = get_string('participants');
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user