Skip to content

Commit

Permalink
4.2.0
Browse files Browse the repository at this point in the history
Languages : untranslated fields
Lost articles : state to 9 in automsg and automsg_waiting
Automsg content plugin becomes a service provider
  • Loading branch information
conseilgouz committed Jun 5, 2024
1 parent d19b090 commit 789d2e4
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 61 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-04</creationDate>
<creationDate>2024-06-05</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.1.3</version>
<version>4.2.0</version>
<description>AutoMsg</description>
<scriptfile>script.install.php</scriptfile>
<files>
Expand Down
16 changes: 15 additions & 1 deletion packages/com_automsg/admin/language/en-GB/com_automsg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,18 @@ COM_AUTOMSG_REPORT_SUBJECT="AutoMsg report."
COM_AUTOMSG_REPORT_MSG="{ARTICLE} : {TOTAL} message(s) have been sent, {OK} message(s) without any error, {ERROR} message(s) with an error, {WAITING} waiting message(s)."
COM_AUTOMSG_RESTARTED="Retry sending messages done"
COM_AUTOMSG_RETRIED="Retry sending errors done"
COM_AUTOMSG_NOT_FOUND="Error : article %s does not exist anymore."
COM_AUTOMSG_NOT_FOUND="Error : article %s does not exist anymore."
COM_AUTOMSG_MESSAGES_BUTTON_SEND="Send"
COM_AUTOMSG_MESSAGES_BUTTON_SEE="See it"
COM_AUTOMSG_MESSAGES_BUTTON_RETRY="Retry"
COM_AUTOMSG_MESSAGES_CLICK="Click to send"
COM_AUTOMSG_MESSAGES_SENT="Sent"
COM_AUTOMSG_MESSAGES_ERRORS="Errors"
COM_AUTOMSG_MESSAGES_WAITING="Waiting"
COM_AUTOMSG_MESSAGES_ARTICLES="Article(s)"
COM_AUTOMSG_MESSAGES_WAITINGS="Waiting(s)"
COM_AUTOMSG_MESSAGES_TOTAL="Total"
COM_AUTOMSG_MESSAGES_OK="Ok"
COM_AUTOMSG_MESSAGES_DETAIL_ERRORS="<b>Errors list</b><br>(You may retry sending errors up to 3 times : select error with its checkbox and click on <b>Retry</b> button)"
COM_AUTOMSG_MESSAGES_DETAIL_WAITING="Waitings list"
COM_AUTOMSG_MESSAGES_CONTAINS_ERRORS="Contains error(s)"
16 changes: 15 additions & 1 deletion packages/com_automsg/admin/language/fr-FR/com_automsg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,18 @@ COM_AUTOMSG_REPORT_SUBJECT="Compte-rendu envoi mail automatique."
COM_AUTOMSG_REPORT_MSG="{ARTICLE} : {TOTAL} message(s) envoyé(s), {OK} message(s) sans erreur, {ERROR} message(s) avec erreur, {WAITING} message(s) en attente."
COM_AUTOMSG_RESTARTED="Relance des messages effectuée"
COM_AUTOMSG_RETRIED="Essai de relance des erreurs effectué"
COM_AUTOMSG_NOT_FOUND="Erreur : l'article %s a disparu."
COM_AUTOMSG_NOT_FOUND="Erreur : l'article %s a disparu."
COM_AUTOMSG_MESSAGES_BUTTON_SEND="Envoi"
COM_AUTOMSG_MESSAGES_BUTTON_SEE="Voir"
COM_AUTOMSG_MESSAGES_BUTTON_RETRY="Nouvel essai"
COM_AUTOMSG_MESSAGES_CLICK="Cliquer pour envoyer"
COM_AUTOMSG_MESSAGES_SENT="Envoyé"
COM_AUTOMSG_MESSAGES_ERRORS="Erreurs"
COM_AUTOMSG_MESSAGES_WAITING="En attente"
COM_AUTOMSG_MESSAGES_ARTICLES="Article(s)"
COM_AUTOMSG_MESSAGES_WAITINGS="En attente"
COM_AUTOMSG_MESSAGES_TOTAL="Total"
COM_AUTOMSG_MESSAGES_OK="Ok"
COM_AUTOMSG_MESSAGES_DETAIL_ERRORS="<b>Liste des erreurs</b><br>(Vous pouvez essayer de les renvoyer jusqu'à 3 fois : sélectionnez l'erreur en utilisant sa checkbox et cliquez sur le bouton <b>Nouvel essai</b>)"
COM_AUTOMSG_MESSAGES_DETAIL_WAITING="Liste des 'en attente"
COM_AUTOMSG_MESSAGES_CONTAINS_ERRORS="Contient des erreurs"
2 changes: 1 addition & 1 deletion packages/com_automsg/admin/src/View/Message/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function addToolbar()
}
ToolBarHelper::title( Text::_('CG_PX_MESSAGE_EDIT'), '#xs#.png');

