From 73e0c357e9893105245f7b1e518edaf023afd2ab Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 23 Oct 2023 10:15:46 +0200 Subject: [PATCH] clean up define --- CHANGELOG.md | 7 +++++ README.md | 8 +++--- _define.php | 17 ++---------- dcstore.xml | 4 +-- src/My.php | 4 +-- src/Prepend.php | 32 +++++++++++++++++++++++ src/Uninstall.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++ src/_mail.php | 29 +++++++++++++++++++++ 8 files changed, 144 insertions(+), 23 deletions(-) create mode 100644 src/Prepend.php create mode 100644 src/Uninstall.php create mode 100644 src/_mail.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 213872a..9883e2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +mail2log 0.8 - 2023.10.23 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Move mail function to keep clean the define +* Add plugin Uninstaller features + mail2log 0.7.1 - 2023.10.19 =========================================================== * Require Dotclear 2.28 diff --git a/README.md b/README.md index 518b97c..eacf443 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # README -[![Release](https://img.shields.io/badge/release-0.7.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/mail2log/releases) -![Date](https://img.shields.io/badge/date-2023.10.19-c44d58.svg) +[![Release](https://img.shields.io/badge/release-0.8-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/mail2log/releases) +![Date](https://img.shields.io/badge/date-2023.10.23-c44d58.svg) [![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/mail2log) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/mail2log/src/branch/master/LICENSE) @@ -10,7 +10,7 @@ _mail2log_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -> It replaces mail function and send them to Dotclear's log database table. +> Replace mail function and send them to Dotclear's log database table. ## REQUIREMENTS @@ -35,6 +35,6 @@ Use it for dev only. ## CONTRIBUTORS -* Jean-Christian Denis +* Jean-Christian Denis (author) You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index 9e1e35e..b663057 100644 --- a/_define.php +++ b/_define.php @@ -17,27 +17,14 @@ $this->registerModule( 'Mail to log', 'Do not send mails but log them', 'Jean-Christian Denis and contributors', - '0.7.1', + '0.8', [ 'requires' => [['core', '2.28']], 'permissions' => 'My', + 'priority' => 10, 'type' => 'plugin', 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', ] ); - -if (!function_exists('\_mail')) { - function _mail(string $to, string $subject, string $message, $headers = '', ?string $params = null): bool - { - $headers = is_array($headers) ? implode("\n\t", $headers) : (is_string($headers) ? $headers : ''); - - $cur = Dotclear\App::log()->openLogCursor(); - $cur->setField('log_table', basename(__DIR__)); - $cur->setField('log_msg', sprintf("%s\n-----\n To: %s\n Subject: %s\n-----\n Message:\n%s\n", $headers, $to, $subject, $message)); - Dotclear\App::log()->addLog($cur); - - return true; - } -} diff --git a/dcstore.xml b/dcstore.xml index 39c1625..7abc083 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ Mail to log - 0.7.1 + 0.8 Jean-Christian Denis and contributors Do not send mails but log them - https://git.dotclear.watch/JcDenis/mail2log/releases/download/v0.7.1/plugin-mail2log.zip + https://git.dotclear.watch/JcDenis/mail2log/releases/download/v0.8/plugin-mail2log.zip 2.28 https://git.dotclear.watch/JcDenis/mail2log/src/branch/master/README.md https://git.dotclear.watch/JcDenis/mail2log/issues diff --git a/src/My.php b/src/My.php index bc5d68e..918bab0 100644 --- a/src/My.php +++ b/src/My.php @@ -7,8 +7,8 @@ namespace Dotclear\Plugin\mail2log; use Dotclear\Module\MyPlugin; /** - * @brief mail2log My helper. - * @ingroup mail2log + * @brief mail2log My helper. + * @ingroup mail2log * * @author Jean-Christian Denis (author) * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/src/Prepend.php b/src/Prepend.php new file mode 100644 index 0000000..221fa2e --- /dev/null +++ b/src/Prepend.php @@ -0,0 +1,32 @@ +addUserAction( + 'logs', + 'delete_all', + 'mail2log' + ) + ->addUserAction( + 'plugins', + 'delete', + My::id() + ) + ->addUserAction( + 'versions', + 'delete', + My::id() + ) + ->addDirectAction( + 'logs', + 'delete_all', + 'mail2log' + ) + ->addDirectAction( + 'plugins', + 'delete', + My::id() + ) + ->addDirectAction( + 'versions', + 'delete', + My::id() + ) + ; + + // no custom action + return false; + } +} diff --git a/src/_mail.php b/src/_mail.php new file mode 100644 index 0000000..a37cbb4 --- /dev/null +++ b/src/_mail.php @@ -0,0 +1,29 @@ +openLogCursor(); + $cur->setField('log_table', 'mail2log'); + $cur->setField('log_msg', sprintf( + "%s\n-----\n To: %s\n Subject: %s\n-----\n Message:\n%s\n", + is_array($headers) ? implode("\n\t", $headers) : (is_string($headers) ? $headers : ''), + $to, + $subject, + $message + )); + App::log()->addLog($cur); + + return true; + } +}