# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/mod/forum/lang/en/forum.php
--- moodle/mod/forum/lang/en/forum.php Base (1.2)
+++ moodle/mod/forum/lang/en/forum.php Locally Modified (Based On 1.2)
@@ -147,6 +147,7 @@
 $string['existingsubscribers'] = 'Existing subscribers';
 $string['forcessubscribe'] = 'This forum forces everyone to be subscribed';
 $string['forcesubscribe'] = 'Force everyone to be subscribed';
+$string['forcesubscribeinitial'] = 'Initially subscribe everyone';
 $string['forcesubscribeq'] = 'Force everyone to be subscribed?';
 $string['forum'] = 'Forum';
 $string['forum:addnews'] = 'Add news';
@@ -193,6 +194,7 @@
 $string['introteacher'] = 'A forum for teacher-only notes and discussion';
 $string['invalidaccess'] = 'This page was not accessed correctly';
 $string['invaliddiscussionid'] = 'Discussion ID was incorrect or no longer exists';
+$string['invalidforcesubscribe'] = 'Invalid force subscription mode';
 $string['invalidforumid'] = 'Forum ID was incorrect';
 $string['invalidparentpostid'] = 'Parent post ID was incorrect';
 $string['invalidpostid'] = 'Invalid Post ID - {$a}';
@@ -239,6 +241,7 @@
 $string['noguesttracking'] = 'Sorry, guests are not allowed to set tracking options.';
 $string['nomorepostscontaining'] = 'No more posts containing \'{$a}\' were found';
 $string['nonews'] = 'No news has been posted yet';
+$string['noonecansubscribenow'] = 'Subscriptions are now disallowed';
 $string['nopermissiontosubscribe'] = 'You do not have the permission to view forum subscribers';
 $string['nopermissiontoview'] = 'You do not have permissions to view this post';
 $string['nopostforum'] = 'Sorry, you are not allowed to post to this forum';
@@ -353,6 +356,7 @@
 $string['subscribestart'] = 'Send me email copies of posts to this forum';
 $string['subscribestop'] = 'I don\'t want email copies of posts to this forum';
 $string['subscription'] = 'Subscription';
+$string['subscriptionmode'] = 'Subscription mode';
 $string['subscriptions'] = 'Subscriptions';
 $string['thisforumisthrottled'] = 'This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at {$a->blockafter} posting(s) in {$a->blockperiod}';
 $string['timedposts'] = 'Timed posts';
Index: moodle/mod/forum/lib.php
--- moodle/mod/forum/lib.php Base (1.859)
+++ moodle/mod/forum/lib.php Locally Modified (Based On 1.859)
@@ -34,6 +34,7 @@
 define('FORUM_MODE_THREADED', 2);
 define('FORUM_MODE_NESTED', 3);
 
+define('FORUM_CHOOSESUBSCRIBE', 0);
 define('FORUM_FORCESUBSCRIBE', 1);
 define('FORUM_INITIALSUBSCRIBE', 2);
 define('FORUM_DISALLOWSUBSCRIBE',3);
@@ -4824,6 +4825,15 @@
     }
 }
 
