Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Users can now subscribe/unsubscribe to all forums in a course from th…
…e forum list
  • Loading branch information
patrickslee committed Nov 28, 2005
1 parent 9a3d715 commit 03877b0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lang/en/forum.php
Expand Up @@ -11,6 +11,8 @@
$string['allowdiscussions'] = 'Can a $a post to this forum?';
$string['allowratings'] = 'Allow posts to be rated?';
$string['allowsdiscussions'] = 'This forum allows each person to start one discussion topic.';
$string['allsubscribe'] = 'Subscribe to all forums';
$string['allunsubscribe'] = 'Unsubscribe from all forums';
$string['anyfile'] = 'Any file';
$string['attachment'] = 'Attachment';
$string['bynameondate'] = 'by $a->name - $a->date';
Expand Down Expand Up @@ -109,6 +111,8 @@
$string['notrackforum'] = 'Don\'t track unread messages';
$string['nownotsubscribed'] = '$a->name will NOT receive copies of \'$a->forum\' by email.';
$string['nownottracking'] = '$a->name is no longer tracking \'$a->forum\'.';
$string['nowallsubscribed'] = 'All forums in $a are subscribed.';
$string['nowallunsubscribed'] = 'All forums in $a are not subscribed.';
$string['nowsubscribed'] = '$a->name will receive copies of \'$a->forum\' by email.';
$string['nowtracking'] = '$a->name is now tracking \'$a->forum\'.';
$string['numposts'] = '$a posts';
Expand Down
35 changes: 35 additions & 0 deletions mod/forum/index.php
Expand Up @@ -5,6 +5,7 @@
require_once("$CFG->libdir/rsslib.php");

$id = optional_param('id',0,PARAM_INT); // course
$subscribe = optional_param('subscribe',null,PARAM_INT); // Subscribe/Unsubscribe all forums

if ($id) {
if (! $course = get_record("course", "id", $id)) {
Expand Down Expand Up @@ -123,6 +124,31 @@
}
}

/// Do course wide subscribe/unsubscribe
if (!is_null($subscribe) && !isguest()) {
$allforums = array_merge($generalforums, $learningforums);
if ($allforums) {
foreach ($allforums as $forum) {
if (!forum_is_forcesubscribed($forum->id)) {
$subscribed = forum_is_subscribed($USER->id, $forum->id);
if ($subscribe && !$subscribed) {
forum_subscribe($USER->id, $forum->id);
} elseif (!$subscribe && $subscribed) {
forum_unsubscribe($USER->id, $forum->id);
}
}
}
}
$returnto = forum_go_back_to("index.php?id=$course->id");
if ($subscribe) {
add_to_log($course->id, "forum", "subscribeall", "index.php?id=$course->id", $course->id);
redirect($returnto, get_string("nowallsubscribed", "forum", $course->shortname), 1);
} else {
add_to_log($course->id, "forum", "unsubscribeall", "index.php?id=$course->id", $course->id);
redirect($returnto, get_string("nowallunsubscribed", "forum", $course->shortname), 1);
}
}

/// First, let's process the general forums and build up a display

if ($generalforums) {
Expand Down Expand Up @@ -405,6 +431,15 @@
"", "", true, $searchform, navmenu($course));
}

if (!isguest()) {
echo '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr valign="top"><td align="right" class="subscription">';
echo '<span class="helplink">';
echo '<a href="index.php?id='.$course->id.'&amp;subscribe=1">'.get_string('allsubscribe', 'forum').'</a>';
echo '<br />';
echo '<a href="index.php?id='.$course->id.'&amp;subscribe=0">'.get_string('allunsubscribe', 'forum').'</a>';
echo '</span></td></tr></table>';
}

if ($generalforums) {
print_heading(get_string("generalforums", "forum"));
print_table($generaltable);
Expand Down

0 comments on commit 03877b0

Please sign in to comment.