LSattr_html :: password : add get_mail_attr_function parameter

This commit is contained in:
Benjamin Renard 2018-02-08 18:16:23 +01:00
parent d9c5225aee
commit 3659031ed2
5 changed files with 129 additions and 54 deletions

View file

@ -15,8 +15,8 @@
'nb' => [nb caractères],
'chars' => '[liste de caractères possibles]'
),
'[autre liste de caractères possible]', // Liste caractère avec un nombre
// d'apparitions égal à 1
'[autre liste de caractères possibles]', // Liste caractère avec un nombre
// d'apparitions égal à 1
...
),
'use_pwgen' => [booléen], // Utiliser pwgen pour la génération du mot de passe
@ -28,6 +28,7 @@
'subject' => "[LSformat du sujet du mail]",
'msg' => "[LSformat du message du mail]",
'mail_attr' => 'mail', // Attribut mail de l'objet
'get_mail_attr_function' => '[function]', // Fonction retournant l'attribut mail de l'objet
'send' => 1, // Activation par défaut de l'envoi du mot de passe
'ask' => 1, // Laisser le choix à l'utilisateur
'canEdit' => 1 // Activation de l'édition du LSformat du message par l'utilisateur
@ -211,6 +212,19 @@
</listitem>
</varlistentry>
<varlistentry>
<term>get_mail_attr_function</term>
<listitem>
<simpara>Nom de la fonction (ou <literal>callable</literal> au sens PHP)
qui sera utilisé pour récupérer le nom de l'attribut listant les mails
possibles de l'utilisateur. Cette fonction prendra en paramètre, l'objet
<literal>LSformElement</literal> courant et devra retourner une valeur
équivalente au paramètre de configuration <literal>mail_attr</literal>.
Si ce paramètre est défini, il prévalera toujours sur le paramètre
<literal>mail_attr</literal>.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>bcc</term>
<listitem>

View file

