MDL-25068 forum: fixed error string usage
authorDavid Mudrak <david.mudrak@gmail.com>
Tue, 7 Dec 2010 12:34:35 +0000 (12:34 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Tue, 7 Dec 2010 12:34:35 +0000 (12:34 +0000)
The string [cannotsubscribe,mod_forum] is supposed to be used for group
membership check only. I have fixed the two other usages of the string.
Note that the condition if (forum_subscribe()) was useless as the
function return true values only now after $DB conversion.

mod/forum/subscribe.php

index 9d7345a..75efa7b 100644 (file)
@@ -132,13 +132,9 @@ if (forum_is_subscribed($user->id, $forum->id)) {
         print_error('disallowsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
     }
     if (!has_capability('mod/forum:viewdiscussion', $context)) {
-        print_error('cannotsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
-    }
-    if (forum_subscribe($user->id, $forum->id) ) {
-        add_to_log($course->id, "forum", "subscribe", "view.php?f=$forum->id", $forum->id, $cm->id);
-        redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
-    } else {
-        print_error('cannotsubscribe', 'forum', $_SERVER["HTTP_REFERER"]);
+        print_error('noviewdiscussionspermission', 'forum', $_SERVER["HTTP_REFERER"]);
     }
+    forum_subscribe($user->id, $forum->id);
+    add_to_log($course->id, "forum", "subscribe", "view.php?f=$forum->id", $forum->id, $cm->id);
+    redirect($returnto, get_string("nowsubscribed", "forum", $info), 1);
 }
-