aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/notifications
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/notifications')
-rw-r--r--phpBB/includes/notifications/service.php11
-rw-r--r--phpBB/includes/notifications/type/approve_post.php4
-rw-r--r--phpBB/includes/notifications/type/approve_topic.php113
-rw-r--r--phpBB/includes/notifications/type/base.php13
-rw-r--r--phpBB/includes/notifications/type/bookmark.php3
-rw-r--r--phpBB/includes/notifications/type/disapprove_post.php105
-rw-r--r--phpBB/includes/notifications/type/disapprove_topic.php104
-rw-r--r--phpBB/includes/notifications/type/interface.php2
-rw-r--r--phpBB/includes/notifications/type/pm.php14
-rw-r--r--phpBB/includes/notifications/type/post.php32
-rw-r--r--phpBB/includes/notifications/type/quote.php5
-rw-r--r--phpBB/includes/notifications/type/topic.php42
12 files changed, 361 insertions, 87 deletions
diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php
index 7fdba5e48a..6e7b160e0f 100644
--- a/phpBB/includes/notifications/service.php
+++ b/phpBB/includes/notifications/service.php
@@ -69,7 +69,10 @@ class phpbb_notifications_service
// Anonymous users and bots never receive notifications
if ($options['user_id'] == $user->data['user_id'] && ($user->data['user_id'] == ANONYMOUS || $user->data['user_type'] == USER_IGNORE))
{
- return;
+ return array(
+ 'notifications' => array(),
+ 'unread_count' => 0,
+ );
}
$notifications = $user_ids = array();
@@ -273,8 +276,8 @@ class phpbb_notifications_service
$notification_objects = $notification_methods = array();
$new_rows = array();
- // Never send notifications to the anonymous user or the current user!
- unset($notify_users[ANONYMOUS], $notify_users[$this->phpbb_container->get('user')->data['user_id']]);
+ // Never send notifications to the anonymous user!
+ unset($notify_users[ANONYMOUS]);
// Make sure not to send new notifications to users who've already been notified about this item
// This may happen when an item was added, but now new users are able to see the item
@@ -457,7 +460,7 @@ class phpbb_notifications_service
{
if (!$safe)
{
- $item_type = preg_replace('#[^a-z]#', '', $item_type);
+ $item_type = preg_replace('#[^a-z_]#', '', $item_type);
}
return 'phpbb_notifications_type_' . $item_type;
diff --git a/phpBB/includes/notifications/type/approve_post.php b/phpBB/includes/notifications/type/approve_post.php
index 9724916a0e..4a310db389 100644
--- a/phpBB/includes/notifications/type/approve_post.php
+++ b/phpBB/includes/notifications/type/approve_post.php
@@ -37,7 +37,7 @@ class phpbb_notifications_type_approve_post extends phpbb_notifications_type_pos
*
* @var string
*/
- protected $language_key = 'NOTIFICATION_POST';
+ protected $language_key = 'NOTIFICATION_POST_APPROVED';
/**
* Get the type of notification this is
@@ -109,6 +109,8 @@ class phpbb_notifications_type_approve_post extends phpbb_notifications_type_pos
{
$this->set_data('post_subject', $post['post_subject']);
+ $this->time = time();
+
return parent::create_insert_array($post);
}
}
diff --git a/phpBB/includes/notifications/type/approve_topic.php b/phpBB/includes/notifications/type/approve_topic.php
new file mode 100644
index 0000000000..426c4e374a
--- /dev/null
+++ b/phpBB/includes/notifications/type/approve_topic.php
@@ -0,0 +1,113 @@
+<?php
+/**
+*
+* @package notifications
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Post notifications class
+* This class handles notifications for replies to a topic
+*
+* @package notifications
+*/
+class phpbb_notifications_type_approve_topic extends phpbb_notifications_type_topic
+{
+ /**
+ * Email template to use to send notifications
+ *
+ * @var string
+ */
+ public $email_template = 'topic_approved';
+
+ /**
+ * Language key used to output the text
+ *
+ * @var string
+ */
+ protected $language_key = 'NOTIFICATION_TOPIC_APPROVED';
+
+ /**
+ * Get the type of notification this is
+ * phpbb_notifications_type_
+ */
+ public static function get_item_type()
+ {
+ return 'approve_topic';
+ }
+
+ /**
+ * Find the users who want to receive notifications
+ *
+ * @param ContainerBuilder $phpbb_container
+ * @param array $post Data from
+ *
+ * @return array
+ */
+ public static function find_users_for_notification(ContainerBuilder $phpbb_container, $post)
+ {
+ $users = array();
+
+ /* todo
+ * find what type of notification they'd like to receive
+ */
+ $users[$post['poster_id']] = array('');
+
+ $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']);
+
+ if (empty($auth_read))
+ {
+ return array();
+ }
+
+ $notify_users = array();
+
+ foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id)
+ {
+ $notify_users[$user_id] = $users[$user_id];
+ }
+
+ return $notify_users;
+ }
+
+ /**
+ * Get email template variables
+ *
+ * @return array
+ */
+ public function get_email_template_variables()
+ {
+ return array(
+ 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
+
+ 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->item_parent_id}&t={$this->item_id}",
+ );
+ }
+
+ /**
+ * Function for preparing the data for insertion in an SQL query
+ * (The service handles insertion)
+ *
+ * @param array $post Data from submit_post
+ *
+ * @return array Array of data ready to be inserted into the database
+ */
+ public function create_insert_array($post)
+ {
+ $this->time = time();
+
+ return parent::create_insert_array($post);
+ }
+}
diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php
index 4958e27919..fb75e19cad 100644
--- a/phpBB/includes/notifications/type/base.php
+++ b/phpBB/includes/notifications/type/base.php
@@ -114,8 +114,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
return array(
'AVATAR' => $this->get_avatar(),
- 'FORMATTED_TITLE' => $this->get_formatted_title(),
- 'TITLE' => $this->get_title(),
+ 'FORMATTED_TITLE' => $this->get_title(),
'URL' => $this->get_url(),
'TIME' => $user->format_date($this->time),
@@ -202,16 +201,6 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
*/
/**
- * Get the formatted title of this notification (fall-back)
- *
- * @return string
- */
- public function get_formatted_title()
- {
- return $this->get_title();
- }
-
- /**
* URL to unsubscribe to this notification (fall-back)
*
* @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item
diff --git a/phpBB/includes/notifications/type/bookmark.php b/phpBB/includes/notifications/type/bookmark.php
index 86a99e4ff5..9f2c2e26dc 100644
--- a/phpBB/includes/notifications/type/bookmark.php
+++ b/phpBB/includes/notifications/type/bookmark.php
@@ -75,6 +75,9 @@ class phpbb_notifications_type_bookmark extends phpbb_notifications_type_post
}
$db->sql_freeresult($result);
+ // Never notify the poster
+ unset($users[$post['poster_id']]);
+
if (empty($users))
{
return array();
diff --git a/phpBB/includes/notifications/type/disapprove_post.php b/phpBB/includes/notifications/type/disapprove_post.php
new file mode 100644
index 0000000000..9ef32349b3
--- /dev/null
+++ b/phpBB/includes/notifications/type/disapprove_post.php
@@ -0,0 +1,105 @@
+<?php
+/**
+*
+* @package notifications
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Post notifications class
+* This class handles notifications for replies to a topic
+*
+* @package notifications
+*/
+class phpbb_notifications_type_disapprove_post extends phpbb_notifications_type_approve_post
+{
+ /**
+ * Email template to use to send notifications
+ *
+ * @var string
+ */
+ public $email_template = 'post_disapproved';
+
+ /**
+ * Language key used to output the text
+ *
+ * @var string
+ */
+ protected $language_key = 'NOTIFICATION_POST_DISAPPROVED';
+
+ /**
+ * Get the type of notification this is
+ * phpbb_notifications_type_
+ */
+ public static function get_item_type()
+ {
+ return 'disapprove_post';
+ }
+
+ /**
+ * Get the HTML formatted title of this notification
+ *
+ * @return string
+ */
+ public function get_title()
+ {
+ return $this->phpbb_container->get('user')->lang(
+ $this->language_key,
+ censor_text($this->get_data('topic_title')),
+ $this->get_data('disapprove_reason')
+ );
+ }
+
+ /**
+ * Get the url to this item
+ *
+ * @return string URL
+ */
+ public function get_url()
+ {
+ return '';
+ }
+
+ /**
+ * Get email template variables
+ *
+ * @return array
+ */
+ public function get_email_template_variables()
+ {
+ return array(
+ 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))),
+ 'REASON' => htmlspecialchars_decode($this->get_data('disapprove_reason')),
+ );
+ }
+
+ /**
+ * Function for preparing the data for insertion in an SQL query
+ * (The service handles insertion)
+ *
+ * @param array $post Data from submit_post
+ *
+ * @return array Array of data ready to be inserted into the database
+ */
+ public function create_insert_array($post)
+ {
+ $this->set_data('post_subject', $post['post_subject']);
+ $this->set_data('disapprove_reason', $post['disapprove_reason']);
+
+ $this->time = time();
+
+ return parent::create_insert_array($post);
+ }
+}
diff --git a/phpBB/includes/notifications/type/disapprove_topic.php b/phpBB/includes/notifications/type/disapprove_topic.php
new file mode 100644
index 0000000000..eba82d2548
--- /dev/null
+++ b/phpBB/includes/notifications/type/disapprove_topic.php
@@ -0,0 +1,104 @@
+<?php
+/**
+*
+* @package notifications
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Post notifications class
+* This class handles notifications for replies to a topic
+*
+* @package notifications
+*/
+class phpbb_notifications_type_disapprove_topic extends phpbb_notifications_type_approve_topic
+{
+ /**
+ * Email template to use to send notifications
+ *
+ * @var string
+ */
+ public $email_template = 'topic_disapproved';
+
+ /**
+ * Language key used to output the text
+ *
+ * @var string
+ */
+ protected $language_key = 'NOTIFICATION_TOPIC_DISAPPROVED';
+
+ /**
+ * Get the type of notification this is
+ * phpbb_notifications_type_
+ */
+ public static function get_item_type()
+ {
+ return 'disapprove_topic';
+ }
+
+ /**
+ * Get the HTML formatted title of this notification
+ *
+ * @return string
+ */
+ public function get_title()
+ {
+ return $this->phpbb_container->get('user')->lang(
+ $this->language_key,
+ censor_text($this->get_data('topic_title')),
+ $this->get_data('disapprove_reason')
+ );
+ }
+
+ /**
+ * Get the url to this item
+ *
+ * @return string URL
+ */
+ public function get_url()
+ {
+ return '';
+ }
+
+ /**
+ * Get email template variables
+ *
+ * @return array
+ */
+ public function get_email_template_variables()
+ {
+ return array(
+ 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
+
+ 'REASON' => htmlspecialchars_decode($this->get_data('disapprove_reason')),
+ );
+ }
+
+ /**
+ * Function for preparing the data for insertion in an SQL query
+ * (The service handles insertion)
+ *
+ * @param array $post Data from submit_post
+ *
+ * @return array Array of data ready to be inserted into the database
+ */
+ public function create_insert_array($post)
+ {
+ $this->set_data('disapprove_reason', $post['disapprove_reason']);
+ $this->time = time();
+
+ return parent::create_insert_array($post);
+ }
+}
diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php
index a8c6e4869b..de08576a38 100644
--- a/phpBB/includes/notifications/type/interface.php
+++ b/phpBB/includes/notifications/type/interface.php
@@ -29,8 +29,6 @@ interface phpbb_notifications_type_interface
public function get_title();
- public function get_formatted_title();
-
public function get_email_template_variables();
public function get_url();
diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php
index 816383949b..df7b42564c 100644
--- a/phpBB/includes/notifications/type/pm.php
+++ b/phpBB/includes/notifications/type/pm.php
@@ -121,7 +121,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
*
* @return string
*/
- public function get_formatted_title()
+ public function get_title()
{
$user_data = $this->service->get_user($this->get_data('from_user_id'));
@@ -131,18 +131,6 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
}
/**
- * Get the plain text title of this notification
- *
- * @return string
- */
- public function get_title()
- {
- $user_data = $this->service->get_user($this->get_data('from_user_id'));
-
- return $this->phpbb_container->get('user')->lang('NOTIFICATION_PM', $user_data['username'], $this->get_data('message_subject'));
- }
-
- /**
* Get email template variables
*
* @return array
diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php
index 13742ee78b..0ad2c4893f 100644
--- a/phpBB/includes/notifications/type/post.php
+++ b/phpBB/includes/notifications/type/post.php
@@ -101,6 +101,9 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
}
$db->sql_freeresult($result);
+ // Never notify the poster
+ unset($users[$post['poster_id']]);
+
if (empty($users))
{
return array();
@@ -136,31 +139,6 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
*
* @return string
*/
- public function get_formatted_title()
- {
- if ($this->get_data('post_username'))
- {
- $username = $this->get_data('post_username');
- }
- else
- {
- $user_data = $this->service->get_user($this->get_data('poster_id'));
-
- $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
- }
-
- return $this->phpbb_container->get('user')->lang(
- $this->language_key,
- $username,
- censor_text($this->get_data('topic_title'))
- );
- }
-
- /**
- * Get the title of this notification
- *
- * @return string
- */
public function get_title()
{
if ($this->get_data('post_username'))
@@ -171,7 +149,7 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
{
$user_data = $this->service->get_user($this->get_data('poster_id'));
- $username = $user_data['username'];
+ $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
}
return $this->phpbb_container->get('user')->lang(
@@ -238,6 +216,8 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
$this->set_data('forum_name', $post['forum_name']);
+ $this->time = $post['post_time'];
+
return parent::create_insert_array($post);
}
}
diff --git a/phpBB/includes/notifications/type/quote.php b/phpBB/includes/notifications/type/quote.php
index 48d63003dd..647f81041d 100644
--- a/phpBB/includes/notifications/type/quote.php
+++ b/phpBB/includes/notifications/type/quote.php
@@ -68,7 +68,7 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post
$db = $phpbb_container->get('dbal.conn');
$usernames = false;
- preg_match_all(self::$regular_expression_match, $post['message'], $usernames);
+ preg_match_all(self::$regular_expression_match, $post['post_text'], $usernames);
if (empty($usernames[1]))
{
@@ -94,6 +94,9 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post
}
$db->sql_freeresult($result);
+ // Never notify the poster
+ unset($users[$post['poster_id']]);
+
if (empty($users))
{
return array();
diff --git a/phpBB/includes/notifications/type/topic.php b/phpBB/includes/notifications/type/topic.php
index e31c8d792b..cfc629430b 100644
--- a/phpBB/includes/notifications/type/topic.php
+++ b/phpBB/includes/notifications/type/topic.php
@@ -33,6 +33,13 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
public $email_template = 'newtopic_notify';
/**
+ * Language key used to output the text
+ *
+ * @var string
+ */
+ protected $language_key = 'NOTIFICATION_TOPIC';
+
+ /**
* Get the type of notification this is
* phpbb_notifications_type_
*/
@@ -94,6 +101,9 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
}
$db->sql_freeresult($result);
+ // Never notify the poster
+ unset($users[$topic['poster_id']]);
+
if (empty($users))
{
return array();
@@ -129,32 +139,6 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
*
* @return string
*/
- public function get_formatted_title()
- {
- if ($this->get_data('post_username'))
- {
- $username = $this->get_data('post_username');
- }
- else
- {
- $user_data = $this->service->get_user($this->get_data('poster_id'));
-
- $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
- }
-
- return $this->phpbb_container->get('user')->lang(
- 'NOTIFICATION_TOPIC',
- $username,
- censor_text($this->get_data('topic_title')),
- $this->get_data('forum_name')
- );
- }
-
- /**
- * Get the title of this notification
- *
- * @return string
- */
public function get_title()
{
if ($this->get_data('post_username'))
@@ -165,11 +149,11 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
{
$user_data = $this->service->get_user($this->get_data('poster_id'));
- $username = $user_data['username'];
+ $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
}
return $this->phpbb_container->get('user')->lang(
- 'NOTIFICATION_TOPIC',
+ $this->language_key,
$username,
censor_text($this->get_data('topic_title')),
$this->get_data('forum_name')
@@ -230,6 +214,8 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
$this->set_data('forum_name', $post['forum_name']);
+ $this->time = $post['post_time'];
+
return parent::create_insert_array($post);
}
}