diff --git a/migration/19.04/migrate.sh b/migration/19.04/migrate.sh index 7afeb536cd729eed81d427a9a58ab6580c0813bf..427f37a3ac14e9b36ac833e473e3085442bad190 100755 --- a/migration/19.04/migrate.sh +++ b/migration/19.04/migrate.sh @@ -5,3 +5,4 @@ php ./migrateExport.php php ./migrateFeature.php php ./migrateNewNature.php php ./refactorPriorities.php +php ./refactorRemoteSignatoryBooks.php diff --git a/migration/19.04/refactorRemoteSignatoryBooks.php b/migration/19.04/refactorRemoteSignatoryBooks.php new file mode 100644 index 0000000000000000000000000000000000000000..be684c1fb1cb93a67b0018b53a1b490b5cca6130 --- /dev/null +++ b/migration/19.04/refactorRemoteSignatoryBooks.php @@ -0,0 +1,46 @@ +<?php + +chdir('../..'); + +$migrated = 0; +$nonReadableFiles = []; +$customs = scandir('custom'); + +foreach ($customs as $custom) { + if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') { + continue; + } + + $priorities = []; + $path = "custom/{$custom}/modules/visa/xml/remoteSignatoryBooks.xml"; + if (file_exists($path)) { + if (!is_readable($path) || !is_writable($path)) { + $nonReadableFiles[] = $path; + continue; + } + $loadedXml = simplexml_load_file($path); + if ($loadedXml) { + $newSignatoryBook = $loadedXml->addChild('signatoryBook'); + $newSignatoryBook->addChild('id', 'maarchParapheur'); + $newSignatoryBook->addChild('userId', ' '); + $newSignatoryBook->addChild('password', ' '); + $newSignatoryBook->addChild('url', ' '); + $newSignatoryBook->addChild('signature', 'SIGN'); + $newSignatoryBook->addChild('annotation', 'NOTE'); + $newSignatoryBook->addChild('externalValidated', 'VAL'); + $newSignatoryBook->addChild('externalRefused', 'REF'); + + $res = $loadedXml->asXML(); + $fp = fopen($path, "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 un fichier remoteSignatoryBooks.xml trouvé(s) et refactoré(s).\n");