first commit from emailNotification 1.1
This commit is contained in:
commit
8e1528fa4c
18
_admin.php
Normal file
18
_admin.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of emailNotification, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) Olivier Meunier and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
|
||||
$core->addBehavior('adminPreferencesForm',array('notificationBehaviors','adminUserForm'));
|
||||
$core->addBehavior('adminUserForm',array('notificationBehaviors','adminUserForm')); // user.php
|
||||
|
||||
$core->addBehavior('adminBeforeUserUpdate',array('notificationBehaviors','adminBeforeUserUpdate'));
|
||||
$core->addBehavior('adminBeforeUserOptionsUpdate',array('notificationBehaviors','adminBeforeUserUpdate')); //preferences.php
|
27
_define.php
Normal file
27
_define.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of emailNotification, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) Olivier Meunier and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$this->registerModule(
|
||||
/* Name */ "Email notification",
|
||||
/* Description*/ "Email notification",
|
||||
/* Author */ "Olivier Meunier",
|
||||
/* Version */ '1.1',
|
||||
/* Properties */
|
||||
array(
|
||||
'permissions' => 'usage,contentadmin',
|
||||
'type' => 'plugin',
|
||||
'dc_min' => '2.6',
|
||||
'support' => 'http://forum.dotclear.org/viewforum.php?id=16',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/emailNotification'
|
||||
)
|
||||
);
|
14
_prepend.php
Normal file
14
_prepend.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of emailNotification, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) Olivier Meunier and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$GLOBALS['__autoload']['notificationBehaviors'] = dirname(__FILE__).'/behaviors.php';
|
14
_public.php
Normal file
14
_public.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of emailNotification, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) Olivier Meunier and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$core->addBehavior('publicAfterCommentCreate',array('notificationBehaviors','publicAfterCommentCreate'));
|
153
behaviors.php
Normal file
153
behaviors.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of emailNotification, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) Olivier Meunier and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) {return;}
|
||||
|
||||
class notificationBehaviors
|
||||
{
|
||||
public static function adminUserForm($core)
|
||||
{
|
||||
global $user_options;
|
||||
|
||||
$notify_comments = !empty($user_options['notify_comments']) ? $user_options['notify_comments'] : '0';
|
||||
|
||||
$opt = array(
|
||||
__('Never') => '0',
|
||||
__('My entries') => 'mine',
|
||||
__('All entries') => 'all'
|
||||
);
|
||||
|
||||
echo
|
||||
'<div class="fieldset"><h5>'.__('Email notification').'</h5>'.
|
||||
'<p><label class="classic" for="notify_comments">'.__('Notify new comments by email:').' '.
|
||||
form::combo('notify_comments',$opt,$notify_comments).
|
||||
'</label></p>'.
|
||||
'</div>';
|
||||
}
|
||||
|
||||
public static function adminBeforeUserUpdate($cur,$user_id='')
|
||||
{
|
||||
$cur->user_options['notify_comments'] = $_POST['notify_comments'];
|
||||
}
|
||||
|
||||
public static function publicAfterCommentCreate($cur,$comment_id)
|
||||
{
|
||||
# We don't want notification for spam
|
||||
if ($cur->comment_status == -2) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $core;
|
||||
|
||||
# Information on comment author and post author
|
||||
$rs = $core->auth->sudo(array($core->blog,'getComments'), array('comment_id'=>$comment_id));
|
||||
|
||||
if ($rs->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Information on blog users
|
||||
$strReq =
|
||||
'SELECT U.user_id, user_email, user_options '.
|
||||
'FROM '.$core->blog->prefix.'user U JOIN '.$core->blog->prefix.'permissions P ON U.user_id = P.user_id '.
|
||||
"WHERE blog_id = '".$core->con->escape($core->blog->id)."' ".
|
||||
'UNION '.
|
||||
'SELECT user_id, user_email, user_options '.
|
||||
'FROM '.$core->blog->prefix.'user '.
|
||||
'WHERE user_super = 1 ';
|
||||
|
||||
$users = $core->con->select($strReq);
|
||||
|
||||
# Create notify list
|
||||
$ulist = array();
|
||||
while ($users->fetch()) {
|
||||
if (!$users->user_email) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$notification_pref = self::notificationPref(rsExtUser::options($users));
|
||||
|
||||
if ($notification_pref == 'all'
|
||||
|| ($notification_pref == 'mine' && $users->user_id == $rs->user_id) )
|
||||
{
|
||||
$ulist[$users->user_id] = $users->user_email;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($ulist) > 0)
|
||||
{
|
||||
# Author of the post wants to be notified by mail
|
||||
$headers = array(
|
||||
'Reply-To: '.$rs->comment_email,
|
||||
'Content-Type: text/plain; charset=UTF-8;',
|
||||
'X-Mailer: Dotclear',
|
||||
'X-Blog-Id: '.mail::B64Header($core->blog->id),
|
||||
'X-Blog-Name: '.mail::B64Header($core->blog->name),
|
||||
'X-Blog-Url: '.mail::B64Header($core->blog->url)
|
||||
);
|
||||
|
||||
$subject = '['.$core->blog->name.'] '.sprintf(__('"%s" - New comment'),$rs->post_title);
|
||||
$subject = mail::B64Header($subject);
|
||||
|
||||
$msg = preg_replace('%</p>\s*<p>%msu',"\n\n",$rs->comment_content);
|
||||
$msg = html::clean($msg);
|
||||
$msg = html_entity_decode($msg);
|
||||
|
||||
if ($cur->comment_status == 1)
|
||||
{
|
||||
$status = __('published');
|
||||
}
|
||||
elseif ($cur->comment_status == 0)
|
||||
{
|
||||
$status = __('unpublished');
|
||||
}
|
||||
elseif ($cur->comment_status == -1)
|
||||
{
|
||||
$status = __('pending');
|
||||
}
|
||||
else
|
||||
{
|
||||
# unknown status
|
||||
$status = $cur->comment_status;
|
||||
}
|
||||
|
||||
$msg .= "\n\n-- \n".
|
||||
sprintf(__('Blog: %s'),$core->blog->name)."\n".
|
||||
sprintf(__('Entry: %s <%s>'),$rs->post_title,$rs->getPostURL())."\n".
|
||||
sprintf(__('Comment by: %s <%s>'),$rs->comment_author,$rs->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) != '/') ? '/' : '').
|
||||
'comment.php?id='.$cur->comment_id.
|
||||
'&switchblog='.$core->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
|
||||
$msg .= $core->callBehavior('emailNotificationAppendToEmail',$cur);
|
||||
|
||||
foreach ($ulist as $email) {
|
||||
$h = array_merge(array('From: '.$email),$headers);
|
||||
mail::sendMail($email,$subject,$msg,$h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function notificationPref($o)
|
||||
{
|
||||
if (is_array($o) && isset($o['notify_comments'])) {
|
||||
return $o['notify_comments'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
76
locales/_pot/main.pot
Normal file
76
locales/_pot/main.pot
Normal file
@ -0,0 +1,76 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# This file is put in the public domain.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Dotclear 2 emailNotification module\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-07-10 07:59+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:24
|
||||
msgid "My entries"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:25
|
||||
msgid "All entries"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:29
|
||||
msgid "Email notification"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:30
|
||||
msgid "Notify new comments by email:"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:97
|
||||
#, php-format
|
||||
msgid "\"%s\" - New comment"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:123
|
||||
#, php-format
|
||||
msgid "Blog: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:124
|
||||
#, php-format
|
||||
msgid "Entry: %s <%s>"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:125
|
||||
#, php-format
|
||||
msgid "Comment by: %s <%s>"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:126
|
||||
#, php-format
|
||||
msgid "Website: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:127
|
||||
#, php-format
|
||||
msgid "Comment status: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:128
|
||||
#, php-format
|
||||
msgid "Edit this comment: <%s>"
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:132
|
||||
msgid "You must log in on the backend before clicking on this link to go directly to the comment."
|
||||
msgstr ""
|
||||
|
||||
#: ../hg-plugins/emailNotification//behaviors.php:134
|
||||
msgid "You received a new comment on your blog:"
|
||||
msgstr ""
|
66
locales/fr/main.po
Normal file
66
locales/fr/main.po
Normal file
@ -0,0 +1,66 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# This file is put in the public domain.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Dotclear 2 emailNotification module\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-07-10 07:59+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "Never"
|
||||
msgstr "Jamais"
|
||||
|
||||
msgid "My entries"
|
||||
msgstr "Mes billets"
|
||||
|
||||
msgid "All entries"
|
||||
msgstr "Tous les billets"
|
||||
|
||||
msgid "Email notification"
|
||||
msgstr "Notification par e-mail"
|
||||
|
||||
msgid "Notify new comments by email:"
|
||||
msgstr "Avertir des nouveaux commentaires par e-mail :"
|
||||
|
||||
#, php-format
|
||||
msgid "\"%s\" - New comment"
|
||||
msgstr "\"%s\" - Nouveau commentaire"
|
||||
|
||||
#, php-format
|
||||
msgid "Blog: %s"
|
||||
msgstr "Blog : %s"
|
||||
|
||||
#, php-format
|
||||
msgid "Entry: %s <%s>"
|
||||
msgstr "Billet : %s <%s>"
|
||||
|
||||
#, php-format
|
||||
msgid "Comment by: %s <%s>"
|
||||
msgstr "Commentaire par : %s <%s>"
|
||||
|
||||
#, php-format
|
||||
msgid "Website: %s"
|
||||
msgstr "Site web : %s"
|
||||
|
||||
#, php-format
|
||||
msgid "Comment status: %s"
|
||||
msgstr "Statut du commentaire : %s"
|
||||
|
||||
#, php-format
|
||||
msgid "Edit this comment: <%s>"
|
||||
msgstr "Modifier ce commentaire : %s"
|
||||
|
||||
msgid "You must log in on the backend before clicking on this link to go directly to the comment."
|
||||
msgstr "Vous devez vous enregistrer sur l'interface d'administration avant de cliquer sur ce lien pour aller directement sur ce commentaire."
|
||||
|
||||
msgid "You received a new comment on your blog:"
|
||||
msgstr "Vous avez reçu un nouveau commentaire sur votre blog :"
|
Loading…
Reference in New Issue
Block a user