[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

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

   1  <?php
   2  
   3  namespace dokuwiki\Action;
   4  
   5  use dokuwiki\Action\Exception\ActionAbort;
   6  use dokuwiki\Action\Exception\ActionDisabledException;
   7  use dokuwiki\Extension\AuthPlugin;
   8  use dokuwiki\Ui;
   9  
  10  /**
  11   * Class Register
  12   *
  13   * Self registering a new user
  14   *
  15   * @package dokuwiki\Action
  16   */
  17  class Register extends AbstractAclAction
  18  {
  19      /** @inheritdoc */
  20      public function minimumPermission()
  21      {
  22          return AUTH_NONE;
  23      }
  24  
  25      /** @inheritdoc */
  26      public function checkPreconditions()
  27      {
  28          parent::checkPreconditions();
  29  
  30          /** @var AuthPlugin $auth */
  31          global $auth;
  32          global $conf;
  33          if (isset($conf['openregister']) && !$conf['openregister']) throw new ActionDisabledException();
  34          if (!$auth->canDo('addUser')) throw new ActionDisabledException();
  35      }
  36  
  37      /** @inheritdoc */
  38      public function preProcess()
  39      {
  40          if (register()) { // FIXME could be moved from auth to here
  41              throw new ActionAbort('login');
  42          }
  43      }
  44  
  45      /** @inheritdoc */
  46      public function tplContent()
  47      {
  48          (new Ui\UserRegister)->show();
  49      }
  50  
  51  }