From aa6fa82acb87b7e89c79fc3c1ccdf7db698edf33 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 27 Oct 2008 14:15:05 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformElement=5Ftext=20:=20Mise=20en=20comp?= =?UTF-8?q?atibilit=C3=A9=20avec=20les=20nouvelles=20fonctionalit=C3=A9s?= =?UTF-8?q?=20=20=20de=20la=20fonction=20getFData()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LSobjects/config.LSobjects.LSeepeople.php | 15 +++++++- .../class/class.LSformElement_password.php | 15 ++++++++ .../js/LSformElement_password_field.js | 35 +++++++++++++++++++ trunk/includes/js/LSformElement_text.js | 4 +-- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php index 5116872e..dab557e0 100644 --- a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php +++ b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php @@ -27,6 +27,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'posixAccount', 'sambaSamAccount', ), + 'orderby' => 'displayValue', // Valeurs possibles : 'displayValue' ou 'subDn' 'rdn' => 'uid', 'container_dn' => 'ou=people', 'container_auto_create' => array( @@ -66,6 +67,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'label' => _('Identifiant'), 'ldap_type' => 'ascii', 'html_type' => 'text', + 'html_options' => array( + 'generate_value_format' => '%{givenName:1}.%{sn}', + 'withoutAccent' => 1, + 'replaceSpaces' => '.', + 'lowerCase' => 1 + ), 'required' => 1, 'check_data' => array ( 'alphanumeric' => array( @@ -340,7 +347,13 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'generationTool' => true, 'autoGenerate' => false, 'chars' => 'abcdefgh', - 'lenght' => 5 + 'lenght' => 5, + 'mail' => array( + 'send' => 1, + 'ask' => 1, + 'subject' => "LSexample : votre nouveau mot de passe", + 'msg' => "Votre mot de passe vient d'être modifié.\nNouveau mot de passe : %{mdp}" + ) ), 'required' => 1, 'rights' => array( diff --git a/trunk/includes/class/class.LSformElement_password.php b/trunk/includes/class/class.LSformElement_password.php index 4d710e88..4fc74f1b 100644 --- a/trunk/includes/class/class.LSformElement_password.php +++ b/trunk/includes/class/class.LSformElement_password.php @@ -34,6 +34,8 @@ class LSformElement_password extends LSformElement { var $fieldTemplate = 'LSformElement_password_field.tpl'; var $template = 'LSformElement_password.tpl'; + + var $sendMail = false; /** * Recupère la valeur de l'élement passée en POST @@ -56,6 +58,16 @@ class LSformElement_password extends LSformElement { $this -> form -> _notUpdate[$this -> name] == true; return true; } + + //Mail + if (isset($_POST['LSformElement_password_'.$this -> name.'_send'])) { + if ($_POST['LSformElement_password_'.$this -> name.'_send']==1) { + $this -> sendMail = true; + } + } + else if ($this -> params['html_options']['mail']['send']==1) { + $this -> sendMail = true; + } } return $retval; } @@ -80,6 +92,9 @@ class LSformElement_password extends LSformElement { 'generate' => ($this -> params['html_options']['generationTool']==True), 'verify' => (!$this -> attr_html -> attribute -> ldapObject-> isNew()) ); + if (isset($this -> params['html_options']['mail'])) { + $params['mail'] = $this -> params['html_options']['mail']; + } $GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$params); $GLOBALS['LSsession'] -> addJSscript('LSformElement_password_field.js'); diff --git a/trunk/includes/js/LSformElement_password_field.js b/trunk/includes/js/LSformElement_password_field.js index 528cd1de..11163e94 100644 --- a/trunk/includes/js/LSformElement_password_field.js +++ b/trunk/includes/js/LSformElement_password_field.js @@ -8,6 +8,30 @@ var LSformElement_password_field = new Class({ }, initialiseLSformElement_password_field: function() { + // Mail + if (this.params['mail']) { + if (this.params.mail['ask']) { + this.mailBtn = new Element('img'); + this.mailBtn.addClass('btn'); + this.mailBtn.addEvent('click',this.onMailBtnClick.bind(this)); + this.mailInput = new Element('input'); + this.mailInput.setProperties({ + name: 'LSformElement_password_' + this.name + '_send', + type: 'hidden' + }); + if (this.params.mail['send']) { + this.mailInput.value = 1; + this.mailBtn.src = varLSdefault.imagePath('nomail.png'); + } + else { + this.mailInput.value = 0; + this.mailBtn.src = varLSdefault.imagePath('mail.png'); + } + this.mailBtn.injectAfter(this.input); + this.mailInput.injectAfter(this.mailBtn); + } + } + // ViewBtn this.viewBtn = new Element('img'); this.viewBtn.src = varLSdefault.imagePath('view.png'); @@ -44,6 +68,17 @@ var LSformElement_password_field = new Class({ } }, + onMailBtnClick: function() { + if (this.mailInput.value==1) { + this.mailInput.value = 0; + this.mailBtn.src = varLSdefault.imagePath('mail.png'); + } + else { + this.mailInput.value = 1; + this.mailBtn.src = varLSdefault.imagePath('nomail.png'); + } + }, + onGenerateBtnClick: function() { var data = { template: 'LSform', diff --git a/trunk/includes/js/LSformElement_text.js b/trunk/includes/js/LSformElement_text.js index 2fd165bc..f457da24 100644 --- a/trunk/includes/js/LSformElement_text.js +++ b/trunk/includes/js/LSformElement_text.js @@ -35,12 +35,12 @@ var LSformElement_text = new Class({ getDependsFields: function(format) { var retval=new Array(); var find = 1; - var getMotif = new RegExp('%\{([A-Za-z0-9]+)\}'); + var getMotif = new RegExp('%\{(([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9])+)?)\}'); var ch = null; while (find) { ch = getMotif.exec(format); if ($type(ch)) { - retval.include(ch[1]); + retval.include(ch[2]); format=format.replace ( new RegExp('%\{'+ch[1]+'\}'), ''