From: pdontthink Date: Fri, 19 Dec 2008 08:33:56 +0000 (+0000) Subject: Add password option widget X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3fa09710c8488fa92f9be6ff66282b35cdaa538f;p=squirrelmail.git Add password option widget git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13376 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index 0e7024b6..3616289b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -266,6 +266,7 @@ Version 1.5.2 - SVN - Allow control over white space wrapping of auto-generated SquirrelMail option widgets. - Add informational type option widget + - Add password type option widget Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/functions/forms.php b/functions/forms.php index 0be61fb5..e49b8a69 100644 --- a/functions/forms.php +++ b/functions/forms.php @@ -76,12 +76,17 @@ function addInputField($sType, $aAttribs=array()) { * Password input field * @param string $sName field name * @param string $sValue initial password value - * @param array $aAttribs (since 1.5.1) extra attributes - * @return string html formated password field + * @param integer $iSize field size (number of characters) + * @param integer $iMaxlength maximum number of characters the user may enter + * @param array $aAttribs (since 1.5.1) extra attributes - should be given + * in the form array('attribute_name' => 'attribute_value', ...) + * @return string html formated password field */ -function addPwField($sName, $sValue = null, $aAttribs=array()) { +function addPwField($sName, $sValue = '', $iSize = 0, $iMaxlength = 0, $aAttribs=array()) { $aAttribs['name'] = $sName; - $aAttribs['value'] = (! is_null($sValue) ? $sValue : ''); + $aAttribs['value'] = $sValue; + if ($iSize) $aAttribs['size'] = (int)$iSize; + if ($iMaxlength) $aAttribs['maxlength'] = (int)$iMaxlength; // add default css if (! isset($aAttribs['class'])) $aAttribs['class'] = 'sqmpwfield'; return addInputField('password',$aAttribs); diff --git a/functions/options.php b/functions/options.php index 1795c226..fd211eab 100644 --- a/functions/options.php +++ b/functions/options.php @@ -364,6 +364,9 @@ class SquirrelOption { /* Get the widget for this option type. */ switch ($this->type) { + case SMOPT_TYPE_PASSWORD: + $result = $this->createWidget_String(TRUE); + break; case SMOPT_TYPE_STRING: $result = $this->createWidget_String(); break; @@ -443,9 +446,15 @@ class SquirrelOption { /** * Create string field + * + * @param boolean $password When TRUE, the text in the input + * widget will be obscured (OPTIONAL; + * default = FALSE). + * * @return string html formated option field + * */ - function createWidget_String() { + function createWidget_String($password=FALSE) { switch ($this->size) { case SMOPT_SIZE_TINY: $width = 5; @@ -465,7 +474,11 @@ class SquirrelOption { } //TODO: might be better to have a separate template file for all widgets, because then the layout of the widget and the "trailing text" can be customized - they are still hard coded here - return addInput('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . ' ' . htmlspecialchars($this->trailing_text); + if ($password) +addPwField($sName, $sValue = null, $aAttribs=array()) { + return addPwField('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . ' ' . htmlspecialchars($this->trailing_text); + else + return addInput('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . ' ' . htmlspecialchars($this->trailing_text); } /** diff --git a/include/constants.php b/include/constants.php index dbf32478..249f2432 100644 --- a/include/constants.php +++ b/include/constants.php @@ -236,6 +236,7 @@ define('SMOPT_TYPE_BOOLEAN_RADIO', 13); define('SMOPT_TYPE_STRLIST_RADIO', 14); define('SMOPT_TYPE_SUBMIT', 15); define('SMOPT_TYPE_INFO', 16); +define('SMOPT_TYPE_PASSWORD', 17); // Define constants for the layout scheme for edit lists define('SMOPT_EDIT_LIST_LAYOUT_LIST', 0);