mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-22 16:33:48 +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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
function checkEmail($value,$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\-]+))$/';
|
||||
function checkEmail($value,$domain=NULL,$checkDns=true) {
|
||||
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)) {
|
||||
LSdebug('checkEmail : regex fail');
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
<dt class='LSform'>{$LSmail_mail_label}</dt>
|
||||
<dd class='LSform'>
|
||||
{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'>
|
||||
{html_options values=$LSmail_mails output=$LSmail_mails}
|
||||
</select>
|
||||
{/if}
|
||||
{else}
|
||||
<input type='text' name='LSmail_mail' id='LSmail_mail'/>
|
||||
{/if}
|
||||
|
|
Loading…
Reference in a new issue