Authorize multpile emails

This commit is contained in:
Michael RICOIS 2014-04-03 13:37:55 +00:00
parent 7ec9fdd9df
commit 708f570d9f

View File

@ -145,27 +145,41 @@ class SurveillanceController extends Zend_Controller_Action
//Vérification siret / email / ref
if (empty($siret) || empty($email) || empty($ref)){
$msg = 'Erreur email ou reférence non définie !';
}
elseif (!$validateur->isValid($email)) {
$msg = "Email invalide.";
}
//Vérification de l'encours (chiffres)
elseif (!preg_match('/([0-9]+)/', $encours)){
$msg = 'Encours incorrect';
} else {
if (!empty($delete)){
$delete = true;
}
$ws = new WsScores();
$set = $ws->setSurveillance($siret, $email, $ref, $source, $delete, $encours);
if ($set) {
if ($delete) { $msg = "Suppression surveillance $source"; }
else { $msg = "Mise sous surveillance $source"; }
} else {
if ($delete) { $msg = "Erreur lors de la suppression de la surveillance $source"; }
else { $msg = "Erreur lors de la mise sous surveillance $source"; }
}
$emails = explode(';', $email);
$emailsValid = true;
foreach ( $emails as $email ) {
if ( !$validateur->isValid($email) ) {
$emailsValid = false;
break;
}
}
if ( $emailsValid ) {
//Vérification de l'encours (chiffres)
if (!preg_match('/([0-9]+)/', $encours)){
$msg = 'Encours incorrect';
} else {
if (!empty($delete)){
$delete = true;
}
$ws = new WsScores();
$set = $ws->setSurveillance($siret, $email, $ref, $source, $delete, $encours);
if ($set) {
if ($delete) { $msg = "Suppression surveillance $source"; }
else { $msg = "Mise sous surveillance $source"; }
} else {
if ($delete) { $msg = "Erreur lors de la suppression de la surveillance $source"; }
else { $msg = "Erreur lors de la mise sous surveillance $source"; }
}
}
} else {
$msg = "Email invalide.";
}
}
$this->view->assign('msg', $msg);
}