Compare commits

..

No commits in common. "master" and "v0.5" have entirely different histories.
master ... v0.5

8 changed files with 52 additions and 204 deletions

View File

@ -1,28 +1,3 @@
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 mail2log 0.5 - 2023.08.13
=========================================================== ===========================================================
* Require Dotclear 2.24 * Require Dotclear 2.24

View File

@ -1,21 +1,25 @@
# README # README
[![Release](https://img.shields.io/badge/release-0.8-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/mail2log/releases) [![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.10.23-c44d58.svg) [![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.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-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/github/license/JcDenis/mail2log)](https://git.dotclear.watch/JcDenis/mail2log/blob/master/LICENSE)
## ABOUT ## WHAT IS MAIL2LOG ?
_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.
> Replace mail function and send them to Dotclear's log database table. It replaces mail function
and send them to Dotclear's log database table.
## REQUIREMENTS ## REQUIREMENTS
* Dotclear 2.28 _mail2log_ requires:
* PHP 8.1+
* Dotclear 2.24
* PHP 7.4
* A plugin to read log. (dcLog) * A plugin to read log. (dcLog)
## USAGE ## USAGE
@ -28,13 +32,12 @@ Use it for dev only.
## LINKS ## LINKS
* [License](https://git.dotclear.watch/JcDenis/mail2log/src/branch/master/LICENSE) * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* [Packages & details](https://git.dotclear.watch/JcDenis/mail2log/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/mail2log)) * Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/mail2log) or [GitHub Page](https://github.com/JcDenis/mail2log)
* [Sources & contributions](https://git.dotclear.watch/JcDenis/mail2log) (or on [GitHub](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)
* [Issues & security](https://git.dotclear.watch/JcDenis/mail2log/issues) (or on [GitHub](https://github.com/JcDenis/mail2log/issues))
## CONTRIBUTORS ## CONTRIBUTORS
* Jean-Christian Denis (author) * Jean-Christian Denis
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

@ -1,30 +1,46 @@
<?php <?php
/** /**
* @file * @brief mail2log, a plugin for Dotclear 2
* @brief The plugin mail2log definition
* @ingroup mail2log
* *
* @defgroup mail2log Plugin mail2log. * @package Dotclear
* @subpackage Plugin
* *
* Do not send mails but log them. * @author Jean-Christian Denis and contributors
* *
* @author Jean-Christian Denis (author) * @copyright Jean-Christian Denis
* @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
*/ */
declare(strict_types=1); if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule( $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.8', '0.5',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.24']],
'permissions' => 'My', 'permissions' => dcCore::app()->auth->makePermissions([
'priority' => 10, dcCore::app()->auth::PERMISSION_USAGE,
'type' => 'plugin', ]),
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'type' => 'plugin',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', '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;
}
}

View File

@ -2,11 +2,11 @@
<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.8</version> <version>0.5</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.8/plugin-mail2log.zip</file> <file>https://git.dotclear.watch/JcDenis/mail2log/releases/download/v0.5/plugin-mail2log.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.24</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>
</module> </module>

View File

@ -1,19 +0,0 @@
<?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
}

View File

@ -1,32 +0,0 @@
<?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();
}
}

View File

@ -1,66 +0,0 @@
<?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;
}
}

View File

@ -1,29 +0,0 @@
<?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;
}
}