164ab5140SAndreas Gohr<?php 264ab5140SAndreas Gohr 364ab5140SAndreas Gohrnamespace dokuwiki\Action; 464ab5140SAndreas Gohr 5480336a3SAndreas Gohruse dokuwiki\Action\Exception\ActionDisabledException; 664ab5140SAndreas Gohruse dokuwiki\Action\Exception\ActionException; 764ab5140SAndreas Gohr 8ab583a1bSAndreas Gohr/** 9ab583a1bSAndreas Gohr * Class Logout 10ab583a1bSAndreas Gohr * 11ab583a1bSAndreas Gohr * Log out a user 12ab583a1bSAndreas Gohr * 13ab583a1bSAndreas Gohr * @package dokuwiki\Action 14ab583a1bSAndreas Gohr */ 15ab583a1bSAndreas Gohrclass Logout extends AbstractUserAction { 1664ab5140SAndreas Gohr 1764ab5140SAndreas Gohr /** @inheritdoc */ 18ec701221SAndreas Gohr public function minimumPermission() { 1964ab5140SAndreas Gohr return AUTH_NONE; 2064ab5140SAndreas Gohr } 2164ab5140SAndreas Gohr 2264ab5140SAndreas Gohr /** @inheritdoc */ 23b2c9cd19SAndreas Gohr public function checkPreconditions() { 24b2c9cd19SAndreas Gohr parent::checkPreconditions(); 25480336a3SAndreas Gohr 26e1d9dcc8SAndreas Gohr /** @var \dokuwiki\Extension\AuthPlugin $auth */ 27480336a3SAndreas Gohr global $auth; 28480336a3SAndreas Gohr if(!$auth->canDo('logout')) throw new ActionDisabledException(); 29480336a3SAndreas Gohr } 30480336a3SAndreas Gohr 31480336a3SAndreas Gohr /** @inheritdoc */ 3264ab5140SAndreas Gohr public function preProcess() { 3364ab5140SAndreas Gohr global $ID; 3464ab5140SAndreas Gohr global $INPUT; 3564ab5140SAndreas Gohr 36*6a25531dSAndreas Gohr if (!checkSecurityToken()) throw new ActionException(); 37*6a25531dSAndreas Gohr 3864ab5140SAndreas Gohr // when logging out during an edit session, unlock the page 3964ab5140SAndreas Gohr $lockedby = checklock($ID); 4064ab5140SAndreas Gohr if($lockedby == $INPUT->server->str('REMOTE_USER')) { 4164ab5140SAndreas Gohr unlock($ID); 4264ab5140SAndreas Gohr } 4364ab5140SAndreas Gohr 4464ab5140SAndreas Gohr // do the logout stuff and redirect to login 4564ab5140SAndreas Gohr auth_logoff(); 462eb1177eSPhy send_redirect(wl($ID, array('do' => 'login'), true, '&')); 4764ab5140SAndreas Gohr 4864ab5140SAndreas Gohr // should never be reached 4964ab5140SAndreas Gohr throw new ActionException('login'); 5064ab5140SAndreas Gohr } 5164ab5140SAndreas Gohr 5264ab5140SAndreas Gohr} 53