diff --git a/automsginstaller.xml b/automsginstaller.xml index 95014b5..0e1e4d0 100644 --- a/automsginstaller.xml +++ b/automsginstaller.xml @@ -2,12 +2,12 @@ plgautomsginstaller ConseilGouz - 2024-06-20 + 2024-06-21 (C)2024 ConseilGouz. All rights reserved. GNU General Public License version 3 or later; see LICENSE.txt pascal.leconte@conseilgouz.com www.conseilgouz.com - 4.2.12 + 4.2.13 AutoMsg script.install.php diff --git a/packages/com_automsg/automsg.xml b/packages/com_automsg/automsg.xml index 70c1b94..64a40a5 100644 --- a/packages/com_automsg/automsg.xml +++ b/packages/com_automsg/automsg.xml @@ -2,12 +2,12 @@ COM_AUTOMSG ConseilGouz - 2024-06-20 + 2024-06-21 (C)2024 ConseilGouz. All rights reserved. GNU General Public License version 3 or later; see LICENSE.txt pascal.leconte@conseilgouz.com www.conseilgouz.com - 4.2.12 + 4.2.13 COM_AUTOMSG_XML_DESCRIPTION ConseilGouz\Component\Automsg diff --git a/packages/library_automsg/automsg.xml b/packages/library_automsg/automsg.xml index 5c73d3a..8c3e9ae 100644 --- a/packages/library_automsg/automsg.xml +++ b/packages/library_automsg/automsg.xml @@ -4,8 +4,8 @@ AutoMsg library automsg ConseilGouz - 4.2.12 - 2024-06-20 + 4.2.13 + 2024-06-21 (C)2024 ConseilGouz. All rights reserved. GNU General Public License version 3 or later; https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL pascal.leconte@conseilgouz.com diff --git a/packages/plg_content_automsg_j4/automsg.xml b/packages/plg_content_automsg_j4/automsg.xml index 2194bf8..266e809 100644 --- a/packages/plg_content_automsg_j4/automsg.xml +++ b/packages/plg_content_automsg_j4/automsg.xml @@ -2,12 +2,12 @@ PLG_CONTENT_AUTOMSG conseilgouz - 2024-06-20 + 2024-06-21 Copyright (C) 2024 ConseilGouz. All rights reserved. GNU General Public License version 3 or later; see LICENSE.txt pascal.leconte@conseilgouz.com www.conseilgouz.com - 4.2.12 + 4.2.13 PLG_CONTENT_AUTOMSG_XML_DESCRIPTION services diff --git a/packages/plg_task_automsg_j4/automsg.xml b/packages/plg_task_automsg_j4/automsg.xml index f5778be..7d255e3 100644 --- a/packages/plg_task_automsg_j4/automsg.xml +++ b/packages/plg_task_automsg_j4/automsg.xml @@ -2,14 +2,15 @@ PLG_TASK_AUTOMSG conseilgouz - 2024-06-20 + 2024-06-21 Copyright (C) 2024 ConseilGouz. All rights reserved. GNU General Public License version 3 or later; see LICENSE.txt pascal.leconte@conseilgouz.com www.conseilgouz.com - 4.2.12 + 4.2.13 PLG_TASK_AUTOMSG_DESC ConseilGouz\Plugin\Task\AutoMsg + script.php services forms diff --git a/packages/plg_task_automsg_j4/script.php b/packages/plg_task_automsg_j4/script.php new file mode 100644 index 0000000..4691ef4 --- /dev/null +++ b/packages/plg_task_automsg_j4/script.php @@ -0,0 +1,35 @@ +get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select('id'); + $query->from('#__scheduler_tasks'); + $query->where('type = ' . $db->quote('automsg')); + $db->setQuery($query); + $found = $db->loadObjectList(); + foreach ($found as $one) { // should be only one, but in case, just loop + $pks['id'] = $one->id; + $task = new TaskModel(array('ignore_request' => true)); + $table = $task->getTable(); + $table->delete($pks); + } + return true; + } +} diff --git a/packages/plg_user_automsg_j4/automsg.xml b/packages/plg_user_automsg_j4/automsg.xml index 4251f0f..6a05e52 100644 --- a/packages/plg_user_automsg_j4/automsg.xml +++ b/packages/plg_user_automsg_j4/automsg.xml @@ -2,12 +2,12 @@ PLG_USER_AUTOMSG_NAME ConseilGouz - 2024-06-20 + 2024-06-21 (C)2024 ConseilGouz. All rights reserved. GNU General Public License version 3 or later; see LICENSE.txt pascal.leconte@conseilgouz.com www.conseilgouz.com - 4.2.12 + 4.2.13 PLG_USER_AUTOMSG_XML_DESCRIPTION services diff --git a/pkg_automsg_changelog.xml b/pkg_automsg_changelog.xml index 8c6dbce..7c1377c 100644 --- a/pkg_automsg_changelog.xml +++ b/pkg_automsg_changelog.xml @@ -1,4 +1,16 @@ + + com_automsg + package + 4.2.13 + + Update : 21/06/2024 + + + Install : initialize com_mail params if empty + Uninstall : delete automsg scheduled tasks + + com_automsg package diff --git a/script.install.php b/script.install.php index 82444b3..c7c0afd 100644 --- a/script.install.php +++ b/script.install.php @@ -1,7 +1,6 @@ dir = __DIR__; - $this->lang = Factory::getLanguage(); + $this->lang = Factory::getApplication()->getLanguage(); } public function uninstall($parent) @@ -48,9 +45,6 @@ public function uninstall($parent) $table->delete('com_automsg.usermail'); $table->delete('com_automsg.asyncmail'); $table->delete('com_automsg.report'); - $task = new TaskModel(array('ignore_request' => true)); - $table = $task->getTable(); - $table->delete('automsg'); return true; } public function preflight($route, $installer) @@ -373,20 +367,23 @@ private function check_email_config() { $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true); - $query->select('params'); + $query->select('*'); $query->from('#__extensions'); $query->where('type = ' . $db->quote('component')); $query->where('element = ' . $db->quote('com_mails')); $db->setQuery($query); - $params = $db->loadResult(); - if (!$params) { + $cfg = $db->loadObject(); + if (!$cfg) { Factory::getApplication()->enqueueMessage(Text::_('PLG_AUTOMSG_EMAIL_CONFIG_NOTOK'), 'error'); return; } - if (strpos($params, 'plaintext') === false) { + if (!$cfg->params) { // not yet created : create default + $cfg->params = '{"mail_style":"plaintext","alternative_mailconfig":"0","copy_mails":"0","attachment_folder":""}'; + } + if (strpos($cfg->params, 'plaintext') === false) { return; } - $params = str_replace('plaintext', 'both', $params); + $params = str_replace('plaintext', 'both', $cfg->params); $query = $db->getQuery(true) ->update('#__extensions') ->set($db->qn('params').' = '.$db->q($params))