Skip to content

Commit

Permalink
4.2.13
Browse files Browse the repository at this point in the history
Install : initialize com_mail params if empty
Uninstall : delete automsg scheduled tasks
  • Loading branch information
conseilgouz committed Jun 21, 2024
1 parent bfe13cf commit d16478e
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
4 changes: 2 additions & 2 deletions automsginstaller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="4.0" type="plugin" group="system" method="upgrade">
<name>plgautomsginstaller</name>
<author>ConseilGouz</author>
<creationDate>2024-06-20</creationDate>
<creationDate>2024-06-21</creationDate>
<copyright>(C)2024 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>4.2.12</version>
<version>4.2.13</version>
<description>AutoMsg</description>
<scriptfile>script.install.php</scriptfile>
<files>
Expand Down
4 changes: 2 additions & 2 deletions packages/com_automsg/automsg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension type="component" method="upgrade">
<name>COM_AUTOMSG</name>
<author>ConseilGouz</author>
<creationDate>2024-06-20</creationDate>
<creationDate>2024-06-21</creationDate>
<copyright>(C)2024 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>4.2.12</version>
<version>4.2.13</version>
<description>COM_AUTOMSG_XML_DESCRIPTION</description>
<namespace path="src">ConseilGouz\Component\Automsg</namespace>
<files folder="site">
Expand Down
4 changes: 2 additions & 2 deletions packages/library_automsg/automsg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<description>AutoMsg library</description>
<libraryname>automsg</libraryname>
<author>ConseilGouz</author>
<version>4.2.12</version>
<creationDate>2024-06-20</creationDate>
<version>4.2.13</version>
<creationDate>2024-06-21</creationDate>
<copyright>(C)2024 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
Expand Down
4 changes: 2 additions & 2 deletions packages/plg_content_automsg_j4/automsg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="4.0" type="plugin" group="content" method="upgrade">
<name>PLG_CONTENT_AUTOMSG</name>
<author>conseilgouz</author>
<creationDate>2024-06-20</creationDate>
<creationDate>2024-06-21</creationDate>
<copyright>Copyright (C) 2024 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>4.2.12</version>
<version>4.2.13</version>
<description>PLG_CONTENT_AUTOMSG_XML_DESCRIPTION</description>
<files>
<folder plugin="automsg">services</folder>
Expand Down
5 changes: 3 additions & 2 deletions packages/plg_task_automsg_j4/automsg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<extension version="4.1" type="plugin" group="task" method="upgrade">
<name>PLG_TASK_AUTOMSG</name>
<author>conseilgouz</author>
<creationDate>2024-06-20</creationDate>
<creationDate>2024-06-21</creationDate>
<copyright>Copyright (C) 2024 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>4.2.12</version>
<version>4.2.13</version>
<description>PLG_TASK_AUTOMSG_DESC</description>
<namespace path="src">ConseilGouz\Plugin\Task\AutoMsg</namespace>
<scriptfile>script.php</scriptfile>
<files>
<folder plugin="automsg">services</folder>
<folder>forms</folder>
Expand Down
35 changes: 35 additions & 0 deletions packages/plg_task_automsg_j4/script.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @package AutoMsg
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
* @copyright (C) 2024 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
* @license GNU/GPLv3
*/
// no direct access
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\Component\Scheduler\Administrator\Model\TaskModel;
use Joomla\Database\DatabaseInterface;

class plgtaskAutomsgInstallerScript
{
public function uninstall($parent)
{
$db = Factory::getContainer()->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;
}
}
4 changes: 2 additions & 2 deletions packages/plg_user_automsg_j4/automsg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="4.0" type="plugin" group="user" method="upgrade">
<name>PLG_USER_AUTOMSG_NAME</name>
<author>ConseilGouz</author>
<creationDate>2024-06-20</creationDate>
<creationDate>2024-06-21</creationDate>
<copyright>(C)2024 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>4.2.12</version>
<version>4.2.13</version>
<description>PLG_USER_AUTOMSG_XML_DESCRIPTION</description>
<files>
<folder plugin="automsg">services</folder>
Expand Down
12 changes: 12 additions & 0 deletions pkg_automsg_changelog.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
<changelogs>
<changelog>
<element>com_automsg</element>
<type>package</type>
<version>4.2.13</version>
<note>
<item>Update : 21/06/2024</item>
</note>
<fix>
<item>Install : initialize com_mail params if empty </item>
<item>Uninstall : delete automsg scheduled tasks</item>
</fix>
</changelog>
<changelog>
<element>com_automsg</element>
<type>package</type>
Expand Down
21 changes: 9 additions & 12 deletions script.install.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
/**
* @package AutoMsg
* Version : 4.0.0
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
* @copyright (C) 2024 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
Expand All @@ -10,7 +9,6 @@
// no direct access
defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Language\Text;
Expand All @@ -22,7 +20,6 @@
use Joomla\Database\DatabaseInterface;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use ConseilGouz\Component\Automsg\Administrator\Model\ConfigModel;

class PlgSystemAutomsgInstallerInstallerScript
{
Expand All @@ -37,7 +34,7 @@ class PlgSystemAutomsgInstallerInstallerScript
public function __construct()
{
$this->dir = __DIR__;
$this->lang = Factory::getLanguage();
$this->lang = Factory::getApplication()->getLanguage();

}
public function uninstall($parent)
Expand All @@ -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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit d16478e

Please sign in to comment.