Skip to content
Snippets Groups Projects
Verified Commit 6c137074 authored by Damien's avatar Damien
Browse files

FIX #8489 Migration

parent ad705ba6
No related branches found
No related tags found
No related merge requests found
...@@ -339,19 +339,6 @@ class Install extends functions ...@@ -339,19 +339,6 @@ class Install extends functions
$cheminCustomMaarchCourrierModulesNotificationsScripts = realpath('.')."/custom/cs_$databasename/modules/notifications/batch/scripts"; $cheminCustomMaarchCourrierModulesNotificationsScripts = realpath('.')."/custom/cs_$databasename/modules/notifications/batch/scripts";
mkdir($cheminCustomMaarchCourrierModulesNotificationsScripts, 0755); mkdir($cheminCustomMaarchCourrierModulesNotificationsScripts, 0755);
/** Création répertoire sendmail dans le custom **/
$cheminCustomMaarchCourrierModulesSendmail = realpath('.')."/custom/cs_$databasename/modules/sendmail";
mkdir($cheminCustomMaarchCourrierModulesSendmail, 0755);
$cheminCustomMaarchCourrierModulesSendmailBatch = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatch, 0755);
$cheminCustomMaarchCourrierModulesSendmailBatchConfig = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/config";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatchConfig, 0755);
$cheminCustomMaarchCourrierModulesSendmailBatchScripts = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/scripts";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatchScripts, 0755);
/** Création répertoire LDAP dans le custom **/ /** Création répertoire LDAP dans le custom **/
$cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap"; $cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap";
mkdir($cheminCustomMaarchCourrierModulesLdap, 0755); mkdir($cheminCustomMaarchCourrierModulesLdap, 0755);
...@@ -393,25 +380,6 @@ class Install extends functions ...@@ -393,25 +380,6 @@ class Install extends functions
mkdir($cheminCustomMaarchCourrierModulesNotificationsScripts, 0755); mkdir($cheminCustomMaarchCourrierModulesNotificationsScripts, 0755);
} }
/* Création répertoire sendmail dans le custom **/
if (!is_dir(realpath('.')."/custom/cs_$databasename/modules/sendmail/")) {
$cheminCustomMaarchCourrierModulesSendmail = realpath('.')."/custom/cs_$databasename/modules/sendmail";
mkdir($cheminCustomMaarchCourrierModulesSendmail, 0755);
}
if (!is_dir(realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/")) {
$cheminCustomMaarchCourrierModulesSendmailBatch = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatch, 0755);
}
if (!is_dir(realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/config/")) {
$cheminCustomMaarchCourrierModulesSendmailBatchConfig = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/config";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatchConfig, 0755);
}
if (!is_dir(realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/scripts/")) {
$cheminCustomMaarchCourrierModulesSendmailBatchScripts = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/scripts";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatchScripts, 0755);
}
if (!is_dir(realpath('.')."/custom/cs_$databasename/modules/ldap/")) { if (!is_dir(realpath('.')."/custom/cs_$databasename/modules/ldap/")) {
$cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap"; $cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap";
mkdir($cheminCustomMaarchCourrierModulesLdap, 0755); mkdir($cheminCustomMaarchCourrierModulesLdap, 0755);
...@@ -560,19 +528,6 @@ class Install extends functions ...@@ -560,19 +528,6 @@ class Install extends functions
$cheminCustomMaarchCourrierModulesNotificationsScripts = realpath('.')."/custom/cs_$databasename/modules/notifications/batch/scripts"; $cheminCustomMaarchCourrierModulesNotificationsScripts = realpath('.')."/custom/cs_$databasename/modules/notifications/batch/scripts";
mkdir($cheminCustomMaarchCourrierModulesNotificationsScripts, 0755); mkdir($cheminCustomMaarchCourrierModulesNotificationsScripts, 0755);
/** Création répertoire sendmail dans le custom **/
$cheminCustomMaarchCourrierModulesSendmail = realpath('.')."/custom/cs_$databasename/modules/sendmail";
mkdir($cheminCustomMaarchCourrierModulesSendmail, 0755);
$cheminCustomMaarchCourrierModulesSendmailBatch = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatch, 0755);
$cheminCustomMaarchCourrierModulesSendmailBatchConfig = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/config";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatchConfig, 0755);
$cheminCustomMaarchCourrierModulesSendmailBatchScripts = realpath('.')."/custom/cs_$databasename/modules/sendmail/batch/scripts";
mkdir($cheminCustomMaarchCourrierModulesSendmailBatchScripts, 0755);
/** Création répertoire LDAP dans le custom **/ /** Création répertoire LDAP dans le custom **/
$cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap"; $cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap";
mkdir($cheminCustomMaarchCourrierModulesLdap, 0755); mkdir($cheminCustomMaarchCourrierModulesLdap, 0755);
...@@ -961,12 +916,6 @@ class Install extends functions ...@@ -961,12 +916,6 @@ class Install extends functions
10 12 * * 0 rm -Rf '.realpath('.').'/modules/notifications/batch/logs/process_event_stack/*.log 10 12 * * 0 rm -Rf '.realpath('.').'/modules/notifications/batch/logs/process_event_stack/*.log
11 12 * * 0 rm -Rf '.realpath('.').'/modules/notifications/batch/logs/process_email_stack/*.log 11 12 * * 0 rm -Rf '.realpath('.').'/modules/notifications/batch/logs/process_email_stack/*.log
######################sendmail####################################################
*/2 * * * * '.realpath('.').'/custom/cs_'.$_SESSION['config']['databasename'].'/modules/sendmail/batch/scripts/sendmail.sh >/dev/null 2>&1
0 12 * * 0 rm -Rf '.realpath('.').'/modules/sendmail/batch/logs/*.log
######################fulltext################################################### ######################fulltext###################################################
......
#!/bin/sh
php ./migrateSendmail.php
<?php
require '../../vendor/autoload.php';
chdir('../..');
$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]);
$xmlfile = null;
$path = "custom/{$custom}/modules/sendmail/batch/config/config.xml";
if (file_exists($path)) {
$xmlfile = simplexml_load_file($path);
}
if ($xmlfile) {
$pass = '';
if (!empty((string)$xmlfile->MAILER->smtp_password)) {
$pass = \SrcCore\models\PasswordModel::encrypt(['password' => (string)$xmlfile->MAILER->smtp_password]);
}
$data = [
'type' => (string)$xmlfile->MAILER->type,
'host' => (string)$xmlfile->MAILER->smtp_host,
'port' => (int)$xmlfile->MAILER->smtp_port,
'user' => (string)$xmlfile->MAILER->smtp_user,
'password' => $pass,
'auth' => (string)$xmlfile->MAILER->smtp_auth == 'true' ? true : false,
'from' => (string)$xmlfile->MAILER->mailfrom,
'secure' => 'ssl',
'charset' => 'utf-8'
];
$data = json_encode($data);
\Configuration\models\ConfigurationModel::update(['set' => ['value' => $data], 'where' => ['service = ?'], 'data' => ['admin_email_server']]);
$migrated++;
}
// $sendmails = \SrcCore\models\DatabaseModel::select([
// 'select' => ['*'],
// 'table' => ['sendmail'],
// 'order_by' => ['creation_date']
// ]);
//
// foreach ($sendmails as $sendmail) {
//
// $user = \User\models\UserModel::getByLogin(['login' => $sendmail['user_id'], 'select' => ['id']]);
//
// \Email\models\EmailModel::create([
// 'userId' => $user['id'],
// 'sender' => json_encode($data['sender']),
// 'recipients' => json_encode($data['recipients']),
// 'cc' => empty($data['cc']) ? '[]' : json_encode($data['cc']),
// 'cci' => empty($data['cci']) ? '[]' : json_encode($data['cci']),
// 'object' => $data['object'],
// 'body' => $data['body'],
// 'document' => empty($data['document']) ? null : json_encode($data['document']),
// 'isHtml' => $data['isHtml'] ? 'true' : 'false',
// 'status' => $data['status'] == 'DRAFT' ? 'DRAFT' : 'WAITING',
// 'messageExchangeId' => $data['messageExchangeId']
// ]);
// }
}
printf($migrated . " custom(s) avec une configuration sendmail trouvé(s) et migré(s).\n");
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