We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

logout.php 2.32 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1
<?php
Robin Millette's avatar
Robin Millette committed
2 3 4 5 6 7
/**
 * Logout action.
 *
 * PHP version 5
 *
 * @category Action
8
 * @package  StatusNet
9 10
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
11
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
13
 *
14
 * StatusNet - the distributed open-source microblogging tool
15
 * Copyright (C) 2008, 2009, StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
16
 *
Evan Prodromou's avatar
Evan Prodromou committed
17 18 19 20
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
Evan Prodromou's avatar
Evan Prodromou committed
21
 *
Evan Prodromou's avatar
Evan Prodromou committed
22 23 24 25
 * 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 Affero General Public License for more details.
Evan Prodromou's avatar
Evan Prodromou committed
26
 *
Evan Prodromou's avatar
Evan Prodromou committed
27 28 29 30
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

31
if (!defined('STATUSNET') && !defined('LACONICA')) {
Robin Millette's avatar
Robin Millette committed
32 33
    exit(1);
}
Evan Prodromou's avatar
Evan Prodromou committed
34

Robin Millette's avatar
Robin Millette committed
35 36 37 38
/**
 * Logout action class.
 *
 * @category Action
39
 * @package  StatusNet
40 41
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
42
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
44
 */
45 46
class LogoutAction extends Action
{
47

Robin Millette's avatar
Robin Millette committed
48 49
    /**
     * This is read only.
50
     *
Robin Millette's avatar
Robin Millette committed
51 52
     * @return boolean true
     */
53
    function isReadOnly($args)
54
    {
55
        return false;
56
    }
Robin Millette's avatar
Robin Millette committed
57 58 59

    /**
     * Class handler.
60
     *
Robin Millette's avatar
Robin Millette committed
61 62 63 64
     * @param array $args array of arguments
     *
     * @return nothing
     */
65 66
    function handle($args)
    {
67 68
        parent::handle($args);
        if (!common_logged_in()) {
69
            // TRANS: Client error displayed trying to log out when not logged in.
70
            $this->clientError(_('Not logged in.'));
71
        } else {
72 73 74 75 76
            if (Event::handle('StartLogout', array($this))) {
                $this->logout();
            }
            Event::handle('EndLogout', array($this));

77
            common_redirect(common_local_url('public'), 303);
78 79
        }
    }
80 81 82 83 84

    function logout()
    {
        common_set_user(null);
        common_real_login(false); // not logged in
85
        common_forgetme(); // don't log back in!
86
    }
Evan Prodromou's avatar
Evan Prodromou committed
87
}