xref: /dokuwiki/inc/Action/Logout.php (revision ec7012214a693c8b3103377245a7d797cf8f9608)
164ab5140SAndreas Gohr<?php
264ab5140SAndreas Gohr
364ab5140SAndreas Gohrnamespace dokuwiki\Action;
464ab5140SAndreas Gohr
564ab5140SAndreas Gohruse dokuwiki\Action\Exception\ActionException;
664ab5140SAndreas Gohr
7ab583a1bSAndreas Gohr/**
8ab583a1bSAndreas Gohr * Class Logout
9ab583a1bSAndreas Gohr *
10ab583a1bSAndreas Gohr * Log out a user
11ab583a1bSAndreas Gohr *
12ab583a1bSAndreas Gohr * @package dokuwiki\Action
13ab583a1bSAndreas Gohr */
14ab583a1bSAndreas Gohrclass Logout extends AbstractUserAction {
1564ab5140SAndreas Gohr
1664ab5140SAndreas Gohr    /** @inheritdoc */
17*ec701221SAndreas Gohr    public function minimumPermission() {
1864ab5140SAndreas Gohr        return AUTH_NONE;
1964ab5140SAndreas Gohr    }
2064ab5140SAndreas Gohr
2164ab5140SAndreas Gohr    /** @inheritdoc */
2264ab5140SAndreas Gohr    public function preProcess() {
2364ab5140SAndreas Gohr        global $ID;
2464ab5140SAndreas Gohr        global $INPUT;
2564ab5140SAndreas Gohr
2664ab5140SAndreas Gohr        // when logging out during an edit session, unlock the page
2764ab5140SAndreas Gohr        $lockedby = checklock($ID);
2864ab5140SAndreas Gohr        if($lockedby == $INPUT->server->str('REMOTE_USER')) {
2964ab5140SAndreas Gohr            unlock($ID);
3064ab5140SAndreas Gohr        }
3164ab5140SAndreas Gohr
3264ab5140SAndreas Gohr        // do the logout stuff and redirect to login
3364ab5140SAndreas Gohr        auth_logoff();
3464ab5140SAndreas Gohr        send_redirect(wl($ID, array('do' => 'login')));
3564ab5140SAndreas Gohr
3664ab5140SAndreas Gohr        // should never be reached
3764ab5140SAndreas Gohr        throw new ActionException('login');
3864ab5140SAndreas Gohr    }
3964ab5140SAndreas Gohr
4064ab5140SAndreas Gohr}
41