[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Action/ -> Logout.php (source)

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