Completed
Push — master ( 13ce47...b2c9cd )
by Andreas
10:39 queued 06:48
created

Logout::minimumPermission()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki\Action;
4
5
use dokuwiki\Action\Exception\ActionDisabledException;
6
use dokuwiki\Action\Exception\ActionException;
7
8
/**
9
 * Class Logout
10
 *
11
 * Log out a user
12
 *
13
 * @package dokuwiki\Action
14
 */
15
class Logout extends AbstractUserAction {
16
17
    /** @inheritdoc */
18
    public function minimumPermission() {
19
        return AUTH_NONE;
20
    }
21
22
    /** @inheritdoc */
23
    public function checkPreconditions() {
24
        parent::checkPreconditions();
25
26
        /** @var \DokuWiki_Auth_Plugin $auth */
27
        global $auth;
28
        if(!$auth->canDo('logout')) throw new ActionDisabledException();
29
    }
30
31
    /** @inheritdoc */
32
    public function preProcess() {
33
        global $ID;
34
        global $INPUT;
35
36
        // when logging out during an edit session, unlock the page
37
        $lockedby = checklock($ID);
38
        if($lockedby == $INPUT->server->str('REMOTE_USER')) {
39
            unlock($ID);
40
        }
41
42
        // do the logout stuff and redirect to login
43
        auth_logoff();
44
        send_redirect(wl($ID, array('do' => 'login')));
45
46
        // should never be reached
47
        throw new ActionException('login');
48
    }
49
50
}
51