summaryrefslogtreecommitdiff
path: root/platform/www/lib/plugins/config/core/Setting/SettingPassword.php
blob: 9d9c53377ce940c84756fd55de11f667ca87d6ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

namespace dokuwiki\plugin\config\core\Setting;

/**
 * Class setting_password
 */
class SettingPassword extends SettingString {

    protected $code = 'plain';  // mechanism to be used to obscure passwords

    /** @inheritdoc */
    public function update($input) {
        if($this->isProtected()) return false;
        if(!$input) return false;

        if($this->pattern && !preg_match($this->pattern, $input)) {
            $this->error = true;
            $this->input = $input;
            return false;
        }

        $this->local = conf_encodeString($input, $this->code);
        return true;
    }

    /** @inheritdoc */
    public function html(\admin_plugin_config $plugin, $echo = false) {

        $disable = $this->isProtected() ? 'disabled="disabled"' : '';

        $key = htmlspecialchars($this->key);

        $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>';
        $input = '<input id="config___' . $key . '" name="config[' . $key .
            ']" autocomplete="off" type="password" class="edit" value="" ' . $disable . ' />';
        return array($label, $input);
    }
}