LSformElement_password : added clearView and clearEdit parameters

This commit is contained in:
Benjamin Renard 2013-06-24 17:52:45 +02:00
parent 350aff50c1
commit ddeff8c622
4 changed files with 38 additions and 3 deletions

View file

@ -102,6 +102,23 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>clearView</term>
<listitem>
<simpara>Booléen définissant si l'utilisateur pourra voir le mot de passe en
clair par défaut (y comris en mode visualisation uniquement).</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>clearEdit</term>
<listitem>
<simpara>Booléen définissant si l'utilisateur éditera le mot de passe au travers
un champs HTML de type <emphasis>text</emphasis> et donc lisible ou au travers un
champs HTML de type <emphasis>password</emphasis>.</simpara>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>mail</term> <term>mail</term>
<listitem> <listitem>

View file

@ -122,6 +122,9 @@ class LSformElement_password extends LSformElement {
LSsession :: addCssFile('LSformElement_password.css'); LSsession :: addCssFile('LSformElement_password.css');
$return = $this -> getLabelInfos(); $return = $this -> getLabelInfos();
$pwd = ""; $pwd = "";
if ($this -> params['html_options']['clearView'] or $this -> params['html_options']['clearEdit']) {
$pwd = $this -> values[0];
}
if (!$this -> isFreeze()) { if (!$this -> isFreeze()) {
// Help Infos // Help Infos
@ -145,6 +148,7 @@ class LSformElement_password extends LSformElement {
$params = array( $params = array(
'generate' => ($this -> params['html_options']['generationTool']==True), 'generate' => ($this -> params['html_options']['generationTool']==True),
'clearEdit' => ($this -> params['html_options']['clearEdit']==True),
'viewHash' => ($this -> params['html_options']['viewHash']==True), 'viewHash' => ($this -> params['html_options']['viewHash']==True),
'verify' => ( (!$this -> attr_html -> attribute -> ldapObject-> isNew()) && ( (isset($this -> params['html_options']['verify']) && $this -> params['html_options']['verify']) || (!isset($this -> params['html_options']['verify'])) ) ) 'verify' => ( (!$this -> attr_html -> attribute -> ldapObject-> isNew()) && ( (isset($this -> params['html_options']['verify']) && $this -> params['html_options']['verify']) || (!isset($this -> params['html_options']['verify'])) ) )
); );
@ -156,7 +160,7 @@ class LSformElement_password extends LSformElement {
LSsession :: addJSscript('LSformElement_password_field.js'); LSsession :: addJSscript('LSformElement_password_field.js');
LSsession :: addJSscript('LSformElement_password.js'); LSsession :: addJSscript('LSformElement_password.js');
} }
$return['html'] = $this -> fetchTemplate(NULL,array('pwd' => $pwd)); $return['html'] = $this -> fetchTemplate(NULL,array('pwd' => $pwd,'clearView' => $this -> params['html_options']['clearView'],'clearEdit' => $this -> params['html_options']['clearEdit']));
return $return; return $return;
} }

View file

@ -54,11 +54,17 @@ var LSformElement_password_field = new Class({
// ViewBtn // ViewBtn
this.viewBtn = new Element('img'); this.viewBtn = new Element('img');
this.viewBtn.src = varLSdefault.imagePath('view'); if (this.params['clearEdit']) {
this.viewBtn.src = varLSdefault.imagePath('hide');
varLSdefault.addHelpInfo(this.viewBtn,'LSformElement_password','hide');
}
else {
this.viewBtn.src = varLSdefault.imagePath('view');
varLSdefault.addHelpInfo(this.viewBtn,'LSformElement_password','view');
}
this.viewBtn.addClass('btn'); this.viewBtn.addClass('btn');
this.viewBtn.addEvent('click',this.changeInputType.bind(this)); this.viewBtn.addEvent('click',this.changeInputType.bind(this));
this.viewBtn.injectAfter(this.input); this.viewBtn.injectAfter(this.input);
varLSdefault.addHelpInfo(this.viewBtn,'LSformElement_password','view');
// Verify // Verify
if (this.params['verify']) { if (this.params['verify']) {

View file

@ -1,5 +1,13 @@
{if $freeze} {if $freeze}
{if $clearView}
{$pwd}
{else}
******** ********
{/if}
{else}
{if $clearEdit}
<input type='text' name='{$attr_name}[]' value="{$pwd}" class='LSformElement_password' autocomplete="off"/>
{else} {else}
<input type='password' name='{$attr_name}[]' value="{$pwd}" class='LSformElement_password' autocomplete="off"/> <input type='password' name='{$attr_name}[]' value="{$pwd}" class='LSformElement_password' autocomplete="off"/>
{/if} {/if}
{/if}