UserResendPwd.php 2.8 KB

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