ToolbarHelper::custom('message.retry','envelope-opened','','Nouvel essai',false);
ToolbarHelper::custom('message.retry','envelope-opened','', Text::_('COM_AUTOMSG_MESSAGES_BUTTON_RETRY'),false);

if (empty($this->message->id)) {
ToolBarHelper::cancel('message.cancel');
Expand Down
9 changes: 2 additions & 7 deletions packages/com_automsg/admin/src/View/Messages/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,13 @@ protected function addToolbar()
ToolbarHelper::title(Text::_('COM_AUTOMSG_MESSAGES'), 'automsg.png');

if (($canDo->get('core.edit')) || ($canDo->get('core.edit.own'))) {
ToolbarHelper::editList('message.edit', 'Voir');
ToolbarHelper::editList('message.edit', Text::_('COM_AUTOMSG_MESSAGES_BUTTON_SEE'));
}

if ($canDo->get('core.edit.state')) {
ToolbarHelper::divider();
ToolbarHelper::publish('messages.send', 'Envoyer', true);
ToolbarHelper::publish('messages.send', Text::_('COM_AUTOMSG_MESSAGES_BUTTON_SEND'), true);
}
/*if (isset($this->state) && $this->state->get('filter.state') == -2 && $canDo->get('core.delete')) {
ToolBarHelper::deleteList('', 'messages.delete', 'JTOOLBAR_EMPTY_TRASH');
} elseif ($canDo->get('core.edit.state')) {
ToolBarHelper::trash('messages.trash');
}*/
if ($canDo->get('core.admin')) {
ToolbarHelper::divider();
ToolbarHelper::inlinehelp();
Expand Down
30 changes: 15 additions & 15 deletions packages/com_automsg/admin/tmpl/message/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
9 => [
'', // restart
'',
'Erreurs', // état :
Text::_('COM_AUTOMSG_MESSAGES_ERRORS'), // état :
'',
true,
'error', // icone
Expand Down Expand Up @@ -85,25 +85,25 @@
<thead>
<tr>
<th class="70%">
Article(s)
<?php echo Text::_('COM_AUTOMSG_MESSAGES_ARTICLES');?>
</th>
<th class="5%">
Envoyé
<?php echo Text::_('COM_AUTOMSG_MESSAGES_SENT');?>
</th>
<th class="5%">
Total
<?php echo Text::_('COM_AUTOMSG_MESSAGES_TOTAL');?>
</th>
<th class="5%">
OK
<?php echo Text::_('COM_AUTOMSG_MESSAGES_OK');?>
</th>
<th class="5%">
Erreur(s)
<?php echo Text::_('COM_AUTOMSG_MESSAGES_ERRORS');?>
</th>
<th class="5%">
Attente
<?php echo Text::_('COM_AUTOMSG_MESSAGES_WAITINGS');?>
</th>
<th width="5%">
Status
<?php echo Text::_('JSTATUS');?>
</th>
</tr>
</thead>
Expand Down Expand Up @@ -164,7 +164,7 @@
if ($cr) {
if ($cr->error > 0) { // build error modal
$errors = $modelMessage->getMessageErrors($message->sent);
echo '<a data-bs-toggle="collapse" href="#errorCollapse" aria-expanded="true" title="Voir les erreurs">';
echo '<a data-bs-toggle="collapse" href="#errorCollapse" aria-expanded="true" title="'.Text::_("COM_AUTOMSG_MESSAGES_DETAIL_ERRORS").'">';
echo $cr->error;
echo '</a>';
}
Expand All @@ -176,7 +176,7 @@
if ($cr) {
if ($cr->waiting > 0) { // build error modal
$waitings = $modelMessage->getMessageWaiting($message->sent);
echo '<a data-bs-toggle="collapse" href="#waitingCollapse" aria-expanded="false" title="Voir en attente">';
echo '<a data-bs-toggle="collapse" href="#waitingCollapse" aria-expanded="false" title="'.Text::_("COM_AUTOMSG_MESSAGES_DETAIL_WAITINGS").'">';
echo $cr->waiting;
echo '</a>';
}
Expand All @@ -186,10 +186,10 @@
<td>
<?php
if ($message->state == 1) {
echo '<span class="icon-publish" aria-hidden="true" title="Envoyé"></span>';
echo '<span class="icon-publish" aria-hidden="true" title="'.Text::_('COM_AUTOMSG_MESSAGES_SENT').'"></span>';
}
if ($message->state == 9) {
echo '<span class="icon-error" aria-hidden="true" title="Contient des erreurs"></span>';
echo '<span class="icon-error" aria-hidden="true" title="'.Text::_('COM_AUTOMSG_MESSAGES_CONTAINS_ERRORS').'"></span>';
}
?>
</td>
Expand All @@ -207,7 +207,7 @@
}
?>
<div class="collapse <?php echo $show;?> " id="errorCollapse" tabindex="-1" aria-labelledby="errorCollapseLabel" aria-hidden="true">
<b>Détail des erreurs</b><br>(vous pouvez ré-essayer jusqu'à 3 fois de les renvoyer : sélectionner l'erreur en cochant sa case et cliquer sur le bouton <b>Nouvel essai</b>)
<?php echo Text::_('COM_AUTOMSG_MESSAGES_DETAIL_ERRORS');?>
<div class="card card-body">
<div class="row">
<?php
Expand All @@ -230,8 +230,8 @@
</div>
</div>
</div>
<div class="collapse" id="waitingCollapse" tabindex="-1" aria-labelledby="waitingCollapseLabel" aria-hidden="true">
Détail des 'en attente'
<div class="collapse" id="waitingCollapse" tabindex="-1" aria-labelledby="waitingCollapseLabel" aria-hidden="true" title="">
<?php echo Text::_('COM_AUTOMSG_MESSAGES_DETAIL_WAITING');?>
<div class="card card-body">
<div class="row">
<?php
Expand Down
26 changes: 13 additions & 13 deletions packages/com_automsg/admin/tmpl/messages/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
0 => [
'send', // action : publish => envoi
'',
'Cliquer pour envoyer',
Text::_('COM_AUTOMSG_MESSAGES_CLICK'),
'',
true,
'warning', // icone
Expand All @@ -43,7 +43,7 @@
1 => [
'detail', // ne rien faire
'',
'Envoyé', // état :
Text::_('COM_AUTOMSG_MESSAGES_SENT'), // state
'',
true,
'publish', // icone
Expand All @@ -52,17 +52,17 @@
9 => [
'detail', // restart
'',
'Erreurs', // état :
Text::_('COM_AUTOMSG_MESSAGES_ERRORS'), // état :
'',
true,
'error', // icone
'',
]
];
$options = [];
$options[] = HTMLHelper::_('select.option', '0', 'En attente');
$options[] = HTMLHelper::_('select.option', '1', 'Envoyés');
$options[] = HTMLHelper::_('select.option', '9', 'En erreur');
$options[] = HTMLHelper::_('select.option', '0', Text::_('COM_AUTOMSG_MESSAGES_WAITING'));
$options[] = HTMLHelper::_('select.option', '1', Text::_('COM_AUTOMSG_MESSAGES_SENT'));
$options[] = HTMLHelper::_('select.option', '9', Text::_('COM_AUTOMSG_MESSAGES_ERRORS'));

$ordering = ($listOrder == 'ordering');
$canCreate = $user->authorise('core.create');
Expand Down Expand Up @@ -102,22 +102,22 @@
<input type="checkbox" name="checkall-toggle" value="" title="<?php echo Text::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />
</th>
<th class="90%">
<?php echo HtmlHelper::_('grid.sort', 'Article(s)', 'articles', $listDirn, $listOrder); ?>
<?php echo HtmlHelper::_('grid.sort', Text::_('COM_AUTOMSG_MESSAGES_ARTICLES'), 'articles', $listDirn, $listOrder); ?>
</th>
<th class="5%">
<?php echo HtmlHelper::_('grid.sort', 'Envoyé', 'sent', $listDirn, $listOrder); ?>
<?php echo HtmlHelper::_('grid.sort', Text::_('COM_AUTOMSG_MESSAGES_SENT'), 'sent', $listDirn, $listOrder); ?>
</th>
<th class="5%">
Total
<?php echo Text::_('COM_AUTOMSG_MESSAGES_TOTAL');?>
</th>
<th class="5%">
OK
<?php echo Text::_('COM_AUTOMSG_MESSAGES_OK');?>
</th>
<th class="5%">
Erreur(s)
<?php echo Text::_('COM_AUTOMSG_MESSAGES_ERRORS');?>
</th>
<th class="5%">
Attente
<?php echo Text::_('COM_AUTOMSG_MESSAGES_WAITINGS');?>
</th>
<th width="5%">
<?php echo HtmlHelper::_('grid.sort', 'JSTATUS', 'sent', $listDirn, $listOrder); ?>
Expand Down Expand Up @@ -164,7 +164,7 @@
<?php
$sent = $message->sent;
if (!$sent) {
$sent = "en attente";
$sent = Text::_('COM_AUTOMSG_MESSAGES_WAITING');
}
echo $this->escape($sent)
?>
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-04</creationDate>
<creationDate>2024-06-05</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.1.3</version>
<version>4.2.0</version>
<description>COM_AUTOMSG_XML_DESCRIPTION</description>
<namespace path="src">ConseilGouz\Component\Automsg</namespace>
<files folder="site">
Expand Down
37 changes: 30 additions & 7 deletions packages/library_automsg/Helper/Automsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,25 @@ public static function store_automsg($article, $state = 0, $timestamp = null, $c
$autoparams = self::getParams();

$db = Factory::getContainer()->get(DatabaseInterface::class);
$query = $db->getQuery(true);
if ($state == 9) { // lost article => set remaining ones to state 9 : error
$query->select('id')
->from($db->qn('#__automsg'))
->where($db->qn('article_id') . ' = '.$article->id)
->where($db->qn('state') .'= 0');
$db->setQuery($query);
$losts = $db->loadColumn();
if (!sizeOf($losts)) { // strange, nothing found
return;
}
$query = $db->getQuery(true)
->update($db->qn('#__automsg'))
->set($db->qn('state').'= 9')
->where($db->qn('id').' in ('.implode(',', $losts).')');
$db->setQuery($query);
$db->execute();
return;
}
$date = Factory::getDate();

$query = $db->getQuery(true)
Expand Down Expand Up @@ -536,12 +555,12 @@ public static function updateAutoMsgTable($articleid = null, $state = 0, $timest
//
// Async : update waiting articles to sent
//
public static function updateAutoMsgWaitingTable($ids = [])
public static function updateAutoMsgWaitingTable($ids = [], $state = 1)
{
$db = Factory::getContainer()->get(DatabaseInterface::class);
$query = $db->getQuery(true)
->update($db->qn('#__automsg_waiting'))
->set($db->qn('state').'= 1')
->set($db->qn('state').'='.$state)
->whereIn($db->qn('id'), $ids);
$db->setQuery($query);
$db->execute();
Expand All @@ -560,9 +579,12 @@ public static function updateAutoMsgCr($timestamp, $cr = [])
$query->setLimit(1); // all articles from one session have same timestamp
$db->setQuery($query);
$oldcr = $db->loadResult();
if (!$oldcr) {
if (!$oldcr) { // should not exist, but do it just in case
return;
} // should not exist, but do it just in case
}
if (!sizeOf($oldcr)) { // we are on an error : ignore it
return;
}
$oldcr = json_decode($oldcr);
if (!$cr['error']) {
$oldcr->sent += $cr['sent'];
Expand Down Expand Up @@ -794,7 +816,7 @@ public static function task_next_exec()
->where($db->qn('id') . ' = 1');
$db->setQuery($query);
$db->execute();
// compute automsg params to use in the task
// compute automsg params to use in the task
$execution_rules = ["rule-type" => "interval-hours",
"interval-hours" => $autoparams->maildelay,
"exec-day" => "1",
Expand Down Expand Up @@ -848,8 +870,9 @@ public static function task_restore_exec()
$db->setQuery($query);
$db->execute();
}
// Lost article
public static function lost_article($articleid,$timestamp) {
// Lost article
public static function lost_article($articleid, $timestamp)
{
$autoparams = self::getParams();
self::store_automsg_error(0, [$articleid], sprintf(Text::_('COM_AUTOMSG_NOT_FOUND'), $articleid), 9, $timestamp);
$article = new \StdClass();
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 @@ -3,8 +3,8 @@
<name>Automsg Library</name>
<libraryname>automsg</libraryname>
<author>ConseilGouz</author>
<version>4.1.3</version>
<creationDate>2024-06-04</creationDate>
<version>4.2.0</version>
<creationDate>2024-06-05</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-04</creationDate>
<creationDate>2024-06-05</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.1.3</version>
<version>4.2.0</version>
<description>PLG_CONTENT_AUTOMSG_XML_DESCRIPTION</description>
<files>
<folder plugin="automsg">services</folder>
Expand Down
Loading

0 comments on commit 789d2e4

Please sign in to comment.