1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-04 07:52:48 +02:00

MDL-47390 mod_forum: Add discussion unsub to email footer

This commit is contained in:
Andrew Nicols 2014-10-28 14:25:51 +08:00
parent 4f82670250
commit 4e3af3cf42
2 changed files with 30 additions and 11 deletions
mod/forum

@ -489,6 +489,7 @@ $string['unreadposts'] = 'Unread posts';
$string['unreadpostsnumber'] = '{$a} unread posts';
$string['unreadpostsone'] = '1 unread post';
$string['unsubscribe'] = 'Unsubscribe from this forum';
$string['unsubscribediscussion'] = 'Unsubscribe from this discussion';
$string['unsubscribeall'] = 'Unsubscribe from all forums';
$string['unsubscribeallconfirm'] = 'You are subscribed to {$a} forums now. Do you really want to unsubscribe from all forums and disable forum auto-subscribe?';
$string['unsubscribealldone'] = 'All optional forum subscriptions were removed. You will still receive notifications from forums with forced subscription. To manage forum notifications go to Messaging in My Profile Settings.';

@ -1175,7 +1175,7 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro
$strforums = get_string('forums', 'forum');
$canunsubscribe = ! \mod_forum\subscriptions::is_forcesubscribed($forum);
$canunsubscribe = !\mod_forum\subscriptions::is_forcesubscribed($forum);
$posttext = '';
@ -1204,15 +1204,25 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro
$posttext .= "\n\n";
$posttext .= forum_print_attachments($post, $cm, "text");
if (!$bare && $canreply) {
$posttext .= "---------------------------------------------------------------------\n";
$posttext .= get_string("postmailinfo", "forum", $shortname)."\n";
$posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id\n";
}
if (!$bare && $canunsubscribe) {
$posttext .= "\n---------------------------------------------------------------------\n";
$posttext .= get_string("unsubscribe", "forum");
$posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?id=$forum->id\n";
if (!$bare) {
if ($canreply) {
$posttext .= "---------------------------------------------------------------------\n";
$posttext .= get_string("postmailinfo", "forum", $shortname)."\n";
$posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id\n";
}
if ($canunsubscribe) {
if (\mod_forum\subscriptions::is_subscribed($userto->id, $forum, null, $cm)) {
// If subscribed to this forum, offer the unsubscribe link.
$posttext .= "\n---------------------------------------------------------------------\n";
$posttext .= get_string("unsubscribe", "forum");
$posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?id=$forum->id\n";
}
// Always offer the unsubscribe from discussion link.
$posttext .= "\n---------------------------------------------------------------------\n";
$posttext .= get_string("unsubscribediscussion", "forum");
$posttext .= ": $CFG->wwwroot/mod/forum/subscribe.php?d=$discussion->id\n";
}
}
$posttext .= "\n---------------------------------------------------------------------\n";
@ -1283,7 +1293,15 @@ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfro
$footerlinks = array();
if ($canunsubscribe) {
$footerlinks[] = '<a href="' . $CFG->wwwroot . '/mod/forum/subscribe.php?id=' . $forum->id . '">' . get_string('unsubscribe', 'forum') . '</a>';
if (\mod_forum\subscriptions::is_subscribed($userto->id, $forum, null, $cm)) {
// If subscribed to this forum, offer the unsubscribe link.
$unsublink = new moodle_url('/mod/forum/subscribe.php', array('id' => $forum->id));
$footerlinks[] = html_writer::link($unsublink, get_string('unsubscribe', 'mod_forum'));
}
// Always offer the unsubscribe from discussion link.
$unsublink = new moodle_url('/mod/forum/subscribe.php', array('d' => $discussion->id));
$footerlinks[] = html_writer::link($unsublink, get_string('unsubscribediscussion', 'mod_forum'));
$footerlinks[] = '<a href="' . $CFG->wwwroot . '/mod/forum/unsubscribeall.php">' . get_string('unsubscribeall', 'forum') . '</a>';
}
$footerlinks[] = "<a href='{$CFG->wwwroot}/mod/forum/index.php?id={$forum->course}'>" . get_string('digestmailpost', 'forum') . '</a>';