|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00024 require_once("../../config.php"); 00025 require_once("lib.php"); 00026 00027 $confirm = optional_param('confirm', false, PARAM_BOOL); 00028 00029 $PAGE->set_url('/mod/forum/unsubscribeall.php'); 00030 $PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id)); 00031 00032 // Do not autologin guest. Only proper users can have forum subscriptions. 00033 require_login(null, false); 00034 00035 $return = $CFG->wwwroot.'/'; 00036 00037 if (isguestuser()) { 00038 redirect($return); 00039 } 00040 00041 $strunsubscribeall = get_string('unsubscribeall', 'forum'); 00042 $PAGE->navbar->add(get_string('modulename', 'forum')); 00043 $PAGE->navbar->add($strunsubscribeall); 00044 $PAGE->set_title($strunsubscribeall); 00045 $PAGE->set_heading(format_string($COURSE->fullname)); 00046 echo $OUTPUT->header(); 00047 echo $OUTPUT->heading($strunsubscribeall); 00048 00049 if (data_submitted() and $confirm and confirm_sesskey()) { 00050 $DB->delete_records('forum_subscriptions', array('userid'=>$USER->id)); 00051 $DB->set_field('user', 'autosubscribe', 0, array('id'=>$USER->id)); 00052 echo $OUTPUT->box(get_string('unsubscribealldone', 'forum')); 00053 echo $OUTPUT->continue_button($return); 00054 echo $OUTPUT->footer(); 00055 die; 00056 00057 } else { 00058 $a = $DB->count_records('forum_subscriptions', array('userid'=>$USER->id)); 00059 00060 if ($a) { 00061 $msg = get_string('unsubscribeallconfirm', 'forum', $a); 00062 echo $OUTPUT->confirm($msg, new moodle_url('unsubscribeall.php', array('confirm'=>1)), $return); 00063 echo $OUTPUT->footer(); 00064 die; 00065 00066 } else { 00067 echo $OUTPUT->box(get_string('unsubscribeallempty', 'forum')); 00068 echo $OUTPUT->continue_button($return); 00069 echo $OUTPUT->footer(); 00070 die; 00071 } 00072 }