-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlib.php
More file actions
60 lines (51 loc) · 2.01 KB
/
Copy pathlib.php
File metadata and controls
60 lines (51 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
*
* @package auth_anonymous
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
/**
* inline logout (no actions)
* can be called by a process (e.g. theme renderer) to ensure a user that has authenticated with anonymous gets logged out
* performs actions similar to require_logout() except doesn't process auth plugin pre and post hooks or redirects
*/
function auth_anonymous_autologout() {
global $USER, $DB;
if (isloggedin() && !isguestuser() && $USER->auth === 'anonymous') {
$sid = session_id();
$event = \core\event\user_loggedout::create(
array(
'userid' => $USER->id,
'objectid' => $USER->id,
'other' => array('sessionid' => $sid),
)
);
if ($session = $DB->get_record('sessions', array('sid'=>$sid))) {
$event->add_record_snapshot('sessions', $session);
}
// Delete session record and drop $_SESSION content.
\core\session\manager::terminate_current();
// Trigger event AFTER action.
$event->trigger();
// not sure if this is necessary, but it doesn't hurt
\core\session\manager::kill_user_sessions($USER->id);
// back to no user
$USER = new stdClass();
$USER->id = 0;
}
}