1*64ab5140SAndreas Gohr<?php 2*64ab5140SAndreas Gohr/** 3*64ab5140SAndreas Gohr * Created by IntelliJ IDEA. 4*64ab5140SAndreas Gohr * User: andi 5*64ab5140SAndreas Gohr * Date: 2/10/17 6*64ab5140SAndreas Gohr * Time: 12:08 PM 7*64ab5140SAndreas Gohr */ 8*64ab5140SAndreas Gohr 9*64ab5140SAndreas Gohrnamespace dokuwiki\Action; 10*64ab5140SAndreas Gohr 11*64ab5140SAndreas Gohruse dokuwiki\Action\Exception\ActionException; 12*64ab5140SAndreas Gohruse dokuwiki\Action\Exception\ActionNoUserException; 13*64ab5140SAndreas Gohr 14*64ab5140SAndreas Gohrclass Logout extends AbstractAclAction { 15*64ab5140SAndreas Gohr 16*64ab5140SAndreas Gohr /** @inheritdoc */ 17*64ab5140SAndreas Gohr function minimumPermission() { 18*64ab5140SAndreas Gohr return AUTH_NONE; 19*64ab5140SAndreas Gohr } 20*64ab5140SAndreas Gohr 21*64ab5140SAndreas Gohr /** @inheritdoc */ 22*64ab5140SAndreas Gohr public function checkPermissions() { 23*64ab5140SAndreas Gohr global $INPUT; 24*64ab5140SAndreas Gohr parent::checkPermissions(); 25*64ab5140SAndreas Gohr if(!$INPUT->server->has('REMOTE_USER')) { 26*64ab5140SAndreas Gohr throw new ActionNoUserException('login'); 27*64ab5140SAndreas Gohr } 28*64ab5140SAndreas Gohr } 29*64ab5140SAndreas Gohr 30*64ab5140SAndreas Gohr /** @inheritdoc */ 31*64ab5140SAndreas Gohr public function preProcess() { 32*64ab5140SAndreas Gohr global $ID; 33*64ab5140SAndreas Gohr global $INPUT; 34*64ab5140SAndreas Gohr 35*64ab5140SAndreas Gohr // when logging out during an edit session, unlock the page 36*64ab5140SAndreas Gohr $lockedby = checklock($ID); 37*64ab5140SAndreas Gohr if($lockedby == $INPUT->server->str('REMOTE_USER')) { 38*64ab5140SAndreas Gohr unlock($ID); 39*64ab5140SAndreas Gohr } 40*64ab5140SAndreas Gohr 41*64ab5140SAndreas Gohr // do the logout stuff and redirect to login 42*64ab5140SAndreas Gohr auth_logoff(); 43*64ab5140SAndreas Gohr send_redirect(wl($ID, array('do' => 'login'))); 44*64ab5140SAndreas Gohr 45*64ab5140SAndreas Gohr // should never be reached 46*64ab5140SAndreas Gohr throw new ActionException('login'); 47*64ab5140SAndreas Gohr } 48*64ab5140SAndreas Gohr 49*64ab5140SAndreas Gohr} 50