10a5b05ebSAndreas Gohr<?php 20a5b05ebSAndreas Gohr 30a5b05ebSAndreas Gohrnamespace dokuwiki\plugin\config\core\Setting; 40a5b05ebSAndreas Gohr 50a5b05ebSAndreas Gohr/** 60a5b05ebSAndreas Gohr * Class setting_password 70a5b05ebSAndreas Gohr */ 88c7c53b0SAndreas Gohrclass SettingPassword extends SettingString 98c7c53b0SAndreas Gohr{ 100a5b05ebSAndreas Gohr protected $code = 'plain'; // mechanism to be used to obscure passwords 110a5b05ebSAndreas Gohr 120a5b05ebSAndreas Gohr /** @inheritdoc */ 13d868eb89SAndreas Gohr public function update($input) 14d868eb89SAndreas Gohr { 150a5b05ebSAndreas Gohr if ($this->isProtected()) return false; 160a5b05ebSAndreas Gohr if (!$input) return false; 170a5b05ebSAndreas Gohr 180a5b05ebSAndreas Gohr if ($this->pattern && !preg_match($this->pattern, $input)) { 190a5b05ebSAndreas Gohr $this->error = true; 200a5b05ebSAndreas Gohr $this->input = $input; 210a5b05ebSAndreas Gohr return false; 220a5b05ebSAndreas Gohr } 230a5b05ebSAndreas Gohr 240a5b05ebSAndreas Gohr $this->local = conf_encodeString($input, $this->code); 250a5b05ebSAndreas Gohr return true; 260a5b05ebSAndreas Gohr } 270a5b05ebSAndreas Gohr 280a5b05ebSAndreas Gohr /** @inheritdoc */ 29d868eb89SAndreas Gohr public function html(\admin_plugin_config $plugin, $echo = false) 30d868eb89SAndreas Gohr { 310a5b05ebSAndreas Gohr 320a5b05ebSAndreas Gohr $disable = $this->isProtected() ? 'disabled="disabled"' : ''; 330a5b05ebSAndreas Gohr 340a5b05ebSAndreas Gohr $key = htmlspecialchars($this->key); 350a5b05ebSAndreas Gohr 360a5b05ebSAndreas Gohr $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>'; 370a5b05ebSAndreas Gohr $input = '<input id="config___' . $key . '" name="config[' . $key . 38*75578ae6SAndreas Gohr ']" autocomplete="new-password" type="password" class="edit" value="" ' . $disable . ' />'; 39467c1427SAndreas Gohr return [$label, $input]; 400a5b05ebSAndreas Gohr } 410a5b05ebSAndreas Gohr} 42