3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Logs the user out and sends them to the home page
23 * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once('../config.php');
29 $PAGE->set_url('/login/logout.php');
30 $PAGE->set_context(context_system
::instance());
32 $sesskey = optional_param('sesskey', '__notpresent__', PARAM_RAW
); // we want not null default to prevent required sesskey warning
33 $login = optional_param('loginpage', 0, PARAM_BOOL
);
35 // can be overridden by auth plugins
37 $redirect = get_login_url();
39 $redirect = $CFG->wwwroot
.'/';
43 // no confirmation, user has already logged out
47 } else if (!confirm_sesskey($sesskey)) {
48 $PAGE->set_title($SITE->fullname
);
49 $PAGE->set_heading($SITE->fullname
);
50 echo $OUTPUT->header();
51 echo $OUTPUT->confirm(get_string('logoutconfirm'), new moodle_url($PAGE->url
, array('sesskey'=>sesskey())), $CFG->wwwroot
.'/');
52 echo $OUTPUT->footer();
56 $authsequence = get_enabled_auth_plugins(); // auths, in sequence
57 foreach($authsequence as $authname) {
58 $authplugin = get_auth_plugin($authname);
59 $authplugin->logoutpage_hook();