From 739da48c01cacea24d2e8fada94c18f3cdf2caca Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 7 Jul 2008 21:51:01 +0000 Subject: [PATCH] MDL-15561 unsubscribe all option implemented --- lang/en_utf8/forum.php | 4 +++ mod/forum/lib.php | 5 ++-- mod/forum/unsubscribeall.php | 47 ++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 mod/forum/unsubscribeall.php diff --git a/lang/en_utf8/forum.php b/lang/en_utf8/forum.php index 2f760470a7..dd280f6364 100644 --- a/lang/en_utf8/forum.php +++ b/lang/en_utf8/forum.php @@ -291,6 +291,10 @@ $string['unreadposts'] = 'Unread posts'; $string['unreadpostsnumber'] = '$a unread posts'; $string['unreadpostsone'] = '1 unread post'; $string['unsubscribe'] = 'Unsubscribe from this forum'; +$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 your forum subscriptions were removed, you might still receive notifications from forums with forced subscription. If you do not want to receive any emails from this server please go to your profile and disable email address there.'; +$string['unsubscribeallempty'] = 'Sorry, you are not subscribed to any forums. If you do not want to receive any emails from this server please go to your profile and disable email address there.'; $string['unsubscribed'] = 'Unsubscribed'; $string['unsubscribeshort'] = 'Unsubscribe'; $string['usermarksread'] = 'Manual message read marking'; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 6ba5328ced..94ab2941cd 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -903,8 +903,9 @@ function forum_make_mail_html($course, $forum, $discussion, $post, $userfrom, $u $posthtml .= forum_make_mail_post($course, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false); if ($canunsubscribe) { - $posthtml .= '
'; + $posthtml .= '
'; } $posthtml .= ''; diff --git a/mod/forum/unsubscribeall.php b/mod/forum/unsubscribeall.php new file mode 100644 index 0000000000..5cd684551b --- /dev/null +++ b/mod/forum/unsubscribeall.php @@ -0,0 +1,47 @@ +wwwroot.'/'; + +if (isguestuser()) { + redirect($return); +} + +$strunsubscribeall = get_string('unsubscribeall', 'forum'); +$navlinks = array(array('name' => get_string('modulename', 'forum'), 'link' => null, 'type' => 'misc'), + array('name' => $strunsubscribeall, 'link' => null, 'type' => 'misc')); +$navigation = build_navigation($navlinks); + +print_header($strunsubscribeall, format_string($COURSE->fullname), $navigation); +print_heading($strunsubscribeall); + +if (data_submitted() and $confirm and confirm_sesskey()) { + $DB->delete_records('forum_subscriptions', array('userid'=>$USER->id)); + $DB->set_field('user', 'autosubscribe', 0, array('id'=>$USER->id)); + print_box(get_string('unsubscribealldone', 'forum')); + print_continue($return); + print_footer(); + die; + +} else { + $a = $DB->count_records('forum_subscriptions', array('userid'=>$USER->id)); + + if ($a) { + $msg = get_string('unsubscribeallconfirm', 'forum', $a); + notice_yesno($msg, 'unsubscribeall.php', $return, array('confirm'=>1, 'sesskey'=>sesskey()), NULL, 'post', 'get'); + print_footer(); + die; + + } else { + print_box(get_string('unsubscribeallempty', 'forum')); + print_continue($return); + print_footer(); + die; + } +} -- 2.39.5