aboutsummaryrefslogtreecommitdiff
path: root/public/logout.php
blob: 6a5ac18816c0a4528b58ce22e2ecaf6469642f9e (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/*
logout.php - Ausloggen aus Stud.IP und aufräumen
Copyright (C) 2000 Stefan Suchi <suchi@gmx.de>, André Noack <andre.noack@gmx.net>,
Cornelis Kater <ckater@gwdg.de>

This program 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 2
of the License, or (at your option) any later version.

This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


require '../lib/bootstrap.php';

page_open(["sess" => "Seminar_Session", "auth" => "Seminar_Default_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"]);

require_once 'lib/messaging.inc.php';

//nur wenn wir angemeldet sind sollten wir dies tun!
if ($auth->auth['uid'] !== 'nobody') {
    $my_messaging_settings = $GLOBALS['user']->cfg->MESSAGING_SETTINGS;

    //Wenn Option dafuer gewaehlt, alle ungelsesenen Nachrichten als gelesen speichern
    if ($my_messaging_settings["logout_markreaded"]) {
        Message::markAllAs();
    }

    $logout_user = $user->id;
    $_language = $_SESSION['_language'];
    $contrast = UserConfig::get($GLOBALS['user']->id)->USER_HIGH_CONTRAST;

    // Get auth plugin of user before logging out since the $auth object will
    // be modified by the logout
    $auth_plugin = StudipAuthAbstract::getInstance($auth->auth['auth_plugin']);

    //Logout aus dem Sessionmanagement
    $auth->logout();
    $sess->delete();

    page_close();

    //Session changed zuruecksetzen
    $timeout=(time()-(15 * 60));
    $user->set_last_action($timeout);

    // Perform logout from auth plugin (if possible)
    if ($auth_plugin instanceof StudipAuthSSO) {
        $auth_plugin->logout();
    }

    $sess->start();
    $_SESSION['_language'] = $_language;
    if ($contrast) {
        $_SESSION['contrast'] = $contrast;
    }

    PageLayout::postSuccess(
        _('Sie sind nun aus dem System abgemeldet.'),
        array_filter((array) $GLOBALS['UNI_LOGOUT_ADD'])
    );
} else {
    $sess->delete();
    page_close();
}

header('Location: ' . URLHelper::getURL('index.php'));