diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/backup/moodle2/backup_forum_stepslib.php moodle_2.5.0_forum/mod/forum/backup/moodle2/backup_forum_stepslib.php --- moodle_2.5.0/mod/forum/backup/moodle2/backup_forum_stepslib.php 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/backup/moodle2/backup_forum_stepslib.php 2013-08-04 20:28:18.000000000 +0100 @@ -41,10 +41,11 @@ $forum = new backup_nested_element('forum', array('id'), array( 'type', 'name', 'intro', 'introformat', 'assessed', 'assesstimestart', 'assesstimefinish', 'scale', - 'maxbytes', 'maxattachments', 'forcesubscribe', 'trackingtype', + 'maxbytes', 'maxattachments', 'forcesubscribe', 'threadsubscribe', 'trackingtype', 'rsstype', 'rssarticles', 'timemodified', 'warnafter', 'blockafter', 'blockperiod', 'completiondiscussions', 'completionreplies', 'completionposts', 'displaywordcount')); + // For thread-based discussion: supply 'threadsubscribe' as well $discussions = new backup_nested_element('discussions'); @@ -68,7 +69,7 @@ $subscriptions = new backup_nested_element('subscriptions'); $subscription = new backup_nested_element('subscription', array('id'), array( - 'userid')); + 'userid', 'thread')); $readposts = new backup_nested_element('readposts'); diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/backup/moodle2/restore_forum_stepslib.php moodle_2.5.0_forum/mod/forum/backup/moodle2/restore_forum_stepslib.php --- moodle_2.5.0/mod/forum/backup/moodle2/restore_forum_stepslib.php 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/backup/moodle2/restore_forum_stepslib.php 2013-08-04 23:33:04.000000000 +0100 @@ -145,6 +145,8 @@ $data->forum = $this->get_new_parentid('forum'); $data->userid = $this->get_mappingid('user', $data->userid); + // For thread-based discussion: supply additional mapping + $data->thread = $this->get_mappingid('forum_discussion', $data->thread); $newitemid = $DB->insert_record('forum_subscriptions', $data); } diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/db/upgrade.php moodle_2.5.0_forum/mod/forum/db/upgrade.php --- moodle_2.5.0/mod/forum/db/upgrade.php 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/db/upgrade.php 2013-08-04 11:46:56.000000000 +0100 @@ -85,6 +85,63 @@ // Moodle v2.5.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2013070900) { + + // Define field to be added to forum_subscriptions. + $table = new xmldb_table('forum_subscriptions'); + // $name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null + $field = new xmldb_field('thread', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'forum'); + + // Conditionally launch add field thread, + // But we are also going to use this field to be sure we CANNOT update 'forcesubscribe' AGAIN! + if (!$dbman->field_exists($table, $field)) { + // IS THERE ANY CAUSE FOR CONCERN HERE? CAN 'forcesubscribe' EVER BE DEFINED AS 'unsigned'??? + // Now switch subscription disabled from it value 3 to -1 so as to get sensible order + $forums = $DB->get_records('forum', array('forcesubscribe' => 3)); + foreach ($forums as $forum) { + $DB->set_field('forum', 'forcesubscribe', -1, array('id'=>$forum->id)); + } + $dbman->add_field($table, $field); + } + + // Define field to be added to forum_subscriptions. + $table = new xmldb_table('forum'); + $field = new xmldb_field('threadsubscribe', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'forcesubscribe'); + + // Conditionally launch add field thread, + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Forum savepoint reached. + upgrade_mod_savepoint(true, 2013070900, 'forum'); + } + + if ($oldversion < 2013070901) { + + // For thread-based subscriptions: we likely need to index thread in forum_subscriptions + // Define index forusubs_thr_ix (not unique) to be added to quiz_attempts + $table = new xmldb_table('forum_subscriptions'); + $index = new xmldb_index('thread', XMLDB_INDEX_NOTUNIQUE, array('thread')); + + // Conditionally launch add index thread + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Define field to be added to forum_queue: we now need to now the state of user's subscription + $table = new xmldb_table('forum_queue'); + $field = new xmldb_field('subscribestate', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'timemodified'); + + // Conditionally launch add field subscribestate, + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Forum savepoint reached. + upgrade_mod_savepoint(true, 2013070901, 'forum'); + } + return true; } diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/discuss.php moodle_2.5.0_forum/mod/forum/discuss.php --- moodle_2.5.0/mod/forum/discuss.php 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/discuss.php 2013-07-28 09:44:19.000000000 +0100 @@ -92,6 +92,17 @@ } $DB->set_field('forum_discussions', 'forum', $forumto->id, array('id' => $discussion->id)); $DB->set_field('forum_read', 'forumid', $forumto->id, array('discussionid' => $discussion->id)); + + // For thread-based subscriptions: move thread subscriptions to discussion in new forum + if (!empty($CFG->forum_subscriptionmodel)) { + // Note: don't test the particular state of any forum, as this may be changed independently of subscriptions + if ($threadsubscriptions = forum_get_thread_subscriptions(null, $forum->id, $discussion->id)) { + // we could edit the existing records, but this is way the new subscriptions have new ids. + forum_thread_unsubscribe(null, $forum->id, $discussion->id); + forum_copy_thread_subscriptions($threadsubscriptions, $forumto, $discussion->id); + } + } + add_to_log($course->id, 'forum', 'move discussion', "discuss.php?d=$discussion->id", $discussion->id, $cmto->id); require_once($CFG->libdir.'/rsslib.php'); diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/forum.js moodle_2.5.0_forum/mod/forum/forum.js --- moodle_2.5.0/mod/forum/forum.js 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/forum.js 2013-07-10 12:38:43.000000000 +0100 @@ -9,6 +9,14 @@ } } +function forum_produce_thread_subscribe_link(forumid, thread, backtoindex, ltext, ltitle) { + var elementid = "threadsubscriptionlink"; + var subs_link = document.getElementById(elementid); + if(subs_link){ + subs_link.innerHTML = ""+ltext+"<\/a>"; + } +} + function forum_produce_tracking_link(forumid, ltext, ltitle) { var elementid = "trackinglink"; var subs_link = document.getElementById(elementid); diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/index.php moodle_2.5.0_forum/mod/forum/index.php --- moodle_2.5.0/mod/forum/index.php 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/index.php 2013-07-31 11:08:23.000000000 +0100 @@ -248,7 +248,7 @@ if ($forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE) { $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes, 'unsubscribed' => $strno, 'forcesubscribed' => $stryes, - 'cantsubscribe' => '-'), false, false, true, $subscribed_forums); + 'cantsubscribe' => '-'), false, false, true, $subscribed_forums, true); } else { $row[] = '-'; } @@ -386,7 +386,7 @@ if ($forum->forcesubscribe != FORUM_DISALLOWSUBSCRIBE) { $row[] = forum_get_subscribe_link($forum, $context, array('subscribed' => $stryes, 'unsubscribed' => $strno, 'forcesubscribed' => $stryes, - 'cantsubscribe' => '-'), false, false, true, $subscribed_forums); + 'cantsubscribe' => '-'), false, false, true, $subscribed_forums, true); } else { $row[] = '-'; } diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/lang/en/forum.php moodle_2.5.0_forum/mod/forum/lang/en/forum.php --- moodle_2.5.0/mod/forum/lang/en/forum.php 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/lang/en/forum.php 2013-08-02 13:18:39.000000000 +0100 @@ -28,6 +28,7 @@ $string['addanewquestion'] = 'Add a new question'; $string['addanewtopic'] = 'Add a new topic'; $string['advancedsearch'] = 'Advanced search'; +$string['advancedsubscription'] = 'Advanced subscription model'; $string['allforums'] = 'All forums'; $string['allowdiscussions'] = 'Can a {$a} post to this forum?'; $string['allowsallsubscribe'] = 'This forum allows everyone to choose whether to subscribe or not'; @@ -101,9 +102,12 @@ $string['configoldpostdays'] = 'Number of days old any post is considered read.'; $string['configreplytouser'] = 'When a forum post is mailed out, should it contain the user\'s email address so that recipients can reply personally rather than via the forum? Even if set to \'Yes\' users can choose in their profile to keep their email address secret.'; $string['configshortpost'] = 'Any post under this length (in characters not including HTML) is considered short (see below).'; +$string['configsubscriptionmodel'] = 'A forum usually uses a Simple subscription model. The advanced subscription model makes thread-based subscriptions a possibility, but generally only very large installations would require this.'; $string['configtrackreadposts'] = 'Set to \'yes\' if you want to track read/unread for each user.'; $string['configusermarksread'] = 'If \'yes\', the user must manually mark a post as read. If \'no\', when the post is viewed it is marked as read.'; $string['confirmsubscribe'] = 'Do you really want to subscribe to forum \'{$a}\'?'; +$string['confirmthreadsubscribe'] = 'Do you really want to subscribe to the forum thread \'{$a}\'?'; +$string['confirmthreadunsubscribe'] = 'Do you really want to unsubscribe from the forum thread \'{$a}\'?'; $string['confirmunsubscribe'] = 'Do you really want to unsubscribe from forum \'{$a}\'?'; $string['couldnotadd'] = 'Could not add your post due to an unknown error'; $string['couldnotdeletereplies'] = 'Sorry, that cannot be deleted as people have already responded to it'; @@ -150,8 +154,11 @@ $string['errorwhiledelete'] = 'An error occurred while deleting record.'; $string['everyonecanchoose'] = 'Everyone can choose to be subscribed'; $string['everyonecannowchoose'] = 'Everyone can now choose to be subscribed'; +$string['everyonecannowchoosethreads'] = 'Everyone can now choose which threads to subscribe to'; +$string['everyonegetsfirstthreadposts'] = 'Everyone now gets subscribed to threads they post to, and gets the initial post in any new discussion'; $string['everyoneisnowsubscribed'] = 'Everyone is now subscribed to this forum'; $string['everyoneissubscribed'] = 'Everyone is subscribed to this forum'; +$string['everyonesubscribedtothreadposts'] = 'Everyone is now gets subscribed to threads they post to'; $string['existingsubscribers'] = 'Existing subscribers'; $string['exportdiscussion'] = 'Export whole discussion'; $string['forcessubscribe'] = 'This forum forces everyone to be subscribed'; @@ -294,8 +301,12 @@ $string['nowallsubscribed'] = 'All forums in {$a} are subscribed.'; $string['nowallunsubscribed'] = 'All forums in {$a} are not subscribed.'; $string['nownotsubscribed'] = '{$a->name} will NOT be notified of new posts in \'{$a->forum}\''; +$string['nownotsubscribedbythreads'] = '{$a->name} will NOT be notified of new posts to threads in \'{$a->forum}\''; +$string['nownotsubscribedthread'] = '{$a->name} will NOT be notified of new posts in discussion \'{$a->dname}\''; $string['nownottracking'] = '{$a->name} is no longer tracking \'{$a->forum}\'.'; $string['nowsubscribed'] = '{$a->name} will be notified of new posts in \'{$a->forum}\''; +$string['nowsubscribedbythread'] = '{$a->name} will be notified of new posts to subscribed threads in \'{$a->forum}\''; +$string['nowsubscribedthread'] = '{$a->name} will be notified of new posts in discussion \'{$a->dname}\''; $string['nowtracking'] = '{$a->name} is now tracking \'{$a->forum}\'.'; $string['numposts'] = '{$a} posts'; $string['olderdiscussions'] = 'Older discussions'; @@ -374,6 +385,7 @@ $string['shortpost'] = 'Short post'; $string['showsubscribers'] = 'Show/edit current subscribers'; $string['singleforum'] = 'A single simple discussion'; +$string['simplesubscription'] = 'Simple subscription model'; $string['smallmessage'] = '{$a->user} posted in {$a->forumname}'; $string['startedby'] = 'Started by'; $string['subject'] = 'Subject'; @@ -381,29 +393,53 @@ $string['subscribeall'] = 'Subscribe everyone to this forum'; $string['subscribeenrolledonly'] = 'Sorry, only enrolled users are allowed to subscribe to forum post notifications.'; $string['subscribed'] = 'Subscribed'; +$string['subscribedq'] = 'Subscribed?'; $string['subscribenone'] = 'Unsubscribe everyone from this forum'; $string['subscribers'] = 'Subscribers'; $string['subscribersto'] = 'Subscribers to \'{$a}\''; $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['subscribethread'] = 'Subscribe to this thread'; +$string['subscribethreadsonly'] = 'Subscribe to threads only'; $string['subscription'] = 'Subscription'; $string['subscription_help'] = 'If you are subscribed to a forum it means you will receive email copies of forum posts. Usually you can choose whether you wish to be subscribed, though sometimes subscription is forced so that everyone receives email copies of forum posts.'; $string['subscriptionandtracking'] = 'Subscription and tracking'; $string['subscriptionmode'] = 'Subscription mode'; $string['subscriptionmode_help'] = 'When a participant is subscribed to a forum it means they will receive forum post notifications. There are 4 subscription mode options: +* Subscription disabled - Subscriptions are not allowed +* Optional subscription - Participants can choose whether to be subscribed +* Forced subscription - Everyone is subscribed and cannot unsubscribe +* Auto subscription - Everyone is subscribed initially but can choose to unsubscribe at any time'; +$string['subscriptionmodeadv'] = 'Advanced subscription mode'; +$string['subscriptionmodeadv_help'] = 'When a participant is subscribed to a forum it means they will receive forum post notifications. There are 7 subscription mode options in this advanced model: + +* Subscription disabled - Subscriptions are not allowed * Optional subscription - Participants can choose whether to be subscribed * Forced subscription - Everyone is subscribed and cannot unsubscribe * Auto subscription - Everyone is subscribed initially but can choose to unsubscribe at any time -* Subscription disabled - Subscriptions are not allowed'; +* Optional thread subscription - Participants can choose whether to be subscribed to a thread or the entire forum +* Auto thread subscription - Everyone is subscribed automatically to a \'thread\' by posting to that discussion, but can unsubscribe at any time. +* Auto/initial thread subscription - This also automatically subscribes the user when posting to a discussion, but also sends the first post in any new discussion to every subscriber, so long as the user\'s own \'autosubscribe\' setting doesn\'t block this'; $string['subscriptionoptional'] = 'Optional subscription'; +$string['subscriptionoptionalthread'] = 'Optional thread subscription'; $string['subscriptionforced'] = 'Forced subscription'; $string['subscriptionauto'] = 'Auto subscription'; +$string['subscriptionautothread'] = 'Auto thread subscription'; $string['subscriptiondisabled'] = 'Subscription disabled'; +$string['subscriptioninitialthread'] = 'Auto/initial thread subscription'; +$string['subscriptionmodel'] = 'Subscription model'; $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['threadautosubscribed'] = 'Starting a new discussion permits you to receive to emails of replies to your discussion thread; however you can unsubscribe from this thread (or from the entire forum) at any time.'; +$string['threadsubscribe'] = 'Thread subscribe'; +$string['threadsubscribed'] = 'To threads'; +$string['threadsubscribednow'] = 'Send me email copies of posts to my subscribed threads'; +$string['threadsubscribestart'] = 'Send me email copies of posts to this thread'; +$string['threadsubscribestop'] = 'I don\'t want email copies of posts to this thread'; $string['timedposts'] = 'Timed posts'; $string['timestartenderror'] = 'Display end date cannot be earlier than the start date'; +$string['tothreads'] = 'To threads'; $string['trackforum'] = 'Track unread posts'; $string['tracking'] = 'Track'; $string['trackingoff'] = 'Off'; @@ -428,6 +464,7 @@ $string['unsubscribeallempty'] = 'You are not subscribed to any forums. To disable all notifications from this server go to Messaging in My Profile Settings.'; $string['unsubscribed'] = 'Unsubscribed'; $string['unsubscribeshort'] = 'Unsubscribe'; +$string['unsubscribethread'] = 'Unsubscribe from this thread'; $string['usermarksread'] = 'Manual message read marking'; $string['viewalldiscussions'] = 'View all discussions'; $string['warnafter'] = 'Post threshold for warning'; diff --exclude-from=exclude.txt -ru --unidirectional-new-file moodle_2.5.0/mod/forum/lib.php moodle_2.5.0_forum/mod/forum/lib.php --- moodle_2.5.0/mod/forum/lib.php 2013-06-14 04:53:28.000000000 +0100 +++ moodle_2.5.0_forum/mod/forum/lib.php 2013-08-04 20:02:51.000000000 +0100 @@ -36,10 +36,28 @@ define('FORUM_MODE_THREADED', 2); define('FORUM_MODE_NESTED', 3); +// For thread-based subscriptions: use in new 'forum_subscriptionmodel' setting +define('FORUM_SIMPLESUBSCRIPTION', 0); +define('FORUM_ADVANCEDSUBSCRIPTION', 1); + +// For thread-based subscriptions: use in new 'threadsubcribe' forum field +define('FORUM_NOTTHREADSUBSCRIBED', 0); +define('FORUM_THREADSUBSCRIBED', 1); + +// For thread-based subscriptions: FORUM_DISALLOWSUBSCRIBE now -1 (see db/upgrade); 3 & 4 added +define('FORUM_DISALLOWSUBSCRIBE',-1); define('FORUM_CHOOSESUBSCRIBE', 0); define('FORUM_FORCESUBSCRIBE', 1); define('FORUM_INITIALSUBSCRIBE', 2); -define('FORUM_DISALLOWSUBSCRIBE',3); +define('FORUM_CHOOSETHREADSUBSCRIBE', 3); // Users free to choose thread subscribing +define('FORUM_AUTOTHREADSUBSCRIBE', 4); // Users free to choose thread subscribing, but posting subscribed to thread +define('FORUM_INITIALTHREADSUBSCRIBE', 5); // Users free to choose thread subscribing, but initially all subscribe + +// For thread-based subscriptions: to track user's subscription status +define('FORUM_NOSUBSCRIPTION', 0); +define('FORUM_FORUMSUBSCRIPTION', 1); +define('FORUM_THREADSUBSCRIPTION', 2); +define('FORUM_THREADANDFORUMSUBSCRIPTION', 3); define('FORUM_TRACKING_OFF', 0); define('FORUM_TRACKING_OPTIONAL', 1); @@ -264,6 +282,7 @@ } } + // Thread-based subscriptions: no problem here, this works of threading or non-threading if (!$DB->delete_records('forum_subscriptions', array('forum'=>$forum->id))) { $result = false; } @@ -515,10 +534,12 @@ // caching subscribed users of each forum if (!isset($subscribedusers[$forumid])) { $modcontext = context_module::instance($coursemodules[$forumid]->id); - if ($subusers = forum_subscribed_users($courses[$courseid], $forums[$forumid], 0, $modcontext, "u.*")) { + if ($subusers = forum_subscribed_users($courses[$courseid], $forums[$forumid], 0, $modcontext, "u.*", 'all')) { foreach ($subusers as $postuser) { // this user is subscribed to this forum - $subscribedusers[$forumid][$postuser->id] = $postuser->id; + // For thread-base subscriptions: the value at [$postuser->id] will now be an array of threads + // which can be as minimal as [0] => 1 + $subscribedusers[$forumid][$postuser->id][$postuser->thread] = 1; $userscount++; if ($userscount > FORUM_CRON_USER_CACHE) { // Store minimal user info. @@ -588,6 +609,27 @@ if (!isset($subscribedusers[$forum->id][$userto->id])) { continue; // user does not subscribe to this forum } + + // For thread-based subscriptions: Need to track kind of subscription user has + // Particular issue because in FORUM_INITIALTHREADSUBSCRIBE mode posts can be sent without subscription + $subscriptionstate = FORUM_FORUMSUBSCRIPTION; // the default presumption here + if (empty($subscribedusers[$forum->id][$userto->id][0])) { + // user is not subsribed to forum + $subscriptionstate = FORUM_NOSUBSCRIPTION; + if ($forum->threadsubscribe) { + // is user subscribed to this thread + if (!isset($subscribedusers[$forum->id][$userto->id][$discussion->id])) { + // using threads, but user not subscribed to this thread + if (!($forum->forcesubscribe == FORUM_INITIALTHREADSUBSCRIBE + && $post->parent == 0 && $userto->autosubscribe == 1)) { + // if forum not Auto/initial subscription mode, new discussion, requested by user... + continue; + } + } else { + $subscriptionstate = FORUM_THREADSUBSCRIPTION; + } + } + } // Don't send email if the forum is Q&A and the user has not posted // Initial topics are still mailed @@ -673,6 +715,7 @@ $queue->discussionid = $discussion->id; $queue->postid = $post->id; $queue->timemodified = $post->created; + $queue->subscribestate = $subscriptionstate; // For thread-based subscriptions $DB->insert_record('forum_queue', $queue); continue; } @@ -700,7 +743,7 @@ $postsubject = html_to_text("$shortname: ".format_string($post->subject, true)); $posttext = forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfrom, $userto); - $posthtml = forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto); + $posthtml = forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $subscriptionstate); // Send the post now! @@ -854,6 +897,9 @@ } $userdiscussions[$digestpost->userid][$digestpost->discussionid] = $digestpost->discussionid; $discussionposts[$digestpost->discussionid][$digestpost->postid] = $digestpost->postid; + // For thread-based subscriptions: need to keep subscription states + // We could eliminate this for non-thread model but only by adding in repeated tests!! + $subscribestates[$digestpost->userid][$digestpost->discussionid] = $digestpost->subscribestate; } $digestposts_rs->close(); /// Finished iteration, let's close the resultset @@ -910,6 +956,7 @@ $forum = $forums[$discussion->forum]; $course = $courses[$forum->course]; $cm = $coursemodules[$forum->id]; + $subscriptionstate = $subscribestates[$userid][$discussionid]; //override language cron_setup_user($userto, $course); @@ -1011,8 +1058,25 @@ } } } + if ($canunsubscribe) { - $posthtml .= "\n
wwwroot/mod/forum/subscribe.php?id=$forum->id\">".get_string("unsubscribe", "forum")."
"; + $subscribemsg = get_string("unsubscribe", "forum"); + $threadmsg = ''; + if ($forum->threadsubscribe) { + switch ($subscriptionstate) { + case FORUM_NOSUBSCRIPTION: + $subscribemsg = get_string("subscribethread", "forum"); + $threadmsg = "&thread=$discussion->id"; + break; + case FORUM_FORUMSUBSCRIPTION: + $subscribemsg = get_string("unsubscribe", "forum"); + break; + default: + $subscribemsg = get_string("unsubscribethread", "forum"); + $threadmsg = "&thread=$discussion->id"; + } + } + $posthtml .= "\n
wwwroot/mod/forum/subscribe.php?id=$forum->id$threadmsg\">".$subscribemsg."
"; } else { $posthtml .= "\n
".get_string("everyoneissubscribed", "forum")."
"; } @@ -1161,9 +1225,10 @@ * @param object $post * @param object $userfrom * @param object $userto + * @param bool $subscriptionstate - true if we are providing a thread subscribe link, otherwise false * @return string The email text in HTML format */ -function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto) { +function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $subscriptionstate=false) { global $CFG; if ($userto->mailformat != 1) { // Needs to be HTML @@ -1201,8 +1266,32 @@ $posthtml .= forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false); if ($canunsubscribe) { - $posthtml .= '