Completed
Push — actionrefactor ( 6e4bf0 )
by Andreas
04:36
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\ActionException;
6
7
/**
8
 * Class Logout
9
 *
10
 * Log out a user
11
 *
12
 * @package dokuwiki\Action
13
 */
14
class Logout extends AbstractUserAction {
15
16
    /** @inheritdoc */
17
    function minimumPermission() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
        return AUTH_NONE;
19
    }
20
21
    /** @inheritdoc */
22
    public function preProcess() {
23
        global $ID;
24
        global $INPUT;
25
26
        // when logging out during an edit session, unlock the page
27
        $lockedby = checklock($ID);
28
        if($lockedby == $INPUT->server->str('REMOTE_USER')) {
29
            unlock($ID);
30
        }
31
32
        // do the logout stuff and redirect to login
33
        auth_logoff();
34
        send_redirect(wl($ID, array('do' => 'login')));
35
36
        // should never be reached
37
        throw new ActionException('login');
38
    }
39
40
}
41