From 0fd6279f1f141387cffda671f3a5db7d252e4e1c Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Wed, 22 Apr 2020 11:36:27 +0100 Subject: [PATCH] FEAT #13679 TIME 1:45 update retrieveMailFromExternalSignatoryBook.sh + breaking change --- migration/20.10/migrateModulesConfig.php | 2 +- .../20.10/migrateNotificationsConfig.php | 3 +- .../20.10/migrateNotificationsProperties.php | 2 +- .../migrateRemoteSignatureBookConfig.php | 34 ++++++++++++++++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/migration/20.10/migrateModulesConfig.php b/migration/20.10/migrateModulesConfig.php index 443bdf73110..8a75bbd5da1 100755 --- a/migration/20.10/migrateModulesConfig.php +++ b/migration/20.10/migrateModulesConfig.php @@ -9,7 +9,7 @@ $migrated = 0; $customs = scandir('custom'); foreach ($customs as $custom) { - if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { + if (in_array($custom, ['custom.json', 'custom.xml', '.', '..'])) { continue; } diff --git a/migration/20.10/migrateNotificationsConfig.php b/migration/20.10/migrateNotificationsConfig.php index 0af44700f73..301e0869b23 100755 --- a/migration/20.10/migrateNotificationsConfig.php +++ b/migration/20.10/migrateNotificationsConfig.php @@ -9,7 +9,7 @@ $migrated = 0; $customs = scandir('custom'); foreach ($customs as $custom) { - if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { + if (in_array($custom, ['custom.json', 'custom.xml', '.', '..'])) { continue; } @@ -61,6 +61,7 @@ foreach ($customs as $custom) { foreach ($notifications as $notification) { \Notification\models\NotificationScheduleModel::createScriptNotification(['notification_sid' => $notification['notification_sid'], 'notification_id' => $notification['notification_id']]); } + printf("Si les scripts de notifications sont lancés dans la crontab, il faut modifier les chemins. Tous les scripts sont dans le dossier : bin/notification/scripts/ \n"); $migrated++; } diff --git a/migration/20.10/migrateNotificationsProperties.php b/migration/20.10/migrateNotificationsProperties.php index 96b18129efd..11a40b13839 100644 --- a/migration/20.10/migrateNotificationsProperties.php +++ b/migration/20.10/migrateNotificationsProperties.php @@ -7,7 +7,7 @@ chdir('../..'); $customs = scandir('custom'); $migrated = 0; foreach ($customs as $custom) { - if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { + if (in_array($custom, ['custom.json', 'custom.xml', '.', '..'])) { continue; } diff --git a/migration/20.10/migrateRemoteSignatureBookConfig.php b/migration/20.10/migrateRemoteSignatureBookConfig.php index 2c46aa33bad..9506d5fc8dc 100755 --- a/migration/20.10/migrateRemoteSignatureBookConfig.php +++ b/migration/20.10/migrateRemoteSignatureBookConfig.php @@ -9,7 +9,7 @@ $migrated = 0; $customs = scandir('custom'); foreach ($customs as $custom) { - if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { + if (in_array($custom, ['custom.json', 'custom.xml', '.', '..'])) { continue; } @@ -53,6 +53,8 @@ foreach ($customs as $custom) { fwrite($fp, $res); } + createScript(); + $migrated++; } } @@ -73,3 +75,33 @@ function formatXml($simpleXMLElement) return $xmlDocument->saveXML(); } + +function createScript() +{ + $corePath = str_replace('migration/20.10', '', __DIR__); + $config = $corePath . \SrcCore\models\CoreConfigModel::getConfigPath(); + + if (!empty($GLOBALS['customId'])) { + $folderScript = $corePath.'custom/'.$GLOBALS['customId'].'/bin/signatureBook/scripts/'; + if (!file_exists($folderScript)) { + mkdir($folderScript, 0777, true); + } + $scriptPath = $folderScript . 'retrieveMailFromExternalSignatoryBook.sh'; + } else { + $scriptPath = $corePath.'bin/signatureBook/scripts/retrieveMailFromExternalSignatoryBook.sh'; + } + $fileToOpen = fopen($scriptPath, 'w+'); + + fwrite($fileToOpen, '#!/bin/sh'); + fwrite($fileToOpen, "\n"); + fwrite($fileToOpen, 'cd ' . $corePath . 'bin/signatureBook/'); + fwrite($fileToOpen, "\n"); + fwrite($fileToOpen, 'filePath=\''.$corePath.'bin/signatureBook/process_mailsFromSignatoryBook.php\''); + fwrite($fileToOpen, "\n"); + fwrite($fileToOpen, 'php $filePath -c ' . $config); + fwrite($fileToOpen, "\n"); + fclose($fileToOpen); + shell_exec('chmod +x '. $scriptPath); + + printf("Si le script process_mailsFromSignatoryBook.php est lancé dans la crontab, il faut modifier le chemin comme ceci : " . $scriptPath . "\n"); +} -- GitLab