Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
// This file is part of Moodle - http://moodle.org/
4
//
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.
9
//
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.
14
//
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/>.
17
 
18
/**
19
 * Logs the user out and sends them to the home page
20
 *
21
 * @package    core
22
 * @subpackage auth
23
 * @copyright  1999 onwards Martin Dougiamas  http://dougiamas.com
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
 
27
require_once('../config.php');
28
 
29
$PAGE->set_url('/login/logout.php');
30
$PAGE->set_context(context_system::instance());
31
 
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);
34
 
35
// can be overridden by auth plugins
36
if ($login) {
37
    $redirect = get_login_url();
38
} else {
39
    $redirect = $CFG->wwwroot.'/';
40
}
41
 
42
if (!isloggedin()) {
43
    // no confirmation, user has already logged out
44
    require_logout();
45
    redirect($redirect);
46
 
47
} else if (!confirm_sesskey($sesskey)) {
48
    $PAGE->set_title(get_string('logout'));
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();
53
    die;
54
}
55
 
56
$authsequence = get_enabled_auth_plugins(); // auths, in sequence
57
foreach($authsequence as $authname) {
58
    $authplugin = get_auth_plugin($authname);
59
    $authplugin->logoutpage_hook();
60
}
61
 
62
require_logout();
63
 
64
redirect($redirect);