upgrade to Dotclear 2.28
This commit is contained in:
parent
97a50c02b8
commit
1741e80aed
@ -1,3 +1,9 @@
|
||||
emailNotification 1.7 - 2023.10.16
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
emailNotification 1.6 - 2023.08.12
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
30
README.md
30
README.md
@ -1,24 +1,21 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-1.6-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/emailNotification/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/emailNotification/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-1.7-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/emailNotification/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.16-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/emailNotification)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/emailNotification)](https://git.dotclear.watch/JcDenis/emailNotification/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/emailNotification/src/branch/master/LICENSE)
|
||||
|
||||
## WHAT IS EMAILNOTIFICATION ?
|
||||
## ABOUT
|
||||
|
||||
_Email notification_ is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
_emailNotification_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
It sends email when a new comment is done.
|
||||
> Send email when a new comment is done.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_Email notification_ requires:
|
||||
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* A working mail service
|
||||
|
||||
## USAGE
|
||||
@ -30,13 +27,14 @@ Go to ''user preferences'' => fieldset ''others options'', fill in form.
|
||||
|
||||
## 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/emailNotification) or [GitHub Page](https://github.com/JcDenis/emailNotification)
|
||||
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/emailNotification/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/emailNotification)
|
||||
* [License](https://git.dotclear.watch/JcDenis/emailNotification/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/emailNotification/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/emailNotification))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/emailNotification) (or on [GitHub](https://github.com/JcDenis/emailNotification))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/emailNotification/issues) (or on [GitHub](https://github.com/JcDenis/emailNotification/issues))
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Olivier Meunier (author)
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (latest)
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
35
_define.php
35
_define.php
@ -1,33 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief emailNotification, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin emailNotification definition
|
||||
* @ingroup emailNotification
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup emailNotification Plugin emailNotification.
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
* Email notification.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Olivier Meunier (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @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(
|
||||
'Email notification',
|
||||
'Email notification',
|
||||
'Olivier Meunier and contributors',
|
||||
'1.6',
|
||||
'1.7',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'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',
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="emailNotification">
|
||||
<name>Email notification</name>
|
||||
<version>1.6</version>
|
||||
<version>1.7</version>
|
||||
<author>Olivier Meunier and contributors</author>
|
||||
<desc>Email notification</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/emailNotification/releases/download/v1.6/plugin-emailNotification.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/emailNotification/releases/download/v1.7/plugin-emailNotification.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/emailNotification/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/emailNotification/issues</da:support>
|
||||
</module>
|
||||
|
@ -1,22 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief emailNotification, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\emailNotification;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief emailNotification backend class.
|
||||
* @ingroup emailNotification
|
||||
*
|
||||
* @author Olivier Meunier (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -30,11 +28,11 @@ class Backend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminPreferencesFormV2' => [BackendBehaviors::class, 'adminUserForm'],
|
||||
'adminUserForm' => [BackendBehaviors::class, 'adminUserForm'],
|
||||
'adminBeforeUserUpdate' => [BackendBehaviors::class, 'adminBeforeUserUpdate'],
|
||||
'adminBeforeUserOptionsUpdate' => [BackendBehaviors::class, 'adminBeforeUserUpdate'],
|
||||
App::behavior()->addBehaviors([
|
||||
'adminPreferencesFormV2' => BackendBehaviors::adminUserForm(...),
|
||||
'adminUserForm' => BackendBehaviors::adminUserForm(...),
|
||||
'adminBeforeUserUpdate' => BackendBehaviors::adminBeforeUserUpdate(...),
|
||||
'adminBeforeUserOptionsUpdate' => BackendBehaviors::adminBeforeUserUpdate(...),
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
@ -1,20 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief emailNotification, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\emailNotification;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\Cursor;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Label,
|
||||
@ -22,11 +12,19 @@ use Dotclear\Helper\Html\Form\{
|
||||
Select
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief emailNotification backend behaviors.
|
||||
* @ingroup emailNotification
|
||||
*
|
||||
* @author Olivier Meunier (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class BackendBehaviors
|
||||
{
|
||||
public static function adminUserForm(): void
|
||||
{
|
||||
$options = dcCore::app()->auth->getOptions();
|
||||
$options = App::auth()->getOptions();
|
||||
|
||||
echo
|
||||
'<div class="fieldset"><h5>' . __('Email notification') . '</h5>' .
|
||||
|
@ -1,22 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief emailNotification, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\emailNotification;
|
||||
|
||||
use dcAuth;
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
@ -28,8 +16,16 @@ use Dotclear\Database\Statement\{
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Network\Mail\Mail;
|
||||
use rsExtUser;
|
||||
use Dotclear\Schema\Extension\User;
|
||||
|
||||
/**
|
||||
* @brief emailNotification frontend class.
|
||||
* @ingroup emailNotification
|
||||
*
|
||||
* @author Olivier Meunier (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -43,25 +39,24 @@ class Frontend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('publicAfterCommentCreate', function (Cursor $cur, ?int $comment_id): void {
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
App::behavior()->addBehavior('publicAfterCommentCreate', function (Cursor $cur, ?int $comment_id): void {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't want notification for spam
|
||||
if ((int) $cur->getField('comment_status') == dcBlog::COMMENT_JUNK) {
|
||||
if ((int) $cur->getField('comment_status') == App::blog()::COMMENT_JUNK) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Information on comment author and post author
|
||||
$rs = dcCore::app()->auth->sudo([dcCore::app()->blog, 'getComments'], ['comment_id' => $comment_id]);
|
||||
$rs = App::auth()->sudo(App::blog()->getComments(...), ['comment_id' => $comment_id]);
|
||||
if (is_null($rs) || $rs->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$users = $sql->from($sql->as(dcCore::app()->blog->prefix . dcAuth::USER_TABLE_NAME, 'U'))
|
||||
$users = $sql->from($sql->as(App::con()->prefix() . App::auth()::USER_TABLE_NAME, 'U'))
|
||||
->columns([
|
||||
'U.user_id as user_id',
|
||||
'user_email',
|
||||
@ -69,11 +64,11 @@ class Frontend extends Process
|
||||
])
|
||||
->join(
|
||||
(new JoinStatement())
|
||||
->from($sql->as(dcCore::app()->blog->prefix . dcAuth::PERMISSIONS_TABLE_NAME, 'P'))
|
||||
->from($sql->as(App::con()->prefix() . App::auth()::PERMISSIONS_TABLE_NAME, 'P'))
|
||||
->on('U.user_id = P.user_id')
|
||||
->statement()
|
||||
)
|
||||
->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->union(
|
||||
(new SelectStatement())
|
||||
->columns([
|
||||
@ -81,7 +76,7 @@ class Frontend extends Process
|
||||
'user_email',
|
||||
'user_options',
|
||||
])
|
||||
->from($sql->as(dcCore::app()->blog->prefix . dcAuth::USER_TABLE_NAME, 'U'))
|
||||
->from($sql->as(App::con()->prefix() . App::auth()::USER_TABLE_NAME, 'U'))
|
||||
->where('user_super = 1')
|
||||
->statement()
|
||||
)
|
||||
@ -98,7 +93,7 @@ class Frontend extends Process
|
||||
continue;
|
||||
}
|
||||
|
||||
$o = rsExtUser::options($users);
|
||||
$o = User::options($users);
|
||||
$notification_pref = is_array($o) && isset($o['notify_comments']) ? $o['notify_comments'] : null;
|
||||
unset($o);
|
||||
|
||||
@ -114,23 +109,23 @@ class Frontend extends Process
|
||||
'Reply-To: ' . $rs->f('comment_email'),
|
||||
'Content-Type: text/plain; charset=UTF-8;',
|
||||
'X-Mailer: Dotclear',
|
||||
'X-Blog-Id: ' . Mail::B64Header(dcCore::app()->blog->id),
|
||||
'X-Blog-Name: ' . Mail::B64Header(dcCore::app()->blog->name),
|
||||
'X-Blog-Url: ' . Mail::B64Header(dcCore::app()->blog->url),
|
||||
'X-Blog-Id: ' . Mail::B64Header(App::blog()->id()),
|
||||
'X-Blog-Name: ' . Mail::B64Header(App::blog()->name()),
|
||||
'X-Blog-Url: ' . Mail::B64Header(App::blog()->url()),
|
||||
];
|
||||
|
||||
$subject = '[' . dcCore::app()->blog->name . '] ' . sprintf(__('"%s" - New comment'), $rs->f('post_title'));
|
||||
$subject = '[' . App::blog()->name() . '] ' . sprintf(__('"%s" - New comment'), $rs->f('post_title'));
|
||||
$subject = Mail::B64Header($subject);
|
||||
|
||||
$msg = preg_replace('%</p>\s*<p>%msu', "\n\n", $rs->f('comment_content'));
|
||||
$msg = Html::clean($msg);
|
||||
$msg = html_entity_decode($msg);
|
||||
|
||||
if ((int) $cur->getField('comment_status') == dcBlog::COMMENT_PUBLISHED) {
|
||||
if ((int) $cur->getField('comment_status') == App::blog()::COMMENT_PUBLISHED) {
|
||||
$status = __('published');
|
||||
} elseif ((int) $cur->getField('comment_status') == dcBlog::COMMENT_UNPUBLISHED) {
|
||||
} elseif ((int) $cur->getField('comment_status') == App::blog()::COMMENT_UNPUBLISHED) {
|
||||
$status = __('unpublished');
|
||||
} elseif ((int) $cur->getField('comment_status') == dcBlog::COMMENT_PENDING) {
|
||||
} elseif ((int) $cur->getField('comment_status') == App::blog()::COMMENT_PENDING) {
|
||||
$status = __('pending');
|
||||
} else {
|
||||
// unknown status
|
||||
@ -138,21 +133,21 @@ class Frontend extends Process
|
||||
}
|
||||
|
||||
$msg .= "\n\n-- \n" .
|
||||
sprintf(__('Blog: %s'), dcCore::app()->blog->name) . "\n" .
|
||||
sprintf(__('Blog: %s'), App::blog()->name()) . "\n" .
|
||||
sprintf(__('Entry: %s <%s>'), $rs->f('post_title'), $rs->getPostURL()) . "\n" .
|
||||
sprintf(__('Comment by: %s <%s>'), $rs->f('comment_author'), $rs->f('comment_email')) . "\n" .
|
||||
sprintf(__('Website: %s'), $rs->getAuthorURL()) . "\n" .
|
||||
sprintf(__('Comment status: %s'), $status) . "\n" .
|
||||
sprintf(__('Edit this comment: <%s>'), DC_ADMIN_URL .
|
||||
((substr(DC_ADMIN_URL, -1) != '/') ? '/' : '') .
|
||||
sprintf(__('Edit this comment: <%s>'), App::config()->adminUrl() .
|
||||
((substr(App::config()->adminUrl(), -1) != '/') ? '/' : '') .
|
||||
'comment.php?id=' . $cur->getField('comment_id') .
|
||||
'&switchblog=' . dcCore::app()->blog->id) . "\n" .
|
||||
'&switchblog=' . App::blog()->id()) . "\n" .
|
||||
__('You must log in on the backend before clicking on this link to go directly to the comment.');
|
||||
|
||||
$msg = __('You received a new comment on your blog:') . "\n\n" . $msg;
|
||||
|
||||
// --BEHAVIOR-- emailNotificationAppendToEmail -- Cursor
|
||||
$msg .= dcCore::app()->callBehavior('emailNotificationAppendToEmail', $cur);
|
||||
$msg .= App::behavior()->callBehavior('emailNotificationAppendToEmail', $cur);
|
||||
|
||||
foreach ($ulist as $email) {
|
||||
$h = array_merge(['From: ' . $email], $headers);
|
||||
|
21
src/My.php
21
src/My.php
@ -1,21 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief emailNotification, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\emailNotification;
|
||||
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief emailNotification My helper.
|
||||
* @ingroup emailNotification
|
||||
*
|
||||
* @author Olivier Meunier (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
// Use default permissions
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user