Commit 90f4745c authored by skodak's avatar skodak
Browse files

MDL-14113 patch for multiple issues - see tracker for subtasks; merged from MOODLE_19_STABLE

parent 59d6852b
......@@ -942,7 +942,7 @@ function print_recent_activity($course) {
$content = $print_recent_activity($course, $viewfullnames, $timestart) || $content;
}
} else {
debugging("Missing lib.php in lib/{$mod->name} - please reinstall files or uninstall the module");
debugging("Missing lib.php in lib/{$modname} - please reinstall files or uninstall the module");
}
}
......@@ -1255,7 +1255,6 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
static $strmovehere;
static $strmovefull;
static $strunreadpostsone;
static $untracked;
static $usetracking;
static $groupings;
......@@ -1272,7 +1271,6 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
include_once($CFG->dirroot.'/mod/forum/lib.php');
if ($usetracking = forum_tp_can_track_forums()) {
$strunreadpostsone = get_string('unreadpostsone', 'forum');
$untracked = forum_tp_get_untracked_forums($USER->id, $course->id);
}
$initialised = true;
}
......@@ -1391,18 +1389,14 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
}
}
if ($usetracking && $mod->modname == 'forum') {
if ($usetracking and !isset($untracked[$mod->instance])) {
$groupid = groups_get_activity_group($mod);
$unread = forum_tp_count_forum_unread_posts($USER->id, $mod->instance, $groupid);
if ($unread) {
echo '<span class="unread"> <a href="'.$CFG->wwwroot.'/mod/forum/view.php?id='.$mod->id.'">';
if ($unread == 1) {
echo $strunreadpostsone;
} else {
print_string('unreadpostsnumber', 'forum', $unread);
}
echo '</a> </span>';
if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) {
echo '<span class="unread"> <a href="'.$CFG->wwwroot.'/mod/forum/view.php?id='.$mod->id.'">';
if ($unread == 1) {
echo $strunreadpostsone;
} else {
print_string('unreadpostsnumber', 'forum', $unread);
}
echo '</a></span>';
}
}
......
......@@ -197,7 +197,7 @@
if (!empty($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
if (forum_is_subscribed($USER->id, $newsforum->id)) {
if (forum_is_subscribed($USER->id, $newsforum)) {
$subtext = get_string('unsubscribe', 'forum');
} else {
$subtext = get_string('subscribe', 'forum');
......
......@@ -53,6 +53,35 @@ function xmldb_forum_upgrade($oldversion=0) {
$db->debug = true;
}
if ($result && $oldversion < 2007101512) {
/// Cleanup the forum subscriptions
notify('Removing stale forum subscriptions', 'notifysuccess');
$roles = get_roles_with_capability('moodle/course:view', CAP_ALLOW);
$roles = array_keys($roles);
$roles = implode(',', $roles);
$sql = "SELECT fs.userid, f.id AS forumid
FROM {$CFG->prefix}forum f
JOIN {$CFG->prefix}course c ON c.id = f.course
JOIN {$CFG->prefix}context ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = ".CONTEXT_COURSE.")
JOIN {$CFG->prefix}forum_subscriptions fs ON fs.forum = f.id
LEFT JOIN {$CFG->prefix}role_assignments ra ON (ra.contextid = ctx.id AND ra.userid = fs.userid AND ra.roleid IN ($roles))
WHERE ra.id IS NULL";
if ($rs = get_recordset_sql($sql)) {
$db->debug = false;
while ($remove = rs_fetch_next_record($rs)) {
delete_records('forum_subscriptions', 'userid', $remove->userid, 'forum', $remove->forumid);
echo '.';
}
$db->debug = true;
rs_close($rs);
}
}
return $result;
}
......
......@@ -14,11 +14,11 @@
$postid = optional_param('postid', 0, PARAM_INT); // Used for tracking read posts if user initiated.
if (!$discussion = get_record('forum_discussions', 'id', $d)) {
print_error("Discussion ID was incorrect or no longer exists");
error("Discussion ID was incorrect or no longer exists");
}
if (!$course = get_record('course', 'id', $discussion->course)) {
print_error("Course ID is incorrect - discussion is faulty");
error("Course ID is incorrect - discussion is faulty");
}
if (!$forum = get_record('forum', 'id', $discussion->forum)) {
......@@ -26,7 +26,7 @@
}
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
print_error('Course Module ID was incorrect');
error('Course Module ID was incorrect');
}
require_course_login($course, true, $cm);
......@@ -38,7 +38,7 @@
if (!($USER->id == $discussion->userid || (($discussion->timestart == 0
|| $discussion->timestart <= time())
&& ($discussion->timeend == 0 || $discussion->timeend > time())))) {
print_error('Discussion ID was incorrect or no longer exists', '', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
error('Discussion ID was incorrect or no longer exists', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
}
}
......@@ -49,25 +49,26 @@
require_capability('mod/forum:movediscussions', $modcontext);
if ($forum->type == 'single') {
print_error('Cannot move discussion from a simple single discussion forum', '', $return);
error('Cannot move discussion from a simple single discussion forum', $return);
}
if (!$forumto = get_record('forum', 'id', $move)) {
print_error('You can\'t move to that forum - it doesn\'t exist!', '', $return);
error('You can\'t move to that forum - it doesn\'t exist!', $return);
}
if (!$cmto = get_coursemodule_from_instance('forum', $forumto->id, $course->id)) {
print_error('Target forum not found in this course.', '', $return);
error('Target forum not found in this course.', $return);
}
if (!coursemodule_visible_for_user($cmto)) {
print_error('Forum not visible', '', $return);
error('Forum not visible', $return);
}
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);
add_to_log($course->id, 'forum', 'move discussion', "discuss.php?d=$discussion->id", $discussion->id, $cmto->id);
require_once($CFG->libdir.'/rsslib.php');
......@@ -77,8 +78,8 @@
// the regeneration of the feeds since the discussions have been
// moved.
if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($forumto)) {
print_error('Could not purge the cached RSS feeds for the source and/or'.
'destination forum(s) - check your file permissionsforums', '', $return);
error('Could not purge the cached RSS feeds for the source and/or'.
'destination forum(s) - check your file permissionsforums', $return);
}
redirect($return.'&amp;moved=-1&amp;sesskey='.sesskey());
......@@ -109,19 +110,18 @@
}
if (! $post = forum_get_post_full($parent)) {
print_error("Discussion no longer exists", '', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
}
if (!forum_user_can_view_post($post, $course, $cm, $forum, $discussion)) {
print_error('You do not have permissions to view this post', '', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id");
error('You do not have permissions to view this post', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id");
}
if ($mark == 'read' or $mark == 'unread') {
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum) &&
$CFG->forum_usermarksread) {
if ($CFG->forum_usermarksread && forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
if ($mark == 'read') {
forum_tp_add_read_record($USER->id, $postid, $discussion->id, $forum->id);
forum_tp_add_read_record($USER->id, $postid);
} else {
// unread
forum_tp_delete_read_records($USER->id, $postid);
......
......@@ -9,11 +9,11 @@
if ($id) {
if (! $course = get_record('course', 'id', $id)) {
print_error("Course ID is incorrect");
error("Course ID is incorrect");
}
} else {
if (! $course = get_site()) {
print_error("Could not find a top-level course!");
error("Could not find a top-level course!");
}
}
......@@ -51,7 +51,7 @@
$generaltable->head = array ($strforum, $strdescription, $strdiscussions);
$generaltable->align = array ('left', 'left', 'center');
if ($usetracking = (!isguestuser() && forum_tp_can_track_forums())) {
if ($usetracking = forum_tp_can_track_forums()) {
$untracked = forum_tp_get_untracked_forums($USER->id, $course->id);
$generaltable->head[] = $strunreadposts;
......@@ -61,6 +61,8 @@
$generaltable->align[] = 'center';
}
$subscribed_forums = forum_get_subscribed_forums($course);
if ($can_subscribe = (!isguestuser() && has_capability('moodle/course:view', $coursecontext))) {
$generaltable->head[] = $strsubscribed;
$generaltable->align[] = 'center';
......@@ -118,11 +120,12 @@
/// Do course wide subscribe/unsubscribe
if (!is_null($subscribe) and !isguestuser() and !isguest()) {
foreach ($modinfo->instances['forum'] as $forumid=>$cm) {
if (!forum_is_forcesubscribed($forumid)) {
$subscribed = forum_is_subscribed($USER->id, $forumid);
$forum = $forums[$forumid];
if (!forum_is_forcesubscribed($forum)) {
$subscribed = forum_is_subscribed($USER->id, $forum);
if ($subscribe && !$subscribed) {
forum_subscribe($USER->id, $forumid);
} elseif (!$subscribe && $subscribed) {
} else if (!$subscribe && $subscribed) {
forum_unsubscribe($USER->id, $forumid);
}
}
......@@ -147,70 +150,48 @@
$cm = $modinfo->instances['forum'][$forum->id];
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$groupmode = groups_get_activity_groupmode($cm, $course);
$currentgroup = groups_get_activity_group($cm);
if ($groupmode == SEPARATEGROUPS) {
$accessallgroups = has_capability('moodle/site:accessallgroups', $context);
} else {
$accessallgroups = true;
}
$cantaccessagroup = !$accessallgroups and empty($currentgroup);
// this is potentially wrong logic. could possibly check for if user has the right to hmmm
if ($cantaccessagroup) {
$count = '';
} if ($currentgroup) {
$count = count_records_select('forum_discussions', "forum = $forum->id AND (groupid = $currentgroup OR groupid = -1)");
} else {
$count = count_records('forum_discussions', 'forum', $forum->id);
}
$count = forum_count_discussions($forum, $cm, $course);
if ($usetracking) {
if ($forum->trackingtype == FORUM_TRACKING_OFF) {
$unreadlink = '-';
$trackedlink = '-';
} else if (($forum->trackingtype == FORUM_TRACKING_ON) || !isset($untracked[$forum->id])) {
$groupid = !$accessallgroups ? $currentgroup : false;
$unread = forum_tp_count_forum_unread_posts($USER->id, $forum->id, $groupid);
if ($unread > 0) {
$unreadlink = '<span class="unread"><a href="view.php?f='.$forum->id.'">'.$unread.'</a>';
} else {
if (isset($untracked[$forum->id])) {
$unreadlink = '-';
} else if ($unread = forum_tp_count_forum_unread_posts($cm, $course)) {
$unreadlink = '<span class="unread"><a href="view.php?f='.$forum->id.'">'.$unread.'</a>';
$unreadlink .= '<a title="'.$strmarkallread.'" href="markposts.php?f='.
$forum->id.'&amp;mark=read"><img src="'.$CFG->pixpath.'/t/clear.gif" alt="'.$strmarkallread.'" /></a></span>';
} else {
$unreadlink = '<span class="read"><a href="view.php?f='.$forum->id.'">'.$unread.'</a></span>';
$unreadlink = '<span class="read">0</span>';
}
if ($forum->trackingtype == FORUM_TRACKING_ON) {
$trackedlink = $stryes;
if ($forum->trackingtype == FORUM_TRACKING_OPTIONAL) {
$trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $stryes, 'post', '_self', true, $strnotrackforum);
} else {
$trackedlink = $stryes;
$options = array('id'=>$forum->id);
if (!isset($untracked[$forum->id])) {
$trackedlink = print_single_button($CFG->wwwroot.'/mod/forum/settracking.php', $options, $stryes, 'post', '_self', true, $strnotrackforum);
} else {
$trackedlink = print_single_button($CFG->wwwroot.'/mod/forum/settracking.php', $options, $strno, 'post', '_self', true, $strtrackforum);
}
}
} else {
$unreadlink = '-';
$trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $strno, 'post', '_self', true, $strtrackforum);
}
}
$forum->intro = shorten_text(trim(format_text($forum->intro, FORMAT_HTML, $introoptions)), $CFG->forum_shortpost);
$forumname = format_string($forum->name, true);;
if ($cantaccessagroup) {
$forumlink = $forumname;
$discussionlink = $count;
if ($cm->visible) {
$style = '';
} else {
if ($cm->visible) {
$style = '';
} else {
$style = 'class="dimmed"';
}
$forumlink = "<a href=\"view.php?f=$forum->id\" $style>".format_string($forum->name,true)."</a>";
$discussionlink = "<a href=\"view.php?f=$forum->id\" $style>".$count."</a>";
$style = 'class="dimmed"';
}
$forumlink = "<a href=\"view.php?f=$forum->id\" $style>".format_string($forum->name,true)."</a>";
$discussionlink = "<a href=\"view.php?f=$forum->id\" $style>".$count."</a>";
$row = array ($forumlink, $forum->intro, $discussionlink);
if ($usetracking) {
......@@ -219,21 +200,29 @@
}
if ($can_subscribe) {
$row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
'cantsubscribe' => '-'), $cantaccessagroup, false, true);
if ($forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE) {
$row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
'cantsubscribe' => '-'), false, false, true, $subscribed_forums);
} else {
$row[] = '-';
}
}
//If this forum has RSS activated, calculate it
if ($show_rss and $forum->rsstype and $forum->rssarticles) {
//Calculate the tolltip text
if ($forum->rsstype == 1) {
$tooltiptext = get_string('rsssubscriberssdiscussions', 'forum', format_string($forum->name));
if ($show_rss) {
if ($forum->rsstype and $forum->rssarticles) {
//Calculate the tolltip text
if ($forum->rsstype == 1) {
$tooltiptext = get_string('rsssubscriberssdiscussions', 'forum', format_string($forum->name));
} else {
$tooltiptext = get_string('rsssubscriberssposts', 'forum', format_string($forum->name));
}
//Get html code for RSS link
$row[] = rss_get_link($course->id, $USER->id, 'forum', $forum->id, $tooltiptext);
} else {
$tooltiptext = get_string('rsssubscriberssposts', 'forum', format_string($forum->name));
$row[] = '&nbsp;';
}
//Get html code for RSS link
$row[] = rss_get_link($course->id, $USER->id, 'forum', $forum->id, $tooltiptext);
}
$generaltable->data[] = $row;
......@@ -283,51 +272,35 @@
$cm = $modinfo->instances['forum'][$forum->id];
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$groupmode = groups_get_activity_groupmode($cm, $course);
$currentgroup = groups_get_activity_group($cm);
if ($groupmode == SEPARATEGROUPS) {
$accessallgroups = has_capability('moodle/site:accessallgroups', $context);
} else {
$accessallgroups = true;
}
$cantaccessagroup = !$accessallgroups and empty($currentgroup);
if ($cantaccessagroup) {
$count = '';
} if ($currentgroup) {
$count = count_records_select('forum_discussions', "forum = $forum->id AND (groupid = $currentgroup OR groupid = -1)");
} else {
$count = count_records('forum_discussions', 'forum', $forum->id);
}
$count = forum_count_discussions($forum, $cm, $course);
if ($usetracking) {
if ($forum->trackingtype == FORUM_TRACKING_OFF) {
$unreadlink = '-';
$unreadlink = '-';
$trackedlink = '-';
} else if (($forum->trackingtype == FORUM_TRACKING_ON) ||
!isset($untracked[$forum->id])) {
$groupid = !$accessallgroups ? $currentgroup : false;
$unread = forum_tp_count_forum_unread_posts($USER->id, $forum->id, $groupid);
if ($unread > 0) {
} else {
if (isset($untracked[$forum->id])) {
$unreadlink = '-';
} else if ($unread = forum_tp_count_forum_unread_posts($cm, $course)) {
$unreadlink = '<span class="unread"><a href="view.php?f='.$forum->id.'">'.$unread.'</a>';
$unreadlink .= '<a title="'.$strmarkallread.'" href="markposts.php?f='.
$forum->id.'&amp;mark=read"><img src="'.$CFG->pixpath.'/t/clear.gif" alt="'.$strmarkallread.'" /></a></span>';
} else {
$unreadlink = '<span class="read"><a href="view.php?f='.$forum->id.'">'.$unread.'</a></span>';
$unreadlink = '<span class="read">0</span>';
}
if ($forum->trackingtype == FORUM_TRACKING_OPTIONAL) {
$trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $stryes, 'post', '_self', true, $strnotrackforum);
} else {
if ($forum->trackingtype == FORUM_TRACKING_ON) {
$trackedlink = $stryes;
} else {
$options = array('id'=>$forum->id);
if (!isset($untracked[$forum->id])) {
$trackedlink = print_single_button($CFG->wwwroot.'/mod/forum/settracking.php', $options, $stryes, 'post', '_self', true, $strnotrackforum);
} else {
$trackedlink = print_single_button($CFG->wwwroot.'/mod/forum/settracking.php', $options, $strno, 'post', '_self', true, $strtrackforum);
}
}
} else {
$unreadlink = '-';
$trackedlink = print_single_button($CFG->wwwroot . '/mod/forum/settracking.php?id=' . $forum->id, '', $strno, 'post', '_self', true, $strtrackforum);
}
}
......@@ -345,18 +318,14 @@
}
$forumname = format_string($forum->name,true);;
if ($cantaccessagroup) {
$forumlink = $forumname;
$discussionlink = $count;
if ($cm->visible) {
$style = '';
} else {
if ($cm->visible) {
$style = '';
} else {
$style = 'class="dimmed"';
}
$forumlink = "<a href=\"view.php?f=$forum->id\" $style>".format_string($forum->name,true)."</a>";
$discussionlink = "<a href=\"view.php?f=$forum->id\" $style>".$count."</a>";
$style = 'class="dimmed"';
}
$forumlink = "<a href=\"view.php?f=$forum->id\" $style>".format_string($forum->name,true)."</a>";
$discussionlink = "<a href=\"view.php?f=$forum->id\" $style>".$count."</a>";
$row = array ($printsection, $forumlink, $forum->intro, $discussionlink);
if ($usetracking) {
......@@ -365,21 +334,29 @@
}
if ($can_subscribe) {
$row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
'cantsubscribe' => '-'), $cantaccessagroup, false, true);
if ($forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE) {
$row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes,
'unsubscribed' => $strno, 'forcesubscribed' => $stryes,
'cantsubscribe' => '-'), false, false, true, $subscribed_forums);
} else {
$row[] = '-';
}
}
//If this forum has RSS activated, calculate it
if ($show_rss and $forum->rsstype and $forum->rssarticles) {
//Calculate the tolltip text
if ($forum->rsstype == 1) {
$tooltiptext = get_string('rsssubscriberssdiscussions', 'forum', format_string($forum->name));
if ($show_rss) {
if ($forum->rsstype and $forum->rssarticles) {
//Calculate the tolltip text
if ($forum->rsstype == 1) {
$tooltiptext = get_string('rsssubscriberssdiscussions', 'forum', format_string($forum->name));
} else {
$tooltiptext = get_string('rsssubscriberssposts', 'forum', format_string($forum->name));
}
//Get html code for RSS link
$row[] = rss_get_link($course->id, $USER->id, 'forum', $forum->id, $tooltiptext);
} else {
$tooltiptext = get_string('rsssubscriberssposts', 'forum', format_string($forum->name));
$row[] = '&nbsp;';
}
//Get html code for RSS link
$row[] = rss_get_link($course->id, $USER->id, 'forum', $forum->id, $tooltiptext);
}
$learningtable->data[] = $row;
......
......@@ -33,6 +33,8 @@ define ('FORUM_AGGREGATE_SUM', 5);
* (defined by the form in mod.html) this function
* will create a new instance and return the id number
* of the new instance.
* @param object $forum add forum instance (with magic quotes)
* @return int intance id
*/
function forum_add_instance($forum) {
global $CFG;
......@@ -63,7 +65,7 @@ function forum_add_instance($forum) {
$discussion->mailnow = false;
if (! forum_add_discussion($discussion, $discussion->intro)) {
print_error('Could not add the discussion for this forum');
error('Could not add the discussion for this forum');
}
}
......@@ -85,7 +87,9 @@ function forum_add_instance($forum) {
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* will update an existing instance with new data.
*/
* @param object $forum forum instance (with magic quotes)
* @return bool success
*/
function forum_update_instance($forum) {
$forum->timemodified = time();
$forum->id = $forum->instance;
......@@ -114,11 +118,11 @@ function forum_update_instance($forum) {
notify('Warning! There is more than one discussion in this forum - using the most recent');
$discussion = array_pop($discussions);
} else {
print_error('Could not find the discussion in this forum');
error('Could not find the discussion in this forum');
}
}
if (! $post = get_record('forum_posts', 'id', $discussion->firstpost)) {
print_error('Could not find the first post in this forum discussion');
error('Could not find the first post in this forum discussion');
}
$post->subject = $forum->name;
......@@ -126,18 +130,18 @@ function forum_update_instance($forum) {
$post->modified = $forum->timemodified;
if (! update_record('forum_posts', ($post))) {
print_error('Could not update the first post');
error('Could not update the first post');
}
$discussion->name = $forum->name;
if (! update_record('forum_discussions', ($discussion))) {
print_error('Could not update the discussion');
error('Could not update the discussion');
}
}
if (!update_record('forum', $forum)) {
print_error('Can not update forum');
error('Can not update forum');
}
$forum = stripslashes_recursive($forum);
......@@ -151,6 +155,8 @@ function forum_update_instance($forum) {
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
* @param int forum instance id
* @return bool success
*/
function forum_delete_instance($id) {
......@@ -188,7 +194,8 @@ function forum_delete_instance($id) {
* Function to be run periodically according to the moodle cron
* Finds all posts that have yet to be mailed out, and mails them
* out to all subscribers
*/
* @return void
*/
function forum_cron() {
global $CFG, $USER;
......@@ -217,7 +224,7 @@ function forum_cron() {
$endtime = $timenow - $CFG->maxeditingtime;
$starttime = $endtime - 48 * 3600; // Two days earlier
if ($posts = forum_get_unmailed_posts($starttime, $endtime)) {
if ($posts = forum_get_unmailed_posts($starttime, $endtime, $timenow)) {
// Mark them all now as being mailed. It's unlikely but possible there
// might be an error later so that a post is NOT actually mailed out,
// but since mail isn't crucial, we can accept this risk. Doing it now
......@@ -314,7 +321,8 @@ function forum_cron() {
// init caches
$userto->viewfullnames = array();
$userto->canpost = array();
$userto->tracking = array();
$userto->markposts = array();
$userto->enrolledin = array();
// reset the caches
foreach ($coursemodules as $forumid=>$unused) {
......@@ -329,13 +337,22 @@ function forum_cron() {
$discussion = $discussions[$post->discussion];
$forum = $forums[$discussion->forum];
$course = $courses[$forum->course];
$cm = $coursemodules[$forum->id];
$cm =& $coursemodules[$forum->id];