aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/mcp/mcp_queue.php33
-rw-r--r--phpBB/includes/notifications/type/approve_post.php114
2 files changed, 122 insertions, 25 deletions
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 1373829ecf..df99e34576 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -597,45 +597,28 @@ function approve_post($post_id_list, $id, $mode)
sync('forum', 'forum_id', array_keys($forum_id_list), true, true);
unset($topic_id_list, $forum_id_list);
- $messenger = new messenger();
+ $phpbb_notifications = $phpbb_container->get('notifications');
// Notify Poster?
if ($notify_poster)
{
+ // Forum Notifications
foreach ($post_info as $post_id => $post_data)
{
- if ($post_data['poster_id'] == ANONYMOUS)
+ if ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id'])
{
- continue;
+ $phpbb_notifications->add_notifications('approve_topic', $post_data);
+ }
+ else
+ {
+ $phpbb_notifications->add_notifications('approve_post', $post_data);
}
-
- $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved';
-
- $messenger->template($email_template, $post_data['user_lang']);
-
- $messenger->to($post_data['user_email'], $post_data['username']);
- $messenger->im($post_data['user_jabber'], $post_data['username']);
-
- $messenger->assign_vars(array(
- 'USERNAME' => htmlspecialchars_decode($post_data['username']),
- 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
- 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])),
-
- 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0",
- 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id")
- );
-
- $messenger->send($post_data['user_notify_type']);
}
}
- $messenger->save_queue();
-
// Send out normal user notifications
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
- $phpbb_notifications = $phpbb_container->get('notifications');
-
foreach ($post_info as $post_id => $post_data)
{
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
diff --git a/phpBB/includes/notifications/type/approve_post.php b/phpBB/includes/notifications/type/approve_post.php
new file mode 100644
index 0000000000..9724916a0e
--- /dev/null
+++ b/phpBB/includes/notifications/type/approve_post.php
@@ -0,0 +1,114 @@
+<?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_post extends phpbb_notifications_type_post
+{
+ /**
+ * Email template to use to send notifications
+ *
+ * @var string
+ */
+ public $email_template = 'post_approved';
+
+ /**
+ * Language key used to output the text
+ *
+ * @var string
+ */
+ protected $language_key = 'NOTIFICATION_POST';
+
+ /**
+ * Get the type of notification this is
+ * phpbb_notifications_type_
+ */
+ public static function get_item_type()
+ {
+ return 'approve_post';
+ }
+
+ /**
+ * 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(
+ 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))),
+
+ 'U_VIEW_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}",
+ 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_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->set_data('post_subject', $post['post_subject']);
+
+ return parent::create_insert_array($post);
+ }
+}