[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Ui/ -> UserResendPwd.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\Ui;
   4  
   5  use dokuwiki\Form\Form;
   6  
   7  /**
   8   * DokuWiki Resend Password Request Interface
   9   *
  10   * @package dokuwiki\Ui
  11   */
  12  class UserResendPwd extends Ui
  13  {
  14      /**
  15       * Display the form to request a new password for an existing account
  16       *
  17       * @return void
  18       * @author   Andreas Gohr <andi@splitbrain.org>
  19       *
  20       * @author   Benoit Chesneau <benoit@bchesneau.info>
  21       */
  22      public function show()
  23      {
  24          global $conf;
  25          global $INPUT;
  26  
  27          $token = preg_replace('/[^a-f0-9]+/', '', $INPUT->str('pwauth'));
  28  
  29          // print intro
  30          echo p_locale_xhtml('resetpwd');
  31          echo '<div class="centeralign">';
  32  
  33          if (!$conf['autopasswd'] && $token) {
  34              $form = $this->formSetNewPassword($token);
  35          } else {
  36              $form = $this->formResendPassword();
  37          }
  38  
  39          echo $form->toHTML('ResendPwd');
  40  
  41          echo '</div>';
  42      }
  43  
  44      /**
  45       * create a form ui to set new password
  46       *
  47       * @params string $token  cleaned pwauth request variable
  48       * @return Form
  49       */
  50      protected function formSetNewPassword($token)
  51      {
  52          global $lang;
  53  
  54          // create the form
  55          $form = new Form(['id' => 'dw__resendpwd']);
  56          $form->addTagOpen('div')->addClass('no');
  57          $form->addFieldsetOpen($lang['btn_resendpwd']);
  58          $form->setHiddenField('token', $token);
  59          $form->setHiddenField('do', 'resendpwd');
  60  
  61          $input = $form->addPasswordInput('pass', $lang['pass'])->attr('size', '50')->addClass('edit');
  62          $input->getLabel()->attr('class', 'block');
  63          $form->addHTML("<br>\n");
  64          $input = $form->addPasswordInput('passchk', $lang['passchk'])->attr('size', '50')->addClass('edit');
  65          $input->getLabel()->attr('class', 'block');
  66          $form->addHTML("<br>\n");
  67          $form->addButton('', $lang['btn_resendpwd'])->attr('type', 'submit');
  68          $form->addFieldsetClose();
  69          $form->addTagClose('div');
  70          return $form;
  71      }
  72  
  73      /**
  74       * create a form ui to request new password
  75       *
  76       * @return Form
  77       */
  78      protected function formResendPassword()
  79      {
  80          global $lang;
  81  
  82          // create the form
  83          $form = new Form(['id' => 'dw__resendpwd']);
  84          $form->addTagOpen('div')->addClass('no');
  85          $form->addFieldsetOpen($lang['btn_resendpwd']);
  86          $form->setHiddenField('do', 'resendpwd');
  87          $form->setHiddenField('save', '1');
  88          $form->addHTML("<br>\n");
  89  
  90          $input = $form->addTextInput('login', $lang['user'])->addClass('edit');
  91          $input->getLabel()->attr('class', 'block');
  92          $form->addHTML("<br>\n");
  93          $form->addHTML("<br>\n");
  94          $form->addButton('', $lang['btn_resendpwd'])->attr('type', 'submit');
  95          $form->addFieldsetClose();
  96          $form->addTagClose('div');
  97          return $form;
  98      }
  99  }