164ab5140SAndreas Gohr<?php 264ab5140SAndreas Gohr 364ab5140SAndreas Gohrnamespace dokuwiki\Action; 464ab5140SAndreas Gohr 5480336a3SAndreas Gohruse dokuwiki\Action\Exception\ActionDisabledException; 664ab5140SAndreas Gohruse dokuwiki\Action\Exception\ActionException; 7*79a2d784SGerrit Uitslaguse dokuwiki\Extension\AuthPlugin; 864ab5140SAndreas Gohr 9ab583a1bSAndreas Gohr/** 10ab583a1bSAndreas Gohr * Class Logout 11ab583a1bSAndreas Gohr * 12ab583a1bSAndreas Gohr * Log out a user 13ab583a1bSAndreas Gohr * 14ab583a1bSAndreas Gohr * @package dokuwiki\Action 15ab583a1bSAndreas Gohr */ 16ab583a1bSAndreas Gohrclass Logout extends AbstractUserAction { 1764ab5140SAndreas Gohr 1864ab5140SAndreas Gohr /** @inheritdoc */ 19ec701221SAndreas Gohr public function minimumPermission() { 2064ab5140SAndreas Gohr return AUTH_NONE; 2164ab5140SAndreas Gohr } 2264ab5140SAndreas Gohr 2364ab5140SAndreas Gohr /** @inheritdoc */ 24b2c9cd19SAndreas Gohr public function checkPreconditions() { 25b2c9cd19SAndreas Gohr parent::checkPreconditions(); 26480336a3SAndreas Gohr 27*79a2d784SGerrit Uitslag /** @var AuthPlugin $auth */ 28480336a3SAndreas Gohr global $auth; 29480336a3SAndreas Gohr if(!$auth->canDo('logout')) throw new ActionDisabledException(); 30480336a3SAndreas Gohr } 31480336a3SAndreas Gohr 32480336a3SAndreas Gohr /** @inheritdoc */ 3364ab5140SAndreas Gohr public function preProcess() { 3464ab5140SAndreas Gohr global $ID; 3564ab5140SAndreas Gohr global $INPUT; 3664ab5140SAndreas Gohr 376a25531dSAndreas Gohr if (!checkSecurityToken()) throw new ActionException(); 386a25531dSAndreas Gohr 3964ab5140SAndreas Gohr // when logging out during an edit session, unlock the page 4064ab5140SAndreas Gohr $lockedby = checklock($ID); 4164ab5140SAndreas Gohr if($lockedby == $INPUT->server->str('REMOTE_USER')) { 4264ab5140SAndreas Gohr unlock($ID); 4364ab5140SAndreas Gohr } 4464ab5140SAndreas Gohr 4564ab5140SAndreas Gohr // do the logout stuff and redirect to login 4664ab5140SAndreas Gohr auth_logoff(); 472eb1177eSPhy send_redirect(wl($ID, array('do' => 'login'), true, '&')); 4864ab5140SAndreas Gohr 4964ab5140SAndreas Gohr // should never be reached 5064ab5140SAndreas Gohr throw new ActionException('login'); 5164ab5140SAndreas Gohr } 5264ab5140SAndreas Gohr 5364ab5140SAndreas Gohr} 54