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('
', "\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 @@ +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); + } +}