use latest database namespace
This commit is contained in:
parent
e94e9991bc
commit
6b564c1464
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\emailNotification;
|
namespace Dotclear\Plugin\emailNotification;
|
||||||
|
|
||||||
use cursor;
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
use Dotclear\Database\Cursor;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Label,
|
Label,
|
||||||
Para,
|
Para,
|
||||||
@ -46,7 +46,7 @@ class BackendBehaviors
|
|||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function adminBeforeUserUpdate(cursor $cur, string $user_id = ''): void
|
public static function adminBeforeUserUpdate(Cursor $cur, string $user_id = ''): void
|
||||||
{
|
{
|
||||||
$opt = $cur->getField('user_options');
|
$opt = $cur->getField('user_options');
|
||||||
$opt = is_null($opt) ? [] : $opt;
|
$opt = is_null($opt) ? [] : $opt;
|
||||||
|
@ -14,12 +14,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\emailNotification;
|
namespace Dotclear\Plugin\emailNotification;
|
||||||
|
|
||||||
use cursor;
|
|
||||||
use dcAuth;
|
use dcAuth;
|
||||||
use dcBlog;
|
use dcBlog;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use dcNsProcess;
|
||||||
use dcRecord;
|
use Dotclear\Database\{
|
||||||
|
Cursor,
|
||||||
|
MetaRecord
|
||||||
|
};
|
||||||
use Dotclear\Database\Statement\{
|
use Dotclear\Database\Statement\{
|
||||||
JoinStatement,
|
JoinStatement,
|
||||||
SelectStatement
|
SelectStatement
|
||||||
@ -43,18 +45,18 @@ class Frontend extends dcNsProcess
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehavior('publicAfterCommentCreate', function (cursor $cur, ?int $comment_id): void {
|
dcCore::app()->addBehavior('publicAfterCommentCreate', function (Cursor $cur, ?int $comment_id): void {
|
||||||
// nullsafe PHP < 8.0
|
// nullsafe PHP < 8.0
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# We don't want notification for spam
|
// We don't want notification for spam
|
||||||
if ((int) $cur->getField('comment_status') == dcBlog::COMMENT_JUNK) {
|
if ((int) $cur->getField('comment_status') == dcBlog::COMMENT_JUNK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Information on comment author and post author
|
// Information on comment author and post author
|
||||||
$rs = dcCore::app()->auth->sudo([dcCore::app()->blog, 'getComments'], ['comment_id' => $comment_id]);
|
$rs = dcCore::app()->auth->sudo([dcCore::app()->blog, 'getComments'], ['comment_id' => $comment_id]);
|
||||||
if (is_null($rs) || $rs->isEmpty()) {
|
if (is_null($rs) || $rs->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -91,7 +93,7 @@ class Frontend extends dcNsProcess
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create notify list
|
// Create notify list
|
||||||
$ulist = [];
|
$ulist = [];
|
||||||
while ($users->fetch()) {
|
while ($users->fetch()) {
|
||||||
if (!$users->f('user_email')) {
|
if (!$users->f('user_email')) {
|
||||||
@ -109,7 +111,7 @@ class Frontend extends dcNsProcess
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count($ulist) > 0) {
|
if (count($ulist) > 0) {
|
||||||
# Author of the post wants to be notified by mail
|
// Author of the post wants to be notified by mail
|
||||||
$headers = [
|
$headers = [
|
||||||
'Reply-To: ' . $rs->f('comment_email'),
|
'Reply-To: ' . $rs->f('comment_email'),
|
||||||
'Content-Type: text/plain; charset=UTF-8;',
|
'Content-Type: text/plain; charset=UTF-8;',
|
||||||
@ -133,7 +135,7 @@ class Frontend extends dcNsProcess
|
|||||||
} elseif ((int) $cur->getField('comment_status') == dcBlog::COMMENT_PENDING) {
|
} elseif ((int) $cur->getField('comment_status') == dcBlog::COMMENT_PENDING) {
|
||||||
$status = __('pending');
|
$status = __('pending');
|
||||||
} else {
|
} else {
|
||||||
# unknown status
|
// unknown status
|
||||||
$status = $cur->getField('comment_status');
|
$status = $cur->getField('comment_status');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +153,7 @@ class Frontend extends dcNsProcess
|
|||||||
|
|
||||||
$msg = __('You received a new comment on your blog:') . "\n\n" . $msg;
|
$msg = __('You received a new comment on your blog:') . "\n\n" . $msg;
|
||||||
|
|
||||||
# --BEHAVIOR-- emailNotificationAppendToEmail
|
// --BEHAVIOR-- emailNotificationAppendToEmail -- Cursor
|
||||||
$msg .= dcCore::app()->callBehavior('emailNotificationAppendToEmail', $cur);
|
$msg .= dcCore::app()->callBehavior('emailNotificationAppendToEmail', $cur);
|
||||||
|
|
||||||
foreach ($ulist as $email) {
|
foreach ($ulist as $email) {
|
||||||
|
Loading…
Reference in New Issue
Block a user