UserProfile.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace dokuwiki\Ui;
  3. use dokuwiki\Extension\AuthPlugin;
  4. use dokuwiki\Form\Form;
  5. /**
  6. * DokuWiki User Profile Interface
  7. *
  8. * @package dokuwiki\Ui
  9. */
  10. class UserProfile extends Ui
  11. {
  12. /**
  13. * Display the User Profile Form Panel
  14. *
  15. * @author Andreas Gohr <andi@splitbrain.org>
  16. *
  17. * @return void
  18. */
  19. public function show()
  20. {
  21. global $lang;
  22. global $conf;
  23. global $INPUT;
  24. global $INFO;
  25. /** @var AuthPlugin $auth */
  26. global $auth;
  27. // print intro
  28. print p_locale_xhtml('updateprofile');
  29. print '<div class="centeralign">';
  30. $fullname = $INPUT->post->str('fullname', $INFO['userinfo']['name'], true);
  31. $email = $INPUT->post->str('email', $INFO['userinfo']['mail'], true);
  32. // create the updateprofile form
  33. $form = new Form(['id' => 'dw__register']);
  34. $form->addTagOpen('div')->addClass('no');
  35. $form->addFieldsetOpen($lang['profile']);
  36. $form->setHiddenField('do', 'profile');
  37. $form->setHiddenField('save', '1');
  38. $attr = array('size' => '50', 'disabled' => 'disabled');
  39. $input = $form->addTextInput('login', $lang['user'])->attrs($attr)->addClass('edit')
  40. ->val($INPUT->server->str('REMOTE_USER'));
  41. $input->getLabel()->attr('class', 'block');
  42. $form->addHTML("<br>\n");
  43. $attr = array('size' => '50');
  44. if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled';
  45. $input = $form->addTextInput('fullname', $lang['fullname'])->attrs($attr)->addClass('edit')
  46. ->val($fullname);
  47. $input->getLabel()->attr('class', 'block');
  48. $form->addHTML("<br>\n");
  49. $attr = array('type' => 'email', 'size' => '50');
  50. if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled';
  51. $input = $form->addTextInput('email', $lang['email'])->attrs($attr)->addClass('edit')
  52. ->val($email);
  53. $input->getLabel()->attr('class', 'block');
  54. $form->addHTML("<br>\n");
  55. if ($auth->canDo('modPass')) {
  56. $attr = array('size'=>'50');
  57. $input = $form->addPasswordInput('newpass', $lang['newpass'])->attrs($attr)->addClass('edit');
  58. $input->getLabel()->attr('class', 'block');
  59. $form->addHTML("<br>\n");
  60. $input = $form->addPasswordInput('passchk', $lang['passchk'])->attrs($attr)->addClass('edit');
  61. $input->getLabel()->attr('class', 'block');
  62. $form->addHTML("<br>\n");
  63. }
  64. if ($conf['profileconfirm']) {
  65. $form->addHTML("<br>\n");
  66. $attr = array('size' => '50', 'required' => 'required');
  67. $input = $form->addPasswordInput('oldpass', $lang['oldpass'])->attrs($attr)->addClass('edit');
  68. $input->getLabel()->attr('class', 'block');
  69. $form->addHTML("<br>\n");
  70. }
  71. $form->addButton('', $lang['btn_save'])->attr('type', 'submit');
  72. $form->addButton('', $lang['btn_reset'])->attr('type', 'reset');
  73. $form->addFieldsetClose();
  74. $form->addTagClose('div');
  75. print $form->toHTML('UpdateProfile');
  76. if ($auth->canDo('delUser') && actionOK('profile_delete')) {
  77. // create the profiledelete form
  78. $form = new Form(['id' => 'dw__profiledelete']);
  79. $form->addTagOpen('div')->addClass('no');
  80. $form->addFieldsetOpen($lang['profdeleteuser']);
  81. $form->setHiddenField('do', 'profile_delete');
  82. $form->setHiddenField('delete', '1');
  83. $form->addCheckbox('confirm_delete', $lang['profconfdelete'])
  84. ->attrs(['required' => 'required'])
  85. ->id('dw__confirmdelete')
  86. ->val('1');
  87. if ($conf['profileconfirm']) {
  88. $form->addHTML("<br>\n");
  89. $attr = array('size' => '50', 'required' => 'required');
  90. $input = $form->addPasswordInput('oldpass', $lang['oldpass'])->attrs($attr)
  91. ->addClass('edit');
  92. $input->getLabel()->attr('class', 'block');
  93. $form->addHTML("<br>\n");
  94. }
  95. $form->addButton('', $lang['btn_deleteuser'])->attr('type', 'submit');
  96. $form->addFieldsetClose();
  97. $form->addTagClose('div');
  98. print $form->toHTML('ProfileDelete');
  99. }
  100. print '</div>';
  101. }
  102. }