diff --git a/install/class/Class_Install.php b/install/class/Class_Install.php index 46bc87d0321ad395ad375929735bafae8ee0a313..e54b98f0cb0ce401eab63c006829e8fb1543f269 100755 --- a/install/class/Class_Install.php +++ b/install/class/Class_Install.php @@ -339,19 +339,6 @@ class Install extends functions $cheminCustomMaarchCourrierModulesNotificationsScripts = realpath('.')."/custom/cs_$databasename/modules/notifications/batch/scripts"; 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 **/ $cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap"; mkdir($cheminCustomMaarchCourrierModulesLdap, 0755); @@ -393,25 +380,6 @@ class Install extends functions 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/")) { $cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap"; mkdir($cheminCustomMaarchCourrierModulesLdap, 0755); @@ -560,19 +528,6 @@ class Install extends functions $cheminCustomMaarchCourrierModulesNotificationsScripts = realpath('.')."/custom/cs_$databasename/modules/notifications/batch/scripts"; 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 **/ $cheminCustomMaarchCourrierModulesLdap = realpath('.')."/custom/cs_$databasename/modules/ldap"; mkdir($cheminCustomMaarchCourrierModulesLdap, 0755); @@ -961,12 +916,6 @@ class Install extends functions 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 -######################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################################################### diff --git a/migration/19.04/migrate.sh b/migration/19.04/migrate.sh new file mode 100644 index 0000000000000000000000000000000000000000..8cf9b3b2ca34d2e9f54d41fd8ece3818f5f086b2 --- /dev/null +++ b/migration/19.04/migrate.sh @@ -0,0 +1,4 @@ +#!/bin/sh +php ./migrateSendmail.php + + diff --git a/migration/19.04/migrateSendmail.php b/migration/19.04/migrateSendmail.php new file mode 100644 index 0000000000000000000000000000000000000000..b144ed62764807dbe0873caaca8827fa30180a33 --- /dev/null +++ b/migration/19.04/migrateSendmail.php @@ -0,0 +1,73 @@ +<?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");