From 708f570d9f85f4e722fc48b75912878a7d1a06cc Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 3 Apr 2014 13:37:55 +0000 Subject: [PATCH] Authorize multpile emails --- .../controllers/SurveillanceController.php | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/application/controllers/SurveillanceController.php b/application/controllers/SurveillanceController.php index 128f2786b..6ad64bda6 100644 --- a/application/controllers/SurveillanceController.php +++ b/application/controllers/SurveillanceController.php @@ -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); }