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