| Conditions | 8 |
| Paths | 48 |
| Total Lines | 103 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 21 | public function show() |
||
| 22 | { |
||
| 23 | global $lang; |
||
| 24 | global $conf; |
||
| 25 | global $INPUT; |
||
| 26 | global $INFO; |
||
| 27 | /** @var AuthPlugin $auth */ |
||
| 28 | global $auth; |
||
| 29 | |||
| 30 | // print intro |
||
| 31 | print p_locale_xhtml('updateprofile'); |
||
| 32 | print '<div class="centeralign">'; |
||
| 33 | |||
| 34 | $fullname = $INPUT->post->str('fullname', $INFO['userinfo']['name'], true); |
||
| 35 | $email = $INPUT->post->str('email', $INFO['userinfo']['mail'], true); |
||
| 36 | |||
| 37 | // create the updateprofile form |
||
| 38 | $form = new Form(['id' => 'dw__register']); |
||
| 39 | $form->addTagOpen('div')->addClass('no'); |
||
| 40 | $form->addFieldsetOpen($lang['profile']); |
||
| 41 | $form->setHiddenField('do', 'profile'); |
||
| 42 | $form->setHiddenField('save', '1'); |
||
| 43 | |||
| 44 | $attr = array('size' => '50', 'disabled' => 'disabled'); |
||
| 45 | $input = $form->addTextInput('login', $lang['user'])->attrs($attr)->addClass('edit') |
||
| 46 | ->val($INPUT->server->str('REMOTE_USER')); |
||
| 47 | $input->getLabel()->attr('class', 'block'); |
||
| 48 | $form->addHTML("<br>\n"); |
||
| 49 | |||
| 50 | $attr = array('size' => '50'); |
||
| 51 | if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; |
||
| 52 | $input = $form->addTextInput('fullname', $lang['fullname'])->attrs($attr)->addClass('edit') |
||
| 53 | ->val($fullname); |
||
| 54 | $input->getLabel()->attr('class', 'block'); |
||
| 55 | $form->addHTML("<br>\n"); |
||
| 56 | |||
| 57 | $attr = array('type' => 'email', 'size' => '50'); |
||
| 58 | if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled'; |
||
| 59 | $input = $form->addTextInput('email', $lang['email'])->attrs($attr)->addClass('edit') |
||
| 60 | ->val($email); |
||
| 61 | $input->getLabel()->attr('class', 'block'); |
||
| 62 | $form->addHTML("<br>\n"); |
||
| 63 | |||
| 64 | if ($auth->canDo('modPass')) { |
||
| 65 | $attr = array('size'=>'50'); |
||
| 66 | $input = $form->addPasswordInput('newpass', $lang['newpass'])->attrs($attr)->addClass('edit'); |
||
| 67 | $input->getLabel()->attr('class', 'block'); |
||
| 68 | $form->addHTML("<br>\n"); |
||
| 69 | |||
| 70 | $input = $form->addPasswordInput('passchk', $lang['passchk'])->attrs($attr)->addClass('edit'); |
||
| 71 | $input->getLabel()->attr('class', 'block'); |
||
| 72 | $form->addHTML("<br>\n"); |
||
| 73 | } |
||
| 74 | |||
| 75 | if ($conf['profileconfirm']) { |
||
| 76 | $form->addHTML("<br>\n"); |
||
| 77 | $attr = array('size' => '50', 'required' => 'required'); |
||
| 78 | $input = $form->addPasswordInput('oldpass', $lang['oldpass'])->attrs($attr)->addClass('edit'); |
||
| 79 | $input->getLabel()->attr('class', 'block'); |
||
| 80 | $form->addHTML("<br>\n"); |
||
| 81 | } |
||
| 82 | |||
| 83 | $form->addButton('', $lang['btn_save'])->attr('type', 'submit'); |
||
| 84 | $form->addButton('', $lang['btn_reset'])->attr('type', 'reset'); |
||
| 85 | |||
| 86 | $form->addFieldsetClose(); |
||
| 87 | $form->addTagClose('div'); |
||
| 88 | |||
| 89 | print $form->toHTML('UpdateProfile'); |
||
| 90 | |||
| 91 | |||
| 92 | if ($auth->canDo('delUser') && actionOK('profile_delete')) { |
||
| 93 | |||
| 94 | // create the profiledelete form |
||
| 95 | $form = new Form(['id' => 'dw__profiledelete']); |
||
| 96 | $form->addTagOpen('div')->addClass('no'); |
||
| 97 | $form->addFieldsetOpen($lang['profdeleteuser']); |
||
| 98 | $form->setHiddenField('do', 'profile_delete'); |
||
| 99 | $form->setHiddenField('delete', '1'); |
||
| 100 | |||
| 101 | $form->addCheckbox('confirm_delete', $lang['profconfdelete']) |
||
| 102 | ->attrs(['required' => 'required']) |
||
| 103 | ->id('dw__confirmdelete') |
||
| 104 | ->val('1'); |
||
| 105 | |||
| 106 | if ($conf['profileconfirm']) { |
||
| 107 | $form->addHTML("<br>\n"); |
||
| 108 | $attr = array('size' => '50', 'required' => 'required'); |
||
| 109 | $input = $form->addPasswordInput('oldppass', $lang['oldpass'])->attrs($attr) |
||
| 110 | ->addClass('edit'); |
||
| 111 | $input->getLabel()->attr('class', 'block'); |
||
| 112 | $form->addHTML("<br>\n"); |
||
| 113 | } |
||
| 114 | |||
| 115 | $form->addButton('', $lang['btn_deleteuser'])->attr('type', 'submit'); |
||
| 116 | $form->addFieldsetClose(); |
||
| 117 | $form->addTagClose('div'); |
||
| 118 | |||
| 119 | print $form->toHTML('ProfileDelete'); |
||
| 120 | } |
||
| 121 | |||
| 122 | print '</div>'; |
||
| 123 | } |
||
| 124 | |||
| 126 |