mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-23 02:19:07 +01:00
- LSmail : input type text plutot qu'un select lorsqu'il y a qu'un seul mail
proposé - LSformRule_email : possibilité de verifier si le domaine répond à une regex - checkEmail() : ajout d'un paramètre en deuxième position pour tester le domaine
This commit is contained in:
parent
d5cb294d65
commit
aba34f8439
3 changed files with 10 additions and 3 deletions
|
@ -38,7 +38,7 @@ class LSformRule_email extends LSformRule {
|
||||||
* @return boolean true si la valeur est valide, false sinon
|
* @return boolean true si la valeur est valide, false sinon
|
||||||
*/
|
*/
|
||||||
function validate($value,$option=array(),$formElement) {
|
function validate($value,$option=array(),$formElement) {
|
||||||
return checkEmail($value,$option['param']['checkDomain']);
|
return checkEmail($value,$option['param']['domain'],$option['param']['checkDomain']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,8 +238,11 @@ function LSdebug_print($return=false) {
|
||||||
return $basedn;
|
return $basedn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkEmail($value,$checkDns=true) {
|
function checkEmail($value,$domain=NULL,$checkDns=true) {
|
||||||
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
|
if (!$domain) {
|
||||||
|
$domain = '((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))';
|
||||||
|
}
|
||||||
|
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@'.$domain.'$/';
|
||||||
|
|
||||||
if (!preg_match($regex, $value)) {
|
if (!preg_match($regex, $value)) {
|
||||||
LSdebug('checkEmail : regex fail');
|
LSdebug('checkEmail : regex fail');
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
<dt class='LSform'>{$LSmail_mail_label}</dt>
|
<dt class='LSform'>{$LSmail_mail_label}</dt>
|
||||||
<dd class='LSform'>
|
<dd class='LSform'>
|
||||||
{if $LSmail_mails != ""}
|
{if $LSmail_mails != ""}
|
||||||
|
{if $LSmail_mails|@count==1}
|
||||||
|
<input type='text' name='LSmail_mail' id='LSmail_mail' value='{$LSmail_mails[0]}'/>
|
||||||
|
{else}
|
||||||
<select name='LSmail_mail' id='LSmail_mail'>
|
<select name='LSmail_mail' id='LSmail_mail'>
|
||||||
{html_options values=$LSmail_mails output=$LSmail_mails}
|
{html_options values=$LSmail_mails output=$LSmail_mails}
|
||||||
</select>
|
</select>
|
||||||
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
<input type='text' name='LSmail_mail' id='LSmail_mail'/>
|
<input type='text' name='LSmail_mail' id='LSmail_mail'/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue