clean up define
This commit is contained in:
parent
2377fdec76
commit
73e0c357e9
8 changed files with 144 additions and 23 deletions
|
@ -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
|
mail2log 0.7.1 - 2023.10.19
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.28
|
* Require Dotclear 2.28
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-0.7.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/mail2log/releases)
|
[![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.19-c44d58.svg)
|
![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)
|
[![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)
|
[![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)
|
[![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).
|
_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
|
## REQUIREMENTS
|
||||||
|
|
||||||
|
@ -35,6 +35,6 @@ Use it for dev only.
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Jean-Christian Denis
|
* Jean-Christian Denis (author)
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
||||||
|
|
17
_define.php
17
_define.php
|
@ -17,27 +17,14 @@ $this->registerModule(
|
||||||
'Mail to log',
|
'Mail to log',
|
||||||
'Do not send mails but log them',
|
'Do not send mails but log them',
|
||||||
'Jean-Christian Denis and contributors',
|
'Jean-Christian Denis and contributors',
|
||||||
'0.7.1',
|
'0.8',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.28']],
|
'requires' => [['core', '2.28']],
|
||||||
'permissions' => 'My',
|
'permissions' => 'My',
|
||||||
|
'priority' => 10,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
'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',
|
'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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="mail2log">
|
<module id="mail2log">
|
||||||
<name>Mail to log</name>
|
<name>Mail to log</name>
|
||||||
<version>0.7.1</version>
|
<version>0.8</version>
|
||||||
<author>Jean-Christian Denis and contributors</author>
|
<author>Jean-Christian Denis and contributors</author>
|
||||||
<desc>Do not send mails but log them</desc>
|
<desc>Do not send mails but log them</desc>
|
||||||
<file>https://git.dotclear.watch/JcDenis/mail2log/releases/download/v0.7.1/plugin-mail2log.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/mail2log/releases/download/v0.8/plugin-mail2log.zip</file>
|
||||||
<da:dcmin>2.28</da:dcmin>
|
<da:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/mail2log/src/branch/master/README.md</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/mail2log/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/JcDenis/mail2log/issues</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/mail2log/issues</da:support>
|
||||||
|
|
|
@ -7,8 +7,8 @@ namespace Dotclear\Plugin\mail2log;
|
||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief mail2log My helper.
|
* @brief mail2log My helper.
|
||||||
* @ingroup mail2log
|
* @ingroup mail2log
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis (author)
|
* @author Jean-Christian Denis (author)
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
32
src/Prepend.php
Normal file
32
src/Prepend.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Dotclear\Plugin\mail2log;
|
||||||
|
|
||||||
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief mail2log prepend class.
|
||||||
|
* @ingroup mail2log
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis (author)
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
class Prepend extends Process
|
||||||
|
{
|
||||||
|
public static function init(): bool
|
||||||
|
{
|
||||||
|
return self::status(My::checkContext(My::BACKEND));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function process(): bool
|
||||||
|
{
|
||||||
|
if (self::status()) {
|
||||||
|
// function must be out of namespace
|
||||||
|
require_once __DIR__ . '/_mail.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::status();
|
||||||
|
}
|
||||||
|
}
|
66
src/Uninstall.php
Normal file
66
src/Uninstall.php
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Dotclear\Plugin\mail2log;
|
||||||
|
|
||||||
|
use Dotclear\Core\Process;
|
||||||
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief mail2log uninstall class.
|
||||||
|
* @ingroup mail2log
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis (author)
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
class Uninstall extends Process
|
||||||
|
{
|
||||||
|
public static function init(): bool
|
||||||
|
{
|
||||||
|
return self::status(My::checkContext(My::UNINSTALL));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function process(): bool
|
||||||
|
{
|
||||||
|
if (!self::status()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Uninstaller::instance()
|
||||||
|
->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;
|
||||||
|
}
|
||||||
|
}
|
29
src/_mail.php
Normal file
29
src/_mail.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief The plugin mail2log _mail function
|
||||||
|
* @ingroup mail2log
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis (author)
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Dotclear\App;
|
||||||
|
|
||||||
|
if (!function_exists('\_mail')) {
|
||||||
|
function _mail(string $to, string $subject, string $message, $headers = '', ?string $params = null): bool
|
||||||
|
{
|
||||||
|
$cur = App::log()->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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue