LSformElement_password : Added possibility to have multiple contact mail attributes

This commit is contained in:
Benjamin Renard 2012-12-18 12:20:27 +01:00
parent f418a5d7cf
commit e557d7f83b
6 changed files with 96 additions and 44 deletions

View file

@ -158,7 +158,9 @@
<listitem> <listitem>
<simpara>Le nom de l'attribut listant les mails possibles de <simpara>Le nom de l'attribut listant les mails possibles de
l'utilisateur. Par défaut, la première valeur de l'attribut sera l'utilisateur. Par défaut, la première valeur de l'attribut sera
utilisée comme adresse mail destinatrice. utilisée comme adresse mail destinatrice. Cet attribut peut également
être un tableau de plusieurs noms d'attributs. Dans ce cas, la première
valeur correcte sera retenue.
Si <parameter>canEdit</parameter> est activé, l'utilisateur pourra Si <parameter>canEdit</parameter> est activé, l'utilisateur pourra
choisir l'adresse mail destinatrice parmi la liste des valeurs de choisir l'adresse mail destinatrice parmi la liste des valeurs de
l'attribut.</simpara> l'attribut.</simpara>

View file

@ -196,13 +196,28 @@ class LSformElement_password extends LSformElement {
$mail = (String)$this -> sendMail['mail']; $mail = (String)$this -> sendMail['mail'];
Lsdebug($mail); Lsdebug($mail);
if ($mail=="") { if ($mail=="") {
$mail_attr = $this -> attr_html -> attribute -> ldapObject -> attrs[$this -> params['html_options']['mail']['mail_attr']]; $mail_attrs = $this -> params['html_options']['mail']['mail_attr'];
if ($mail_attr instanceOf LSattribute) { if (!is_array($mail_attrs)) {
$mail = $mail_attr -> getValue(); $mail_attrs=array();
$mail=$mail[0];
} }
else { foreach($mail_attrs as $attr) {
LSdebug("L'attribut $mail_attr pour l'envoie du nouveau mot de passe n'existe pas."); $mail_attr = $this -> attr_html -> attribute -> ldapObject -> attrs[$attr];
if ($mail_attr instanceOf LSattribute) {
$mail = $mail_attr -> getValue();
if (!empty($mail) && checkEmail($mail[0],NULL,true)) {
$mail=$mail[0];
break;
}
else {
$mail="";
}
}
else {
LSdebug("L'attribut $mail_attr pour l'envoie du nouveau mot de passe n'existe pas.");
}
}
if ($mail=="") {
LSerror :: addErrorCode('LSformElement_password_01');
return; return;
} }
} }
@ -229,7 +244,7 @@ class LSformElement_password extends LSformElement {
} }
} }
else { else {
LSdebug('Adresse mail incorrect : '.$mail); LSerror :: addErrorCode('LSformElement_password_02',$mail);
return; return;
} }
} }
@ -300,5 +315,15 @@ class LSformElement_password extends LSformElement {
} }
} }
/*
* Error Codes
*/
LSerror :: defineError('LSformElement_password_01',
_("LSformElement_password : No contact mail available to send password.")
);
LSerror :: defineError('LSformElement_password_02',
_("LSformElement_password : Contact mail invalid (%{mail}). Can't send password.")
);
?> ?>

View file

@ -111,10 +111,18 @@ var LSformElement_password_field = new Class({
this.LSmail.addEvent('valid',this.onLSmailValid.bind(this)); this.LSmail.addEvent('valid',this.onLSmailValid.bind(this));
} }
var mail = varLSform.getValue(this.params.mail['mail_attr']); var mails = []
if ($type(this.params.mail['mail_attr'])=='array') {
this.params.mail['mail_attr'].each(function(a) {
this.append(varLSform.getValue(a));
},mails);
}
else {
mails.append(varLSform.getValue(this.params.mail['mail_attr']));
}
this.LSmail_open = 1; this.LSmail_open = 1;
this.LSmail.setMails(mail); this.LSmail.setMails(mails);
this.LSmail.setSubject(this.params.mail['subject']); this.LSmail.setSubject(this.params.mail['subject']);
this.LSmail.setMsg(this.params.mail['msg']); this.LSmail.setMsg(this.params.mail['msg']);
this.LSmail.open(this.editMailBtn); this.LSmail.open(this.editMailBtn);

View file

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: LdapSaisie\n" "Project-Id-Version: LdapSaisie\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-10-03 12:19+0200\n" "POT-Creation-Date: 2012-12-18 11:55+0100\n"
"PO-Revision-Date: 2012-10-03 12:21+0100\n" "PO-Revision-Date: 2012-12-18 11:56+0100\n"
"Last-Translator: Benjamin Renard <brenard@easter-eggs.com>\n" "Last-Translator: Benjamin Renard <brenard@easter-eggs.com>\n"
"Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise.org>\n" "Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise.org>\n"
"Language: \n" "Language: \n"
@ -806,43 +806,43 @@ msgstr "Oui"
msgid "No" msgid "No"
msgstr "Non" msgstr "Non"
#: includes/class/class.LSattribute.php:260 #: includes/class/class.LSattribute.php:267
msgid "The value of field %{label} is invalid." msgid "The value of field %{label} is invalid."
msgstr "La valeur du champ %{label} est incorrecte." msgstr "La valeur du champ %{label} est incorrecte."
#: includes/class/class.LSattribute.php:724 #: includes/class/class.LSattribute.php:731
msgid "LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} & HTML = %{html})." msgid "LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} & HTML = %{html})."
msgstr "LSattribute : Attribut %{attr} : Les types LDAP ou HTML sont inconnus (LDAP = %{ldap} & HTML = %{html})." msgstr "LSattribute : Attribut %{attr} : Les types LDAP ou HTML sont inconnus (LDAP = %{ldap} & HTML = %{html})."
#: includes/class/class.LSattribute.php:727 #: includes/class/class.LSattribute.php:734
msgid "LSattribute : The function %{func} to display the attribute %{attr} is unknow." msgid "LSattribute : The function %{func} to display the attribute %{attr} is unknow."
msgstr "LSattribute : La fonction %{func} pour afficher l'attribut %{attr} est inconnue." msgstr "LSattribute : La fonction %{func} pour afficher l'attribut %{attr} est inconnue."
#: includes/class/class.LSattribute.php:730 #: includes/class/class.LSattribute.php:737
msgid "LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow." msgid "LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow."
msgstr "LSattribute : La règle %{rule} de validation de l'attribut %{attr} n'existe pas." msgstr "LSattribute : La règle %{rule} de validation de l'attribut %{attr} n'existe pas."
#: includes/class/class.LSattribute.php:733 #: includes/class/class.LSattribute.php:740
msgid "LSattribute : Configuration data to verify the attribute %{attr} are incorrect." msgid "LSattribute : Configuration data to verify the attribute %{attr} are incorrect."
msgstr "LSattribute : Les données de configuration pour vérifier l'attribut %{attr} sont incorrecte." msgstr "LSattribute : Les données de configuration pour vérifier l'attribut %{attr} sont incorrecte."
#: includes/class/class.LSattribute.php:736 #: includes/class/class.LSattribute.php:743
msgid "LSattribute : The function %{func} to save the attribute %{attr} is unknow." msgid "LSattribute : The function %{func} to save the attribute %{attr} is unknow."
msgstr "LSattribute : La fonction %{func} pour sauvegarder l'attribut %{attr} est inconnue." msgstr "LSattribute : La fonction %{func} pour sauvegarder l'attribut %{attr} est inconnue."
#: includes/class/class.LSattribute.php:739 #: includes/class/class.LSattribute.php:746
msgid "LSattribute : The value of the attribute %{attr} can't be generated." msgid "LSattribute : The value of the attribute %{attr} can't be generated."
msgstr "LSattribute : La valeur de l'attribut %{attr} ne peut être générée." msgstr "LSattribute : La valeur de l'attribut %{attr} ne peut être générée."
#: includes/class/class.LSattribute.php:742 #: includes/class/class.LSattribute.php:749
msgid "LSattribute : Generation of the attribute %{attr} failed." msgid "LSattribute : Generation of the attribute %{attr} failed."
msgstr "LSattribute : La génération de l'attribut %{attr} a échouée." msgstr "LSattribute : La génération de l'attribut %{attr} a échouée."
#: includes/class/class.LSattribute.php:745 #: includes/class/class.LSattribute.php:752
msgid "LSattribute : Generation of the attribute %{attr} did not return a correct value." msgid "LSattribute : Generation of the attribute %{attr} did not return a correct value."
msgstr "LSattribute : La génération de l'attribut %{attr} n'a pas retournée de valeur correcte." msgstr "LSattribute : La génération de l'attribut %{attr} n'a pas retournée de valeur correcte."
#: includes/class/class.LSattribute.php:748 #: includes/class/class.LSattribute.php:755
msgid "LSattribute : The attr_%{type} of the attribute %{name} is not yet defined." msgid "LSattribute : The attr_%{type} of the attribute %{name} is not yet defined."
msgstr "LSattribute : L'objet attr_%{type} de l'attribut %{name} n'est pas encore défini." msgstr "LSattribute : L'objet attr_%{type} de l'attribut %{name} n'est pas encore défini."
@ -958,10 +958,18 @@ msgstr "Le mot de passe ne sera pas envoyé en cas de modification. Cliquer pour
msgid "Modify the mail sent to notice the user" msgid "Modify the mail sent to notice the user"
msgstr "Modifier mail de notification de l'utilisateur" msgstr "Modifier mail de notification de l'utilisateur"
#: includes/class/class.LSformElement_password.php:228 #: includes/class/class.LSformElement_password.php:243
msgid "Notice mail sent." msgid "Notice mail sent."
msgstr "Le mail de notification a été envoyé." msgstr "Le mail de notification a été envoyé."
#: includes/class/class.LSformElement_password.php:323
msgid "LSformElement_password : No contact mail available to send password."
msgstr "LSformElement_password : Aucun mail de contact disponible pour envoyer le mot de passe."
#: includes/class/class.LSformElement_password.php:326
msgid "LSformElement_password : Contact mail invalid (%{mail}). Can't send password."
msgstr "LSformElement_password : Mail de contact invalide (%{mail}). Impossible d'envoyer le mot de passe."
#: includes/class/class.LSformElement_date.php:159 #: includes/class/class.LSformElement_date.php:159
msgid "Now." msgid "Now."
msgstr "Maintenant." msgstr "Maintenant."
@ -998,21 +1006,21 @@ msgstr "Discuter avec cette personne."
msgid "The custom action %{customAction} have been successfully execute on %{objectname}." msgid "The custom action %{customAction} have been successfully execute on %{objectname}."
msgstr "L'action personnalisée %{customAction} a été correctement exécutée sur %{objectname}." msgstr "L'action personnalisée %{customAction} a été correctement exécutée sur %{objectname}."
#: view.php:87 #: view.php:88
msgid "My account" msgid "My account"
msgstr "Mon compte" msgstr "Mon compte"
#: view.php:117 #: view.php:118
#: select.php:60 #: select.php:60
msgid "Search" msgid "Search"
msgstr "Rechercher" msgstr "Rechercher"
#: view.php:118 #: view.php:119
#: select.php:61 #: select.php:61
msgid "Approximative search" msgid "Approximative search"
msgstr "Recherche approximative" msgstr "Recherche approximative"
#: view.php:119 #: view.php:120
#: select.php:62 #: select.php:62
msgid "Recursive search" msgid "Recursive search"
msgstr "Recherche récursive" msgstr "Recherche récursive"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-10-03 12:19+0200\n" "POT-Creation-Date: 2012-12-18 11:55+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -899,53 +899,53 @@ msgstr ""
msgid "No" msgid "No"
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:260 #: includes/class/class.LSattribute.php:267
msgid "The value of field %{label} is invalid." msgid "The value of field %{label} is invalid."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:724 #: includes/class/class.LSattribute.php:731
msgid "" msgid ""
"LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} " "LSattribute : Attribute %{attr} : LDAP or HTML types unknow (LDAP = %{ldap} "
"& HTML = %{html})." "& HTML = %{html})."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:727 #: includes/class/class.LSattribute.php:734
msgid "" msgid ""
"LSattribute : The function %{func} to display the attribute %{attr} is " "LSattribute : The function %{func} to display the attribute %{attr} is "
"unknow." "unknow."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:730 #: includes/class/class.LSattribute.php:737
msgid "" msgid ""
"LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow." "LSattribute : The rule %{rule} to validate the attribute %{attr} is unknow."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:733 #: includes/class/class.LSattribute.php:740
msgid "" msgid ""
"LSattribute : Configuration data to verify the attribute %{attr} are " "LSattribute : Configuration data to verify the attribute %{attr} are "
"incorrect." "incorrect."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:736 #: includes/class/class.LSattribute.php:743
msgid "" msgid ""
"LSattribute : The function %{func} to save the attribute %{attr} is unknow." "LSattribute : The function %{func} to save the attribute %{attr} is unknow."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:739 #: includes/class/class.LSattribute.php:746
msgid "LSattribute : The value of the attribute %{attr} can't be generated." msgid "LSattribute : The value of the attribute %{attr} can't be generated."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:742 #: includes/class/class.LSattribute.php:749
msgid "LSattribute : Generation of the attribute %{attr} failed." msgid "LSattribute : Generation of the attribute %{attr} failed."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:745 #: includes/class/class.LSattribute.php:752
msgid "" msgid ""
"LSattribute : Generation of the attribute %{attr} did not return a correct " "LSattribute : Generation of the attribute %{attr} did not return a correct "
"value." "value."
msgstr "" msgstr ""
#: includes/class/class.LSattribute.php:748 #: includes/class/class.LSattribute.php:755
msgid "" msgid ""
"LSattribute : The attr_%{type} of the attribute %{name} is not yet defined." "LSattribute : The attr_%{type} of the attribute %{name} is not yet defined."
msgstr "" msgstr ""
@ -1076,10 +1076,19 @@ msgstr ""
msgid "Modify the mail sent to notice the user" msgid "Modify the mail sent to notice the user"
msgstr "" msgstr ""
#: includes/class/class.LSformElement_password.php:228 #: includes/class/class.LSformElement_password.php:243
msgid "Notice mail sent." msgid "Notice mail sent."
msgstr "" msgstr ""
#: includes/class/class.LSformElement_password.php:323
msgid "LSformElement_password : No contact mail available to send password."
msgstr ""
#: includes/class/class.LSformElement_password.php:326
msgid ""
"LSformElement_password : Contact mail invalid (%{mail}). Can't send password."
msgstr ""
#: includes/class/class.LSformElement_date.php:159 #: includes/class/class.LSformElement_date.php:159
msgid "Now." msgid "Now."
msgstr "" msgstr ""
@ -1118,19 +1127,19 @@ msgid ""
"%{objectname}." "%{objectname}."
msgstr "" msgstr ""
#: view.php:87 #: view.php:88
msgid "My account" msgid "My account"
msgstr "" msgstr ""
#: view.php:117 select.php:60 #: view.php:118 select.php:60
msgid "Search" msgid "Search"
msgstr "" msgstr ""
#: view.php:118 select.php:61 #: view.php:119 select.php:61
msgid "Approximative search" msgid "Approximative search"
msgstr "" msgstr ""
#: view.php:119 select.php:62 #: view.php:120 select.php:62
msgid "Recursive search" msgid "Recursive search"
msgstr "" msgstr ""