MDL-15561 unsubscribe all option implemented

This commit is contained in:
skodak
2008-07-07 21:51:01 +00:00
parent ac5efef6b5
commit 739da48c01
3 changed files with 54 additions and 2 deletions
+4
View File
@@ -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';
+3 -2
View File
@@ -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 .= '<hr /><div align="center" class="unsubscribelink"><a href="'.$CFG->wwwroot.'/mod/forum/subscribe.php?id='.$forum->id.'">'.
get_string('unsubscribe', 'forum').'</a></div>';
$posthtml .= '<hr /><div align="center" class="unsubscribelink">
<a href="'.$CFG->wwwroot.'/mod/forum/subscribe.php?id='.$forum->id.'">'.get_string('unsubscribe', 'forum').'</a>&nbsp;
<a href="'.$CFG->wwwroot.'/mod/forum/unsubscribeall.php">'.get_string('unsubscribeall', 'forum').'</a></div>';
}
$posthtml .= '</body>';
+47
View File
@@ -0,0 +1,47 @@
<?php //$Id$
require_once("../../config.php");
require_once("lib.php");
$confirm = optional_param('confirm', false, PARAM_BOOL);
require_login();
$return = $CFG->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;
}
}