164ab5140SAndreas Gohr<?php 264ab5140SAndreas Gohr 364ab5140SAndreas Gohrnamespace dokuwiki\Action; 464ab5140SAndreas Gohr 5*480336a3SAndreas 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 */ 23*480336a3SAndreas Gohr public function checkPermissions() { 24*480336a3SAndreas Gohr parent::checkPermissions(); 25*480336a3SAndreas Gohr 26*480336a3SAndreas Gohr /** @var \DokuWiki_Auth_Plugin $auth */ 27*480336a3SAndreas Gohr global $auth; 28*480336a3SAndreas Gohr if(!$auth->canDo('logout')) throw new ActionDisabledException(); 29*480336a3SAndreas Gohr } 30*480336a3SAndreas Gohr 31*480336a3SAndreas Gohr /** @inheritdoc */ 3264ab5140SAndreas Gohr public function preProcess() { 3364ab5140SAndreas Gohr global $ID; 3464ab5140SAndreas Gohr global $INPUT; 3564ab5140SAndreas Gohr 3664ab5140SAndreas Gohr // when logging out during an edit session, unlock the page 3764ab5140SAndreas Gohr $lockedby = checklock($ID); 3864ab5140SAndreas Gohr if($lockedby == $INPUT->server->str('REMOTE_USER')) { 3964ab5140SAndreas Gohr unlock($ID); 4064ab5140SAndreas Gohr } 4164ab5140SAndreas Gohr 4264ab5140SAndreas Gohr // do the logout stuff and redirect to login 4364ab5140SAndreas Gohr auth_logoff(); 4464ab5140SAndreas Gohr send_redirect(wl($ID, array('do' => 'login'))); 4564ab5140SAndreas Gohr 4664ab5140SAndreas Gohr // should never be reached 4764ab5140SAndreas Gohr throw new ActionException('login'); 4864ab5140SAndreas Gohr } 4964ab5140SAndreas Gohr 5064ab5140SAndreas Gohr} 51