$string[nodiscussions] = "There are no discussion topics yet in this forum";
$string[noposts] = "No posts";
$string[nosubscribers] = "There are no subscribers yet for this forum";
-$string[nownotsubscribed] = "You are now NOT SUBSCRIBED to receive '\$a' by email.";
-$string[nowsubscribed] = "You are now SUBSCRIBED to receive '\$a' by email.";
+$string[nownotsubscribed] = "\$a->name will NOT receive copies of '\$a->forum' by email.";
+$string[nowsubscribed] = "\$a->name will receive copies of '\$a->forum' by email.";
$string[numposts] = "\$a posts";
$string[olderdiscussions] = "Older discussions";
$string[parentofthispost] = "Parent of this post";
require_variable($id); // The forum to subscribe or unsubscribe to
optional_variable($force); // Force everyone to be subscribed to this forum?
+ optional_variable($user); // Force everyone to be subscribed to this forum?
if (isguest()) {
error("Guests are not allowed to subscribe to posts.", $HTTP_REFERER);
error("Forum doesn't belong to a course!");
}
+ if ($user) {
+ if (!isteacher($course->id)) {
+ error("Only teachers can subscribe/unsubscribe other people!");
+ }
+ if (! $user = get_record("user", "id", $user)) {
+ error("User ID was incorrect");
+ }
+ } else {
+ $user = $USER;
+ }
+
if ($course->category) {
require_login($forum->course);
} else {
redirect($returnto, get_string("everyoneissubscribed", "forum"), 1);
}
- if ( forum_is_subscribed($USER->id, $forum->id) ) {
- if (forum_unsubscribe($USER->id, $forum->id) ) {
+ $info->name = "$user->firstname $user->lastname";
+ $info->forum = $forum->name;
+
+ if ( forum_is_subscribed($user->id, $forum->id) ) {
+ if (forum_unsubscribe($user->id, $forum->id) ) {
add_to_log($course->id, "forum", "unsubscribe", "view.php?f=$forum->id", "$forum->id");
- redirect($returnto, get_string("nownotsubscribed", "forum", "$forum->name"), 1);
+ redirect($returnto, get_string("nownotsubscribed", "forum", $info), 1);
} else {
error("Could not unsubscribe you from that forum", "$HTTP_REFERER");
}
} else { // subscribe
- if (forum_subscribe($USER->id, $forum->id) ) {
+ if (forum_subscribe($user->id, $forum->id) ) {
add_to_log($course->id, "forum", "subscribe", "view.php?f=$forum->id", "$forum->id");
- redirect($returnto, get_string("nowsubscribed", "forum", "$forum->name"), 1);
+ redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
} else {
error("Could not subscribe you to that forum", "$HTTP_REFERER");
}