diff --git a/apps/maarch_entreprise/xml/config.xml.default b/apps/maarch_entreprise/xml/config.xml.default index 0f214138b4fd8e7ec07b1da351736d78c97bf431..c6fe1b231c0541824bd261a7a243c467d955bd6a 100755 --- a/apps/maarch_entreprise/xml/config.xml.default +++ b/apps/maarch_entreprise/xml/config.xml.default @@ -24,6 +24,15 @@ <customID></customID> <MaarchUrl>http://preview.maarchcourrier.com/</MaarchUrl> </CONFIG> + <SIGNATUREBOOK> + <validatedStatus>EENV</validatedStatus> + <validatedStatusOnlyVisa>EENV</validatedStatusOnlyVisa> + <refusedStatus>REJ_SIGN</refusedStatus> + <validatedStatusAnnot>COU</validatedStatusAnnot> + <refusedStatusAnnot>RET</refusedStatusAnnot> + <userWS>superadmin</userWS> + <passwordWS>superadmin</passwordWS> + </SIGNATUREBOOK> <CRYPT> <encrypt>false</encrypt> <pathtopublickey>/home/user/maarchkey.pub</pathtopublickey> diff --git a/modules/visa/batch/batch_tools.php b/bin/signatureBook/batch_tools.php old mode 100755 new mode 100644 similarity index 98% rename from modules/visa/batch/batch_tools.php rename to bin/signatureBook/batch_tools.php index 530de0483e84e9bc87c3b85470d5bf8a0eb3dbdc..2e841daae3995e6d5cbbebc3d6bf2df30191473a --- a/modules/visa/batch/batch_tools.php +++ b/bin/signatureBook/batch_tools.php @@ -165,7 +165,7 @@ function Bt_createNote($aArgs = []) function Bt_createAttachment($args = []) { $opts = [ - CURLOPT_URL => $GLOBALS['applicationUrl'] . 'rest/attachments', + CURLOPT_URL => rtrim($GLOBALS['applicationUrl'], "/") . '/rest/attachments', CURLOPT_HTTPHEADER => [ 'accept:application/json', 'content-type:application/json', diff --git a/modules/visa/batch/process_mailsFromSignatoryBook.php b/bin/signatureBook/process_mailsFromSignatoryBook.php old mode 100755 new mode 100644 similarity index 98% rename from modules/visa/batch/process_mailsFromSignatoryBook.php rename to bin/signatureBook/process_mailsFromSignatoryBook.php index 4379646b2a50f76d9526735d82ff22296c919812..f5599532080ee56e4cc2f892bd5c31ab83ff904d --- a/modules/visa/batch/process_mailsFromSignatoryBook.php +++ b/bin/signatureBook/process_mailsFromSignatoryBook.php @@ -73,11 +73,13 @@ if ($xmlconfig == false) { // Load config $config = $xmlconfig->CONFIG; $GLOBALS['MaarchDirectory'] = (string)$config->MaarchDirectory; -$GLOBALS['customId'] = (string)$config->CustomId; -$GLOBALS['applicationUrl'] = (string)$config->applicationUrl; +$GLOBALS['customId'] = (string)$config->customID; +$GLOBALS['applicationUrl'] = (string)$config->MaarchUrl; + +$config = $xmlconfig->SIGNATUREBOOK; $GLOBALS['userWS'] = (string)$config->userWS; $GLOBALS['passwordWS'] = (string)$config->passwordWS; -$GLOBALS['batchDirectory'] = $GLOBALS['MaarchDirectory'] . 'modules/visa/batch'; +$GLOBALS['batchDirectory'] = $GLOBALS['MaarchDirectory'] . 'bin/signatureBook'; $validatedStatus = (string)$config->validatedStatus; $validatedStatusOnlyVisa = (string)$config->validatedStatusOnlyVisa; $refusedStatus = (string)$config->refusedStatus; diff --git a/bin/signatureBook/scripts/retrieveMailFromExternalSignatoryBook.sh.default b/bin/signatureBook/scripts/retrieveMailFromExternalSignatoryBook.sh.default new file mode 100755 index 0000000000000000000000000000000000000000..ed270066651ec6f4d4e24439fd015c348e59af1e --- /dev/null +++ b/bin/signatureBook/scripts/retrieveMailFromExternalSignatoryBook.sh.default @@ -0,0 +1,4 @@ +#!/bin/sh +cd /var/www/html/MaarchCourrier/bin/signatureBook/ +filePath='/var/www/html/MaarchCourrier/bin/signatureBook/process_mailsFromSignatoryBook.php' +php $filePath -c /var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/config.xml diff --git a/migration/20.10/migrate.sh b/migration/20.10/migrate.sh index a2502b2cf8257edd4a3865d15246e4135510f79f..b06e1ee17a770a6eaeee65307738ec1ed6b4b82a 100755 --- a/migration/20.10/migrate.sh +++ b/migration/20.10/migrate.sh @@ -2,4 +2,5 @@ php ./migrateModulesConfig.php php ./migrateNotificationsProperties.php php ./migrateNotificationsConfig.php +php ./migrateRemoteSignatureBookConfig.php php ./migrateCustomXml.php # mettre en dernier diff --git a/migration/20.10/migrateNotificationsConfig.php b/migration/20.10/migrateNotificationsConfig.php index 9a16547c0db77391d0a0582dae9ba4846b82cd06..0af44700f7350484e5d290034883160d3d3a05ac 100755 --- a/migration/20.10/migrateNotificationsConfig.php +++ b/migration/20.10/migrateNotificationsConfig.php @@ -40,7 +40,9 @@ foreach ($customs as $custom) { if ($loadedXml && $loadedNotificationXml) { $loadedXml->CONFIG->MaarchDirectory = (string)$loadedNotificationXml->CONFIG->MaarchDirectory; $loadedXml->CONFIG->customID = (string)$loadedNotificationXml->CONFIG->customID; - $loadedXml->CONFIG->MaarchUrl = (string)$loadedNotificationXml->CONFIG->MaarchUrl; + if (empty($loadedXml->CONFIG->MaarchUrl)) { + $loadedXml->CONFIG->MaarchUrl = (string)$loadedNotificationXml->CONFIG->MaarchUrl; + } $res = formatXml($loadedXml); $fp = fopen($configPath, "w+"); diff --git a/migration/20.10/migrateRemoteSignatureBookConfig.php b/migration/20.10/migrateRemoteSignatureBookConfig.php new file mode 100755 index 0000000000000000000000000000000000000000..2c46aa33bad885cf50c905c9054579b73cedf08d --- /dev/null +++ b/migration/20.10/migrateRemoteSignatureBookConfig.php @@ -0,0 +1,75 @@ +<?php + +require '../../vendor/autoload.php'; + +chdir('../..'); + +$nonReadableFiles = []; +$migrated = 0; +$customs = scandir('custom'); + +foreach ($customs as $custom) { + if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { + continue; + } + + \SrcCore\models\DatabasePDO::reset(); + new \SrcCore\models\DatabasePDO(['customId' => $custom]); + $GLOBALS['customId'] = $custom; + + $configPath = "custom/{$custom}/apps/maarch_entreprise/xml/config.xml"; + $visaConfigPath = "modules/visa/batch/config/config.xml"; + if (file_exists($configPath)) { + if (!is_readable($configPath) || !is_writable($configPath)) { + $nonReadableFiles[] = $configPath; + continue; + } + if (is_readable($visaConfigPath) && is_writable($visaConfigPath)) { + $visaFilePath = $visaConfigPath; + } elseif (is_readable("custom/{$custom}/{$visaConfigPath}") && is_writable("custom/{$custom}/{$visaConfigPath}")) { + $visaFilePath = "custom/{$custom}/{$visaConfigPath}"; + } else { + printf("Aucun fichier de configuration de parapheur externe trouvé pour le custom {$custom}\n"); + continue; + } + $loadedXml = simplexml_load_file($configPath); + $loadedVisaXml = simplexml_load_file($visaFilePath); + + if ($loadedXml && $loadedVisaXml) { + $loadedXml->SIGNATUREBOOK->validatedStatus = (string)$loadedVisaXml->CONFIG->validatedStatus; + $loadedXml->SIGNATUREBOOK->validatedStatusOnlyVisa = (string)$loadedVisaXml->CONFIG->validatedStatusOnlyVisa; + $loadedXml->SIGNATUREBOOK->refusedStatus = (string)$loadedVisaXml->CONFIG->refusedStatus; + $loadedXml->SIGNATUREBOOK->validatedStatusAnnot = (string)$loadedVisaXml->CONFIG->validatedStatusAnnot; + $loadedXml->SIGNATUREBOOK->refusedStatusAnnot = (string)$loadedVisaXml->CONFIG->refusedStatusAnnot; + $loadedXml->SIGNATUREBOOK->userWS = (string)$loadedVisaXml->CONFIG->userWS; + $loadedXml->SIGNATUREBOOK->passwordWS = (string)$loadedVisaXml->CONFIG->passwordWS; + if (empty($loadedXml->CONFIG->MaarchUrl)) { + $loadedXml->CONFIG->MaarchUrl = (string)$loadedVisaXml->CONFIG->applicationUrl; + } + + $res = formatXml($loadedXml); + $fp = fopen($configPath, "w+"); + if ($fp) { + fwrite($fp, $res); + } + + $migrated++; + } + } +} + +foreach ($nonReadableFiles as $file) { + printf("The file %s it is not readable or not writable.\n", $file); +} + +printf($migrated . " custom(s) avec config.xml (visa) trouvé(s) et migré(s).\n"); + +function formatXml($simpleXMLElement) +{ + $xmlDocument = new DOMDocument('1.0'); + $xmlDocument->preserveWhiteSpace = false; + $xmlDocument->formatOutput = true; + $xmlDocument->loadXML($simpleXMLElement->asXML()); + + return $xmlDocument->saveXML(); +} diff --git a/modules/visa/batch/config/config.xml.default b/modules/visa/batch/config/config.xml.default deleted file mode 100755 index f8495defe200c900721f9126c7dba020d6b4f265..0000000000000000000000000000000000000000 --- a/modules/visa/batch/config/config.xml.default +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <CustomId></CustomId> - <validatedStatus>EENV</validatedStatus> - <validatedStatusOnlyVisa>EENV</validatedStatusOnlyVisa> - <refusedStatus>REJ_SIGN</refusedStatus> - <validatedStatusAnnot>COU</validatedStatusAnnot> - <refusedStatusAnnot>RET</refusedStatusAnnot> - <applicationUrl>http://localhost/MaarchCourrier/</applicationUrl> - <userWS>superadmin</userWS> - <passwordWS>superadmin</passwordWS> - </CONFIG> -</ROOT> \ No newline at end of file diff --git a/modules/visa/batch/scripts/retrieveMailFromExternalSignatoryBook.sh.default b/modules/visa/batch/scripts/retrieveMailFromExternalSignatoryBook.sh.default deleted file mode 100755 index 002582bfcd1741c158b484439041ffcaa211a66c..0000000000000000000000000000000000000000 --- a/modules/visa/batch/scripts/retrieveMailFromExternalSignatoryBook.sh.default +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -cd /var/www/html/MaarchCourrier/modules/visa/batch/ -filePath='/var/www/html/MaarchCourrier/modules/visa/batch/process_mailsFromSignatoryBook.php' -php $filePath -c /var/www/html/MaarchCourrier/modules/visa/batch/config/config.xml