Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | 73e0c357e9 | |
Jean-Christian Paul Denis | 2377fdec76 | |
Jean-Christian Paul Denis | d15b51809d | |
Jean-Christian Paul Denis | 5097cc7736 | |
Jean-Christian Paul Denis | 9258788db5 |
25
CHANGELOG.md
25
CHANGELOG.md
|
@ -1,3 +1,28 @@
|
|||
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
|
||||
* Require PHP 8.1
|
||||
* Fix namespace
|
||||
|
||||
mail2log 0.7 - 2023.10.13
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Code review
|
||||
|
||||
mail2log 0.6 - 2023.10.07
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
mail2log 0.5 - 2023.08.13
|
||||
===========================================================
|
||||
* Require Dotclear 2.24
|
||||
|
|
31
README.md
31
README.md
|
@ -1,25 +1,21 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-0.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/mail2log/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/mail2log/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![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/github/license/JcDenis/mail2log)](https://git.dotclear.watch/JcDenis/mail2log/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/mail2log/src/branch/master/LICENSE)
|
||||
|
||||
## WHAT IS MAIL2LOG ?
|
||||
## ABOUT
|
||||
|
||||
_mail2log_ is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
_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
|
||||
|
||||
_mail2log_ requires:
|
||||
|
||||
* Dotclear 2.24
|
||||
* PHP 7.4
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* A plugin to read log. (dcLog)
|
||||
|
||||
## USAGE
|
||||
|
@ -32,12 +28,13 @@ Use it for dev only.
|
|||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/mail2log) or [GitHub Page](https://github.com/JcDenis/mail2log)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/mail2log/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/mail2log)
|
||||
* [License](https://git.dotclear.watch/JcDenis/mail2log/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/mail2log/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/mail2log))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/mail2log) (or on [GitHub](https://github.com/JcDenis/mail2log))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/mail2log/issues) (or on [GitHub](https://github.com/JcDenis/mail2log/issues))
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (author)
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
|
48
_define.php
48
_define.php
|
@ -1,46 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief mail2log, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin mail2log definition
|
||||
* @ingroup mail2log
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup mail2log Plugin mail2log.
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
* Do not send mails but log them.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->registerModule(
|
||||
'Mail to log',
|
||||
'Do not send mails but log them',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'0.5',
|
||||
'0.8',
|
||||
[
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
]),
|
||||
'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',
|
||||
'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 = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcLog::LOG_TABLE_NAME);
|
||||
$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));
|
||||
dcCore::app()->log->addLog($cur);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="mail2log">
|
||||
<name>Mail to log</name>
|
||||
<version>0.5</version>
|
||||
<version>0.8</version>
|
||||
<author>Jean-Christian Denis and contributors</author>
|
||||
<desc>Do not send mails but log them</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/mail2log/releases/download/v0.5/plugin-mail2log.zip</file>
|
||||
<da:dcmin>2.24</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/mail2log/releases/download/v0.8/plugin-mail2log.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<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>
|
||||
</module>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\mail2log;
|
||||
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief mail2log My helper.
|
||||
* @ingroup mail2log
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
// use default permissions
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 New Issue