@ -154,6 +154,7 @@ class LSformElement_password extends LSformElement {
);
if (isset($this -> params['html_options']['mail'])) {
$params['mail'] = $this -> params['html_options']['mail'];
$params['mail']['mail_attr'] = $this -> getMailAttrs();
}
LSsession :: addJSconfigParam($this -> name,$params);
@ -208,13 +209,35 @@ class LSformElement_password extends LSformElement {
return $find;
}
}
function getMailAttrs() {
if (!isset($this -> params['html_options']['mail']) || !is_array($this -> params['html_options']['mail']))
return False;
if (isset($this -> params['html_options']['mail']['get_mail_attr_function'])) {
if (is_callable($this -> params['html_options']['mail']['get_mail_attr_function'])) {
try {
return call_user_func_array($this -> params['html_options']['mail']['get_mail_attr_function'], array(&$this));
}
catch(Exception $e) {
LSerror :: addErrorCode('LSformElement_password_05', $e->getMessage());
}
}
else {
LSerror :: addErrorCode('LSformElement_password_04');
return False;
}
}
elseif (isset($this -> params['html_options']['mail']['mail_attr'])) {
return $this -> params['html_options']['mail']['mail_attr'];
}
}
function send($params) {
if (is_array($this -> sendMail)) {
$mail = (String)$this -> sendMail['mail'];
Lsdebug($mail);
if ($mail=="") {
$mail_attrs = $this -> params['html_options']['mail']['mail_attr'];
$mail_attrs = $this -> getMailAttrs();
if (!is_array($mail_attrs)) {
$mail_attrs=array($mail_attrs);
}
@ -346,3 +369,9 @@ _("LSformElement_password : Contact mail invalid (%{mail}). Can't send password.
LSerror :: defineError('LSformElement_password_03',
_("LSformElement_password : Fail to exec pwgen. Check it's correctly installed.")
);
LSerror :: defineError('LSformElement_password_04',
_("LSformElement_password : Fail to determine witch e-mail attribute to use to send new password : get_mail_attr_function parameter not refer to a valid function.")
);
LSerror :: defineError('LSformElement_password_05',
_("LSformElement_password : Fail to determine witch e-mail attribute to use to send new password : get_mail_attr_function throwed an exception : %{msg}")
);

View file

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: LdapSaisie\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-12 14:50+0200\n"
"PO-Revision-Date: 2017-10-12 14:50+0100\n"
"POT-Creation-Date: 2018-02-08 18:12+0100\n"
"PO-Revision-Date: 2018-02-08 18:13+0100\n"
"Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n"
"Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise."
"org>\n"
@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-Basepath: /var/www/ldapsaisie/trunk\n"
"X-Generator: Poedit 1.6.10\n"
"X-Generator: Poedit 1.8.11\n"
#: view.php:44 modify.php:54
#: includes/class/class.LSformElement_supannCompositeAttribute.php:106
@ -1218,30 +1218,49 @@ msgstr ""
msgid "Modify the mail sent to notice the user"
msgstr "Modifier mail de notification de l'utilisateur"
#: includes/class/class.LSformElement_password.php:261
#: includes/class/class.LSformElement_password.php:284
msgid "Notice mail sent."
msgstr "Le mail de notification a été envoyé."
#: includes/class/class.LSformElement_password.php:341
#: includes/class/class.LSformElement_password.php:364
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:344
#: includes/class/class.LSformElement_password.php:367
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_password.php:347
#: includes/class/class.LSformElement_password.php:370
msgid ""
"LSformElement_password : Fail to exec pwgen. Check it's correctly installed."
msgstr ""
"LSformElement_password : Impossible d'exécuter pwgen. Vérifier qu'il est "
"bien installé."
#: includes/class/class.LSformElement_password.php:373
msgid ""
"LSformElement_password : Fail to determine witch e-mail attribute to use to "
"send new password : get_mail_attr_function parameter not refer to a valid "
"function."
msgstr ""
"LSformElement_password : Impossible de déterminer quel attribut e-mail doit "
"être utilisé pour l'envoi du mot de passe : le paramètre "
"get_mail_attr_function ne fait pas référence à une fonction valide."
#: includes/class/class.LSformElement_password.php:376
msgid ""
"LSformElement_password : Fail to determine witch e-mail attribute to use to "
"send new password : get_mail_attr_function throwed an exception : %{msg}"
msgstr ""
"LSformElement_password : Impossible de déterminer quel attribut e-mail doit "
"être utilisé pour l'envoi du mot de passe : le fonction "
"get_mail_attr_function a déclenchée une exception : %{msg}."
#: includes/class/class.LSformElement_url.php:51
msgid "Display this website."
msgstr "Afficher le site internet."
@ -1484,38 +1503,38 @@ msgstr "Étape"
msgid "Pedagogical element"
msgstr "Élement pédagogique"
#: includes/class/class.LSsearch.php:1037
#: includes/class/class.LSsearch.php:1043
msgid "Actions"
msgstr "Actions"
#: includes/class/class.LSsearch.php:1040
#: includes/class/class.LSsearch.php:1046
msgid "This search didn't get any result."
msgstr "Cette recherche n'a retournée aucun résultat"
#: includes/class/class.LSsearch.php:1292
#: includes/class/class.LSsearch.php:1298
msgid "LSsearch : Invalid filter : %{filter}."
msgstr "LSsearch : Filtre invalide : %{filter}."
#: includes/class/class.LSsearch.php:1295
#: includes/class/class.LSsearch.php:1301
msgid "LSsearch : Invalid basedn : %{basedn}."
msgstr "LSsearch : Base DN invalide."
#: includes/class/class.LSsearch.php:1298
#: includes/class/class.LSsearch.php:1304
msgid "LSsearch : Invalid value for %{param} parameter."
msgstr "LSsearch : La valeur du paramètre %{param} est incorrecte."
#: includes/class/class.LSsearch.php:1301
#: includes/class/class.LSsearch.php:1307
msgid ""
"LSsearch : Invalid size limit. Must be an integer greater or equal to 0."
msgstr ""
"LSsearch : Limite de taille de recherche invalide. Elle doit être un entier "
"supérieur ou égal à 0."
#: includes/class/class.LSsearch.php:1304
#: includes/class/class.LSsearch.php:1310
msgid "LSsearch : Invalid parameter %{attr}. Must be an boolean."
msgstr "LSsearch : Paramètre %{param} invalide. Il doit être un booléen."
#: includes/class/class.LSsearch.php:1307
#: includes/class/class.LSsearch.php:1313
msgid ""
"LSsearch : Invalid parameter attributes. Must be an string or an array of "
"strings."
@ -1523,13 +1542,13 @@ msgstr ""
"LSsearch : Paramètre 'attributes' invalide. Il doit être une chaîne de "
"caractères ou un tableau de chaînes de caractères."
#: includes/class/class.LSsearch.php:1310
#: includes/class/class.LSsearch.php:1316
msgid "LSsearch : Can't build attributes list for make filter."
msgstr ""
"LSsearch : Impossible de construire la liste des attributs pour faire le "
"filtre."
#: includes/class/class.LSsearch.php:1313
#: includes/class/class.LSsearch.php:1319
msgid ""
"LSsearch : Error building filter with attribute '%{attr}' and pattern "
"'%{pattern}'"
@ -1537,34 +1556,34 @@ msgstr ""
"LSsearch : Problème en construisant le filtre avec l'attribut '%{attr}' et "
"le mot clé '%{pattern}'"
#: includes/class/class.LSsearch.php:1316
#: includes/class/class.LSsearch.php:1322
msgid "LSsearch : Error combining filters."
msgstr "LSsearch : Problème en combinant les filtres."
#: includes/class/class.LSsearch.php:1319
#: includes/class/class.LSsearch.php:1325
msgid "LSsearch : Invalid pattern."
msgstr "LSsearch : Mot clé invalide."
#: includes/class/class.LSsearch.php:1322
#: includes/class/class.LSsearch.php:1328
msgid "LSsearch : Invalid attribute %{attr} in parameters."
msgstr "LSsearch : Attribut %{attr} incorrect dans les paramètres."
#: includes/class/class.LSsearch.php:1325
#: includes/class/class.LSsearch.php:1331
msgid "LSsearch : Error during the search."
msgstr "LSsearch : Erreur pendant la recherche."
#: includes/class/class.LSsearch.php:1328
#: includes/class/class.LSsearch.php:1334
msgid "LSsearch : Error sorting the search."
msgstr "LSsearch : Erreur pendant le trie de la recherche."
#: includes/class/class.LSsearch.php:1331
#: includes/class/class.LSsearch.php:1337
msgid ""
"LSsearch : The function of the custum information %{name} is not callable."
msgstr ""
"LSsearch : La fonction de l'information personnalisée %{name} n'est pas "
"exécutable."
#: includes/class/class.LSsearch.php:1334
#: includes/class/class.LSsearch.php:1340
msgid ""
"LSsearch : Invalid predefinedFilter for LSobject type %{type} : %{label} "
"(filter : %{filter})."
@ -1572,7 +1591,7 @@ msgstr ""
"LSsearch : PredefinedFilter invalide pour le type d'LSobject %{type} : "
"%{label} (filtre : %{filter})."
#: includes/class/class.LSsearch.php:1337
#: includes/class/class.LSsearch.php:1343
msgid "LSsearch : Error during execution of the custom action %{customAction}."
msgstr ""
"LSldapObject : Erreur durant l'exécution de l'action personnalisée "
@ -1650,7 +1669,7 @@ msgstr "Erreur inconnu : %{error}"
msgid "PHP error : %{error}"
msgstr "Erreur PHP : %{error}"
#: includes/class/class.LSsearchEntry.php:250
#: includes/class/class.LSsearchEntry.php:257
msgid ""
"LSsearchEntry : Invalid formaterFunction %{func} for extraDisplayedColumns "
"%{column}."

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-12 14:50+0200\n"
"POT-Creation-Date: 2018-02-08 18:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1040,24 +1040,37 @@ msgstr ""
msgid "Modify the mail sent to notice the user"
msgstr ""
#: includes/class/class.LSformElement_password.php:261
#: includes/class/class.LSformElement_password.php:284
msgid "Notice mail sent."
msgstr ""
#: includes/class/class.LSformElement_password.php:341
#: includes/class/class.LSformElement_password.php:364
msgid "LSformElement_password : No contact mail available to send password."
msgstr ""
#: includes/class/class.LSformElement_password.php:344
#: includes/class/class.LSformElement_password.php:367
msgid ""
"LSformElement_password : Contact mail invalid (%{mail}). Can't send password."
msgstr ""
#: includes/class/class.LSformElement_password.php:347
#: includes/class/class.LSformElement_password.php:370
msgid ""
"LSformElement_password : Fail to exec pwgen. Check it's correctly installed."
msgstr ""
#: includes/class/class.LSformElement_password.php:373
msgid ""
"LSformElement_password : Fail to determine witch e-mail attribute to use to "
"send new password : get_mail_attr_function parameter not refer to a valid "
"function."
msgstr ""
#: includes/class/class.LSformElement_password.php:376
msgid ""
"LSformElement_password : Fail to determine witch e-mail attribute to use to "
"send new password : get_mail_attr_function throwed an exception : %{msg}"
msgstr ""
#: includes/class/class.LSformElement_url.php:51
msgid "Display this website."
msgstr ""
@ -1280,83 +1293,83 @@ msgstr ""
msgid "Pedagogical element"
msgstr ""
#: includes/class/class.LSsearch.php:1037
#: includes/class/class.LSsearch.php:1043
msgid "Actions"
msgstr ""
#: includes/class/class.LSsearch.php:1040
#: includes/class/class.LSsearch.php:1046
msgid "This search didn't get any result."
msgstr ""
#: includes/class/class.LSsearch.php:1292
#: includes/class/class.LSsearch.php:1298
msgid "LSsearch : Invalid filter : %{filter}."
msgstr ""
#: includes/class/class.LSsearch.php:1295
#: includes/class/class.LSsearch.php:1301
msgid "LSsearch : Invalid basedn : %{basedn}."
msgstr ""
#: includes/class/class.LSsearch.php:1298
#: includes/class/class.LSsearch.php:1304
msgid "LSsearch : Invalid value for %{param} parameter."
msgstr ""
#: includes/class/class.LSsearch.php:1301
#: includes/class/class.LSsearch.php:1307
msgid ""
"LSsearch : Invalid size limit. Must be an integer greater or equal to 0."
msgstr ""
#: includes/class/class.LSsearch.php:1304
#: includes/class/class.LSsearch.php:1310
msgid "LSsearch : Invalid parameter %{attr}. Must be an boolean."
msgstr ""
#: includes/class/class.LSsearch.php:1307
#: includes/class/class.LSsearch.php:1313
msgid ""
"LSsearch : Invalid parameter attributes. Must be an string or an array of "
"strings."
msgstr ""
#: includes/class/class.LSsearch.php:1310
#: includes/class/class.LSsearch.php:1316
msgid "LSsearch : Can't build attributes list for make filter."
msgstr ""
#: includes/class/class.LSsearch.php:1313
#: includes/class/class.LSsearch.php:1319
msgid ""
"LSsearch : Error building filter with attribute '%{attr}' and pattern "
"'%{pattern}'"
msgstr ""
#: includes/class/class.LSsearch.php:1316
#: includes/class/class.LSsearch.php:1322
msgid "LSsearch : Error combining filters."
msgstr ""
#: includes/class/class.LSsearch.php:1319
#: includes/class/class.LSsearch.php:1325
msgid "LSsearch : Invalid pattern."
msgstr ""
#: includes/class/class.LSsearch.php:1322
#: includes/class/class.LSsearch.php:1328
msgid "LSsearch : Invalid attribute %{attr} in parameters."
msgstr ""
#: includes/class/class.LSsearch.php:1325
#: includes/class/class.LSsearch.php:1331
msgid "LSsearch : Error during the search."
msgstr ""
#: includes/class/class.LSsearch.php:1328
#: includes/class/class.LSsearch.php:1334
msgid "LSsearch : Error sorting the search."
msgstr ""
#: includes/class/class.LSsearch.php:1331
#: includes/class/class.LSsearch.php:1337
msgid ""
"LSsearch : The function of the custum information %{name} is not callable."
msgstr ""
#: includes/class/class.LSsearch.php:1334
#: includes/class/class.LSsearch.php:1340
msgid ""
"LSsearch : Invalid predefinedFilter for LSobject type %{type} : %{label} "
"(filter : %{filter})."
msgstr ""
#: includes/class/class.LSsearch.php:1337
#: includes/class/class.LSsearch.php:1343
msgid "LSsearch : Error during execution of the custom action %{customAction}."
msgstr ""
@ -1428,7 +1441,7 @@ msgstr ""
msgid "PHP error : %{error}"
msgstr ""
#: includes/class/class.LSsearchEntry.php:250
#: includes/class/class.LSsearchEntry.php:257
msgid ""
"LSsearchEntry : Invalid formaterFunction %{func} for extraDisplayedColumns "
"%{column}."