From b03d1b82df7122d6def8cea8830c67d779082bb7 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Tue, 30 Apr 2019 14:50:17 +0200
Subject: [PATCH] FEAT #10460 TIME 0:30 move externalMailsEntities.xml in
 migration

---
 migration/19.04/migrate.sh            |  1 +
 migration/19.04/migrateSendmail_2.php | 34 +++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 migration/19.04/migrateSendmail_2.php

diff --git a/migration/19.04/migrate.sh b/migration/19.04/migrate.sh
index 33aa46c4f89..7afeb536cd7 100755
--- a/migration/19.04/migrate.sh
+++ b/migration/19.04/migrate.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 php ./migrateSendmail.php
+php ./migrateSendmail_2.php
 php ./migrateExport.php
 php ./migrateFeature.php
 php ./migrateNewNature.php
diff --git a/migration/19.04/migrateSendmail_2.php b/migration/19.04/migrateSendmail_2.php
new file mode 100644
index 00000000000..1e188b2586f
--- /dev/null
+++ b/migration/19.04/migrateSendmail_2.php
@@ -0,0 +1,34 @@
+<?php
+
+require '../../vendor/autoload.php';
+
+chdir('../..');
+
+$migrated = 0;
+$customs =  scandir('custom');
+foreach ($customs as $custom) {
+    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
+        continue;
+    }
+
+    $xmlfile = null;
+    $path = "custom/{$custom}/modules/sendmail/batch/config/externalMailsEntities.xml";
+    if (file_exists($path)) {
+        $xmlfile = simplexml_load_file($path);
+    }
+
+    if ($xmlfile) {
+        if (!is_dir("custom/{$custom}/modules/sendmail/xml")) {
+            echo "Création du dossier custom/{$custom}/modules/sendmail/xml...\n";
+            if (!mkdir("custom/{$custom}/modules/sendmail/xml", 0777, true)) {
+                die('Echec lors de la création des répertoires...');
+            }
+        }
+
+        rename("custom/{$custom}/modules/sendmail/batch/config/externalMailsEntities.xml", "custom/{$custom}/modules/sendmail/xml/externalMailsEntities.xml");
+
+        $migrated++;
+    }
+}
+
+printf($migrated . " custom(s) avec externalMailsEntities.xml trouvé(s) et déplacé(s).\n");
-- 
GitLab