]> git.mjollnir.org Git - moodle.git/commitdiff
Teachers can now unsubscribe anyone from the "list of subscribers" list.
authormartin <martin>
Sat, 17 Aug 2002 07:53:32 +0000 (07:53 +0000)
committermartin <martin>
Sat, 17 Aug 2002 07:53:32 +0000 (07:53 +0000)
Made the feedback display when subscribing/unsubscribing a little more
generic.

lang/en/forum.php
mod/forum/subscribe.php
mod/forum/subscribers.php

index 56aed5e36628084d75ca8d9bc4cace04980dd84e..bc750122e89d56879befcc43b1ad3ac671e786ac 100644 (file)
@@ -47,8 +47,8 @@ $string[nameteacher] = "Teacher forum";
 $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";
index e1b97358d6155a17fdb992141ec5530a16b126e2..b7209eb01d809d3497461ba874c348e12e0f4458 100644 (file)
@@ -7,6 +7,7 @@
 
     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");
         }
index d6874c421e52d253e3b972abe5e29c064a83e370..519b0612b9851499a7cae1607b48c151fd77d2ca 100644 (file)
@@ -51,6 +51,8 @@
             echo "$user->firstname $user->lastname";
             echo "</TD><TD BGCOLOR=\"$THEME->cellcontent\">";
             echo "$user->email";
+            echo "</TD><TD>";
+            echo "<FONT SIZE=1><A HREF=\"subscribe.php?id=$forum->id&user=$user->id\">unsubscribe</A></FONT>";
             echo "</TD></TR>";
         }
         echo "</TABLE>";