+function forum_get_forcesubscribed($forum) {
+    global $DB;
+    if (isset($forum->forcesubscribe)) {    // then we use that
+        return $forum->forcesubscribe;
+    } else {   // Check the database
+        return $DB->get_field('forum', 'forcesubscribe', array('id' => $forum));
+    }
+}
+
 /**
  * @global object
  * @param int $userid
@@ -8029,39 +8039,45 @@
     if (is_enrolled($PAGE->cm->context)) { // means enrolled users only
         $notenode = false;
         $helpbutton = false;
-        if (forum_is_forcesubscribed($forumobject)) {
-            $notenode = $forumnode->add(get_string("forcessubscribe", 'forum'));
-            $string = get_string('allowchoice', 'forum');
-            $helpbutton = $OUTPUT->old_help_icon("subscription", $string, "forum");
-            if (has_capability('mod/forum:managesubscriptions', $PAGE->cm->context)) {
-                $url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'force'=>'no'));
-                $forumnode->add($string, $url, navigation_node::TYPE_SETTING);
-            } else {
-                $forumnode->add(get_string('everyoneisnowsubscribed', 'forum'), null, navigation_node::TYPE_SETTING);
+
+        $canmanage  = has_capability('mod/forum:managesubscriptions', $PAGE->cm->context);
+        $subscriptionmode = forum_get_forcesubscribed($forumobject);
+        $cansubscribe = ($subscriptionmode != FORUM_FORCESUBSCRIBE && ($subscriptionmode == FORUM_DISALLOWSUBSCRIBE || $canmanage));
+
+        $mode = $forumnode->add(get_string('subscriptionmode', 'forum'), null, navigation_node::TYPE_CONTAINER);
+        
+        $allowchoice = $mode->add(get_string('allowchoice', 'forum'), null, navigation_node::TYPE_SETTING);
+        $forceforever = $mode->add(get_string("forcesubscribe", "forum"), null, navigation_node::TYPE_SETTING);
+        $forceinitially = $mode->add(get_string("forcesubscribeinitial", "forum"), null, navigation_node::TYPE_SETTING);
+        $disallowchoice = $mode->add(get_string('disallowsubscribe', 'forum'), null, navigation_node::TYPE_SETTING);
+
+        if ($canmanage) {
+            $allowchoice->action = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>'0'));
+            $forceforever->action = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>'1'));
+            $forceinitially->action = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>'2'));
+            $disallowchoice->action = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>'3'));
             }
-        } else if ($forumobject->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
-            $string = get_string('disallowsubscribe', 'forum');
-            $notenode = $forumnode->add($string);
-            $helpbutton = $OUTPUT->old_help_icon("subscription", $string, "forum");
-        } else {
-            $string = get_string("forcesubscribe", "forum");
-            $notenode = $forumnode->add(get_string("allowsallsubscribe", 'forum'));
-            $helpbutton = $OUTPUT->old_help_icon("subscription", $string, "forum");
 
-            if (has_capability('mod/forum:managesubscriptions', $PAGE->cm->context)) {
-                $url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'force'=>'yes'));
-                $forumnode->add($string, $url, navigation_node::TYPE_SETTING);
-            } else {
-                $forumnode->add(get_string('everyonecannowchoose', 'forum'), null, navigation_node::TYPE_SETTING);
+        switch ($subscriptionmode) {
+            case FORUM_CHOOSESUBSCRIBE : // 0
+                $allowchoice->action = null;
+                $allowchoice->add_class('activesetting');
+                break;
+            case FORUM_FORCESUBSCRIBE : // 1
+                $forceforever->action = null;
+                $forceforever->add_class('activesetting');
+                break;
+            case FORUM_INITIALSUBSCRIBE : // 2
+                $forceinitially->action = null;
+                $forceinitially->add_class('activesetting');
+                break;
+            case FORUM_DISALLOWSUBSCRIBE : // 3
+                $disallowchoice->action = null;
+                $disallowchoice->add_class('activesetting');
+                break;
             }
-            if(has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)){
-                $url = new moodle_url('/mod/forum/subscribers.php', array('id'=>$forumobject->id));
-                $forumnode->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
-            }
 
-            if (forum_is_forcesubscribed($forumobject) || ($forumobject->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !has_capability('mod/forum:managesubscriptions', $PAGE->cm->context))) {
-                // Do nothing
-            } else {
+        if ($cansubscribe) {
                 if (forum_is_subscribed($USER->id, $forumobject)) {
                     $linktext = get_string('unsubscribe', 'forum');
                 } else {
@@ -8070,6 +8086,10 @@
                 $url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id));
                 $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
             }
+
+        if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)){
+            $url = new moodle_url('/mod/forum/subscribers.php', array('id'=>$forumobject->id));
+            $forumnode->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
         }
 
         if (forum_tp_can_track_forums($forumobject)) {
@@ -8081,13 +8101,7 @@
             $url = new moodle_url('/mod/forum/settracking.php', array('id'=>$forumobject->id));
             $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
         }
-        if ($notenode!==false) {
-            $notenode->add_class('note');
-            if ($helpbutton!==false) {
-                $notenode->helpbutton = $helpbutton;
             }
-        }
-    }
 
     if (!empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds) && $forumobject->rsstype && $forumobject->rssarticles) {
 
Index: moodle/mod/forum/mod_form.php
--- moodle/mod/forum/mod_form.php Base (1.43)
+++ moodle/mod/forum/mod_form.php Locally Modified (Based On 1.43)
@@ -52,11 +52,11 @@
         $this->add_intro_editor(true, get_string('forumintro', 'forum'));
 
         $options = array();
-        $options[0] = get_string('no');
-        $options[1] = get_string('yesforever', 'forum');
-        $options[FORUM_INITIALSUBSCRIBE] = get_string('yesinitially', 'forum');
+        $options[FORUM_CHOOSESUBSCRIBE] = get_string('allowchoice', 'forum');
+        $options[FORUM_FORCESUBSCRIBE] = get_string('forcesubscribe', 'forum');
+        $options[FORUM_INITIALSUBSCRIBE] = get_string('forcesubscribeinitial', 'forum');
         $options[FORUM_DISALLOWSUBSCRIBE] = get_string('disallowsubscribe','forum');
-        $mform->addElement('select', 'forcesubscribe', get_string('forcesubscribeq', 'forum'), $options);
+        $mform->addElement('select', 'forcesubscribe', get_string('subscriptionmode', 'forum'), $options);
         $mform->setHelpButton('forcesubscribe', array('subscription2', get_string('forcesubscribeq', 'forum'), 'forum'));
 
         $options = array();
Index: moodle/mod/forum/subscribe.php
--- moodle/mod/forum/subscribe.php Base (1.58)
+++ moodle/mod/forum/subscribe.php Locally Modified (Based On 1.58)
@@ -27,12 +27,12 @@
 require_once("lib.php");
 
 $id = required_param('id',PARAM_INT);      // The forum to subscribe or unsubscribe to
-$force = optional_param('force','',PARAM_ALPHA);  // Force everyone to be subscribed to this forum?
+$mode = optional_param('mode',false,PARAM_INT);  // Force everyone to be subscribed to this forum?
 $user = optional_param('user',0,PARAM_INT);
 
 $url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$id));
-if ($force !== '') {
-    $url->param('force', $force);
+if ($mode !== '') {
+    $url->param('force', $mode);
 }
 if ($user !== 0) {
     $url->param('user', $user);
@@ -88,13 +88,26 @@
     ? "index.php?id=".$course->id
     : "view.php?f=$id";
 
-if ($force and has_capability('mod/forum:managesubscriptions', $context)) {
-    if (forum_is_forcesubscribed($forum)) {
+if ($mode !== false && has_capability('mod/forum:managesubscriptions', $context)) {
+    switch ($mode) {
+        case FORUM_CHOOSESUBSCRIBE : // 0
         forum_forcesubscribe($forum->id, 0);
         redirect($returnto, get_string("everyonecannowchoose", "forum"), 1);
-    } else {
+            break;
+        case FORUM_FORCESUBSCRIBE : // 1
         forum_forcesubscribe($forum->id, 1);
         redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
+            break;
+        case FORUM_INITIALSUBSCRIBE : // 2
+            forum_forcesubscribe($forum->id, 2);
+            redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
+            break;
+        case FORUM_DISALLOWSUBSCRIBE : // 3
+            forum_forcesubscribe($forum->id, 3);
+            redirect($returnto, get_string("noonecansubscribenow", "forum"), 1);
+            break;
+        default:
+            print_error(get_string('invalidforcesubscribe', 'forum'));
     }
 }
 
