From 8697022530d9195cb7f8fae447dc127b4215923b Mon Sep 17 00:00:00 2001
From: martin
Date: Thu, 15 Aug 2002 04:16:39 +0000
Subject: [PATCH] Fixes to finding list of subscribers to a forum for
site-level forums which affected both the displayed list and the mailouts.
---
lib/setup.php | 2 +-
mod/forum/lib.php | 88 ++++++++++++++++++++++-----------------
mod/forum/subscribers.php | 31 +++++---------
3 files changed, 61 insertions(+), 60 deletions(-)
diff --git a/lib/setup.php b/lib/setup.php
index 90af95571c..a0a4a3a5ce 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -18,7 +18,7 @@
// Default editing time for posts and the like (in seconds)
- $CFG->maxeditingtime = 1800;
+ $CFG->maxeditingtime = 10;
// Location of standard files
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index daabe4be3d..6aceaf6397 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -106,7 +106,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course,
$output .= "
";
$output .= "body\" WIDTH=10>";
echo " ";
- echo " | \n";
+ echo " | cellcontent\">\n";
if ($link && (strlen($post->message) > $FORUM_LONG_POST)) {
// Print shortened version
@@ -691,7 +691,7 @@ function forum_cron () {
continue;
}
- if ($users = get_course_users($course->id)) {
+ if ($users = forum_subscribed_users($course, $forum)) {
$strforums = get_string("forums", "forum");
$mailcount=0;
@@ -700,44 +700,43 @@ function forum_cron () {
$by->date = userdate($post->created, "", $userto->timezone);
$strbynameondate = get_string("bynameondate", "forum", $by);
- if (forum_is_subscribed($userto->id, $forum->id)) {
- $postsubject = "$course->shortname: $post->subject";
- $posttext = "$course->shortname -> $strforums -> $forum->name";
+ $postsubject = "$course->shortname: $post->subject";
+ $posttext = "$course->shortname -> $strforums -> $forum->name";
+
+ if ($discussion->name == $forum->name) {
+ $posttext .= "\n";
+ } else {
+ $posttext .= " -> $discussion->name\n";
+ }
+ $posttext .= "---------------------------------------------------------------------\n";
+ $posttext .= "$post->subject\n";
+ $posttext .= $strbynameondate."\n";
+ $posttext .= "---------------------------------------------------------------------\n";
+ $posttext .= strip_tags($post->message);
+ $posttext .= "\n\n";
+ $posttext .= "---------------------------------------------------------------------\n";
+ $posttext .= get_string("postmailinfo", "forum", $course->shortname)."\n";
+ $posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id";
+
+ if ($userto->mailformat == 1) { // HTML
+ $posthtml = " ".
+ "wwwroot/course/view.php?id=$course->id\">$course->shortname -> ".
+ "wwwroot/mod/forum/index.php?id=$course->id\">$strforums -> ".
+ "wwwroot/mod/forum/view.php?f=$forum->id\">$forum->name";
if ($discussion->name == $forum->name) {
- $posttext .= "\n";
- } else {
- $posttext .= " -> $discussion->name\n";
- }
- $posttext .= "---------------------------------------------------------------------\n";
- $posttext .= "$post->subject\n";
- $posttext .= $strbynameondate."\n";
- $posttext .= "---------------------------------------------------------------------\n";
- $posttext .= strip_tags($post->message);
- $posttext .= "\n\n";
- $posttext .= "---------------------------------------------------------------------\n";
- $posttext .= get_string("postmailinfo", "forum", $course->shortname)."\n";
- $posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id";
-
- if ($userto->mailformat == 1) { // HTML
- $posthtml = "".
- "wwwroot/course/view.php?id=$course->id\">$course->shortname -> ".
- "wwwroot/mod/forum/index.php?id=$course->id\">$strforums -> ".
- "wwwroot/mod/forum/view.php?f=$forum->id\">$forum->name";
- if ($discussion->name == $forum->name) {
- $posthtml .= " ";
- } else {
- $posthtml .= " -> wwwroot/mod/forum/discuss.php?d=$discussion->id\">$discussion->name ";
- }
- $posthtml .= forum_make_mail_post($post, $userfrom, $userto, $course, false, true, false, false);
- } else {
- $posthtml = "";
- }
-
- if (! email_to_user($userto, $userfrom, $postsubject, $posttext, $posthtml)) {
- echo "Error: mod/forum/cron.php: Could not send out mail for id $post->id to user $userto->id ($userto->email)\n";
+ $posthtml .= "";
} else {
- $mailcount++;
+ $posthtml .= " -> wwwroot/mod/forum/discuss.php?d=$discussion->id\">$discussion->name";
}
+ $posthtml .= forum_make_mail_post($post, $userfrom, $userto, $course, false, true, false, false);
+ } else {
+ $posthtml = "";
+ }
+
+ if (! email_to_user($userto, $userfrom, $postsubject, $posttext, $posthtml)) {
+ echo "Error: mod/forum/cron.php: Could not send out mail for id $post->id to user $userto->id ($userto->email)\n";
+ } else {
+ $mailcount++;
}
}
echo "mailed to $mailcount users ...";
@@ -769,6 +768,19 @@ function forum_is_subscribed($userid, $forumid) {
return record_exists_sql("SELECT * FROM forum_subscriptions WHERE user='$userid' AND forum='$forumid'");
}
+function forum_subscribed_users($course, $forum) {
+// Returns list of user objects that are subscribed to this forum
+
+ if ($course->category) { // normal course
+ if ($forum->forcesubscribe) {
+ return get_course_users($course->id);
+ }
+ }
+ return get_records_sql("SELECT u.* FROM user u, forum_subscriptions s
+ WHERE s.forum = '$forum->id'
+ AND s.user = u.id");
+}
+
function forum_subscribe($userid, $forumid) {
global $db;
diff --git a/mod/forum/subscribers.php b/mod/forum/subscribers.php
index 9281f6051d..d6874c421e 100644
--- a/mod/forum/subscribers.php
+++ b/mod/forum/subscribers.php
@@ -38,31 +38,20 @@
print_header("$course->shortname: $strsubscribers", "$course->fullname", "$navigation");
- if ($course->category) {
- $users = get_course_users($course->id);
- } else {
- $users = get_records_sql("SELECT * from user");
- }
-
- if (! $users) {
- print_heading(get_string("nousersyet"));
+ if (! $users = forum_subscribed_users($course, $forum) ) {
+ print_heading(get_string("nosubscribers", "forum"));
} else {
print_heading(get_string("subscribersto","forum", "'$forum->name'"));
- echo "";
- $count = 0;
+ echo "";
foreach ($users as $user) {
- if (forum_is_subscribed($user->id, $forum->id)) {
- echo "";
- print_user_picture($user->id, $course->id, $user->picture);
- echo " | ";
- echo "$user->firstname $user->lastname";
- echo " | ";
- $count++;
- }
- }
- if (!$count) {
- echo "".get_string("nosubscribers", "forum")." | ";
+ echo "";
+ print_user_picture($user->id, $course->id, $user->picture);
+ echo " | cellcontent\">";
+ echo "$user->firstname $user->lastname";
+ echo " | cellcontent\">";
+ echo "$user->email";
+ echo " | ";
}
echo " ";
}
--
2.39.5
|