diff --git a/lang/en/forum.php b/lang/en/forum.php index 65b63e92c13..61f9547f71e 100644 --- a/lang/en/forum.php +++ b/lang/en/forum.php @@ -11,6 +11,8 @@ $string['allowchoice'] = 'Allow everyone to choose'; $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'; @@ -109,6 +111,8 @@ $string['notingroup'] = 'Sorry, but you need to be part of a group to see this f $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'; diff --git a/mod/forum/index.php b/mod/forum/index.php index 45b8b3d344e..24f2433a773 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -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)) { @@ -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) { @@ -405,6 +431,15 @@ "", "", true, $searchform, navmenu($course)); } + if (!isguest()) { + echo '
'; + echo ''; + echo ''.get_string('allsubscribe', 'forum').''; + echo '
'; + echo ''.get_string('allunsubscribe', 'forum').''; + echo '
'; + } + if ($generalforums) { print_heading(get_string("generalforums", "forum")); print_table($generaltable);