From b06101fa030a11c830c5aa5752310cb4eb5c5f06 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Fri, 27 Sep 2019 14:42:50 +0100
Subject: [PATCH] FIX #11622 improve notification scheduler + FIX #11455
 infinite loop if contact already exists + retex iparapheur

---
 apps/maarch_entreprise/class/class_contacts_v2_Abstract.php | 2 +-
 modules/visa/class/IParapheurController.php                 | 6 ------
 .../models/NotificationScheduleModelAbstract.php            | 4 ++--
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php b/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php
index e9308141552..871201b55cd 100755
--- a/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php
+++ b/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php
@@ -167,7 +167,7 @@ abstract class contacts_v2_Abstract extends Database
                 $path_contacts_confirm = $_SESSION['config']['businessappurl'].'index.php?page=contacts_v2_confirm';
             }
             header(
-                'location: '.$path_contacts_confirm.'&mode='.$mode.'&mycontact='.$mycontact
+                'location: '.$path_contacts_confirm.'&body_loaded&mode='.$mode.'&mycontact='.$mycontact
             );
             exit;
         }
diff --git a/modules/visa/class/IParapheurController.php b/modules/visa/class/IParapheurController.php
index d496ea7ba8c..7acb32cac09 100755
--- a/modules/visa/class/IParapheurController.php
+++ b/modules/visa/class/IParapheurController.php
@@ -193,12 +193,6 @@ class IParapheurController
 
         $curlReturn = $curlReturn = self::returnCurl($xmlPostString, $aArgs['config']);
 
-        if (!$curlReturn['response']) {
-            // TODO gestin d'une erreur
-            echo $curlReturn['error'];
-            return false;
-        }
-
         $response = $curlReturn['response']->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://www.adullact.org/spring-ws/iparapheur/1.0')->GetDossierResponse[0];
         if ($response->MessageRetour->codeRetour == $aArgs['config']['data']['errorCode']) {
             // TODO gestion d'une potentielle erreur
diff --git a/src/app/notification/models/NotificationScheduleModelAbstract.php b/src/app/notification/models/NotificationScheduleModelAbstract.php
index 7f90bded0ad..1f1a74328a9 100755
--- a/src/app/notification/models/NotificationScheduleModelAbstract.php
+++ b/src/app/notification/models/NotificationScheduleModelAbstract.php
@@ -83,10 +83,10 @@ abstract class NotificationScheduleModelAbstract
         ];
         foreach ($lines as $cronLine) {
             $cronLine = preg_replace('![ \t]+!', ' ', trim($cronLine));
-            if ($aArgs['setHiddenValue'] && (strpos($cronLine, '#') !== false || strpos($cronLine, 'MAILTO=') !== false)) {
+            if ($aArgs['setHiddenValue'] && ($cronLine[0] == '#' || ctype_alpha($cronLine[0]))) {
                 $data[] = $emptyLine;
                 continue;
-            } elseif (!$aArgs['setHiddenValue'] && (strpos($cronLine, '#') === 0 || strpos($cronLine, 'MAILTO=') === 0)) {
+            } elseif (!$aArgs['setHiddenValue'] && ($cronLine[0] == '#' || ctype_alpha($cronLine[0]))) {
                 $data[] = [ 'm' => $cronLine];
                 continue;
             }
-- 
GitLab