Failed Conditions
Pull Request — master (#3198)
by
unknown
02:50
created

UserResendPwd   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 6

1 Method

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