1<?php 2 3namespace dokuwiki\Action; 4 5use dokuwiki\Action\Exception\ActionDisabledException; 6use dokuwiki\Action\Exception\ActionException; 7 8/** 9 * Class Logout 10 * 11 * Log out a user 12 * 13 * @package dokuwiki\Action 14 */ 15class Logout extends AbstractUserAction { 16 17 /** @inheritdoc */ 18 public function minimumPermission() { 19 return AUTH_NONE; 20 } 21 22 /** @inheritdoc */ 23 public function checkPreconditions() { 24 parent::checkPreconditions(); 25 26 /** @var \dokuwiki\Extension\AuthPlugin $auth */ 27 global $auth; 28 if(!$auth->canDo('logout')) throw new ActionDisabledException(); 29 } 30 31 /** @inheritdoc */ 32 public function preProcess() { 33 global $ID; 34 global $INPUT; 35 36 if (!checkSecurityToken()) throw new ActionException(); 37 38 // when logging out during an edit session, unlock the page 39 $lockedby = checklock($ID); 40 if($lockedby == $INPUT->server->str('REMOTE_USER')) { 41 unlock($ID); 42 } 43 44 // do the logout stuff and redirect to login 45 auth_logoff(); 46 send_redirect(wl($ID, array('do' => 'login'), true, '&')); 47 48 // should never be reached 49 throw new ActionException('login'); 50 } 51 52} 53