From ddeff8c622febe3ae2cb5f2881a5bde6c3e4a917 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 24 Jun 2013 17:52:45 +0200 Subject: [PATCH] LSformElement_password : added clearView and clearEdit parameters --- .../LSattr_html/LSattr_html_password.docbook | 17 +++++++++++++++++ .../class/class.LSformElement_password.php | 6 +++++- .../includes/js/LSformElement_password_field.js | 10 ++++++++-- .../default/LSformElement_password_field.tpl | 8 ++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html_password.docbook b/doc/conf/LSattribute/LSattr_html/LSattr_html_password.docbook index 6a5009db..19dfeb14 100644 --- a/doc/conf/LSattribute/LSattr_html/LSattr_html_password.docbook +++ b/doc/conf/LSattribute/LSattr_html/LSattr_html_password.docbook @@ -102,6 +102,23 @@ + + clearView + + Booléen définissant si l'utilisateur pourra voir le mot de passe en + clair par défaut (y comris en mode visualisation uniquement). + + + + + clearEdit + + Booléen définissant si l'utilisateur éditera le mot de passe au travers + un champs HTML de type text et donc lisible ou au travers un + champs HTML de type password. + + + mail diff --git a/public_html/includes/class/class.LSformElement_password.php b/public_html/includes/class/class.LSformElement_password.php index 8f1f4892..489f6f2e 100644 --- a/public_html/includes/class/class.LSformElement_password.php +++ b/public_html/includes/class/class.LSformElement_password.php @@ -122,6 +122,9 @@ class LSformElement_password extends LSformElement { LSsession :: addCssFile('LSformElement_password.css'); $return = $this -> getLabelInfos(); $pwd = ""; + if ($this -> params['html_options']['clearView'] or $this -> params['html_options']['clearEdit']) { + $pwd = $this -> values[0]; + } if (!$this -> isFreeze()) { // Help Infos @@ -145,6 +148,7 @@ class LSformElement_password extends LSformElement { $params = array( 'generate' => ($this -> params['html_options']['generationTool']==True), + 'clearEdit' => ($this -> params['html_options']['clearEdit']==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'])) ) ) ); @@ -156,7 +160,7 @@ class LSformElement_password extends LSformElement { LSsession :: addJSscript('LSformElement_password_field.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; } diff --git a/public_html/includes/js/LSformElement_password_field.js b/public_html/includes/js/LSformElement_password_field.js index 6fbeeb6e..798fac5a 100644 --- a/public_html/includes/js/LSformElement_password_field.js +++ b/public_html/includes/js/LSformElement_password_field.js @@ -54,11 +54,17 @@ var LSformElement_password_field = new Class({ // ViewBtn 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.addEvent('click',this.changeInputType.bind(this)); this.viewBtn.injectAfter(this.input); - varLSdefault.addHelpInfo(this.viewBtn,'LSformElement_password','view'); // Verify if (this.params['verify']) { diff --git a/public_html/templates/default/LSformElement_password_field.tpl b/public_html/templates/default/LSformElement_password_field.tpl index d8e8f58d..d94ae051 100644 --- a/public_html/templates/default/LSformElement_password_field.tpl +++ b/public_html/templates/default/LSformElement_password_field.tpl @@ -1,5 +1,13 @@ {if $freeze} +{if $clearView} +{$pwd} +{else} ******** +{/if} +{else} +{if $clearEdit} + {else} {/if} +{/if}