Skip to content
Snippets Groups Projects
Verified Commit 4313ccaa authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #13679 TIME 2 Use config.xml in visa script + docker + doc + move to bin folder

parent 2eda8a10
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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',
......
......@@ -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;
......
#!/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
......@@ -2,4 +2,5 @@
php ./migrateModulesConfig.php
php ./migrateNotificationsProperties.php
php ./migrateNotificationsConfig.php
php ./migrateRemoteSignatureBookConfig.php
php ./migrateCustomXml.php # mettre en dernier
......@@ -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+");
......
<?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();
}
<?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
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment