diff options
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 34 | ||||
-rw-r--r-- | phpBB/includes/notification/type/report_pm.php | 25 | ||||
-rw-r--r-- | phpBB/includes/notification/type/report_pm_closed.php | 140 | ||||
-rw-r--r-- | phpBB/includes/notification/type/report_post.php | 25 | ||||
-rw-r--r-- | phpBB/includes/notification/type/report_post_closed.php | 140 | ||||
-rw-r--r-- | phpBB/language/en/common.php | 5 |
6 files changed, 345 insertions, 24 deletions
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index b43f9d6ec4..7c6352a244 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -448,6 +448,7 @@ function close_report($report_id_list, $mode, $action, $pm = false) { global $db, $template, $user, $config, $auth; global $phpEx, $phpbb_root_path; + global $phpbb_notifications; $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 '; $id_column = ($pm) ? 'pm_id' : 'post_id'; @@ -633,8 +634,6 @@ function close_report($report_id_list, $mode, $action, $pm = false) } } - $messenger = new messenger(); - // Notify reporters if (sizeof($notify_reporters)) { @@ -647,30 +646,23 @@ function close_report($report_id_list, $mode, $action, $pm = false) $post_id = $reporter[$id_column]; - $messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']); - - $messenger->to($reporter['user_email'], $reporter['username']); - $messenger->im($reporter['user_jabber'], $reporter['username']); - if ($pm) { - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($reporter['username']), - 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), - 'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])), - )); + $phpbb_notifications->add_notifications('report_pm_closed', array_merge($post_info[$post_id], array( + 'reporter' => $reporter['user_id'], + 'closer_id' => $user->data['user_id'], + 'from_user_id' => $post_info[$post_id]['author_id'], + ))); + $phpbb_notifications->delete_notifications('report_pm', $post_id); } else { - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($reporter['username']), - 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) - ); + $phpbb_notifications->add_notifications('report_post_closed', array_merge($post_info[$post_id], array( + 'reporter' => $reporter['user_id'], + 'closer_id' => $user->data['user_id'], + ))); + $phpbb_notifications->delete_notifications('report_post', $post_id); } - - $messenger->send($reporter['user_notify_type']); } } @@ -685,8 +677,6 @@ function close_report($report_id_list, $mode, $action, $pm = false) unset($notify_reporters, $post_info, $reports); - $messenger->save_queue(); - $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS'; } else diff --git a/phpBB/includes/notification/type/report_pm.php b/phpBB/includes/notification/type/report_pm.php index e9fa4c0f11..af1f71433c 100644 --- a/phpBB/includes/notification/type/report_pm.php +++ b/phpBB/includes/notification/type/report_pm.php @@ -158,10 +158,15 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm { $this->user->add_lang('mcp'); + $user_data = $this->notification_manager->get_user($this->get_data('reporter_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + if (isset($this->user->lang[$this->get_data('reason_title')])) { return $this->user->lang( $this->language_key, + $username, censor_text($this->get_data('message_subject')), $this->user->lang[$this->get_data('reason_title')] ); @@ -169,12 +174,31 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm return $this->user->lang( $this->language_key, + $username, censor_text($this->get_data('message_subject')), $this->get_data('reason_description') ); } /** + * Get the user's avatar + */ + public function get_avatar() + { + return $this->_get_avatar($this->get_data('reporter_id')); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array($this->data['reporter_id']); + } + + /** * Function for preparing the data for insertion in an SQL query * (The service handles insertion) * @@ -184,6 +208,7 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm */ public function create_insert_array($post) { + $this->set_data('reporter_id', $this->user->data['user_id']); $this->set_data('reason_title', strtoupper($post['reason_title'])); $this->set_data('reason_description', $post['reason_description']); diff --git a/phpBB/includes/notification/type/report_pm_closed.php b/phpBB/includes/notification/type/report_pm_closed.php new file mode 100644 index 0000000000..534e1288a6 --- /dev/null +++ b/phpBB/includes/notification/type/report_pm_closed.php @@ -0,0 +1,140 @@ +<?php +/** +* +* @package notifications +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Reported post notifications class +* This class handles notifications for reported pms +* +* @package notifications +*/ +class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_pm +{ + /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = ''; + + /** + * Language key used to output the text + * + * @var string + */ + protected $language_key = 'NOTIFICATION_REPORT_CLOSED'; + + public function is_available() + { + return false; + } + + /** + * Get the type of notification this is + * phpbb_notification_type_ + */ + public static function get_item_type() + { + return 'report_pm_closed'; + } + + /** + * Find the users who want to receive notifications + * + * @param array $post Data from + * + * @return array + */ + public function find_users_for_notification($post, $options = array()) + { + return array($post['reporter'] => array('')); + } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + return array(); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return ''; + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_title() + { + $user_data = $this->notification_manager->get_user($this->get_data('closer_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + + return $this->user->lang( + $this->language_key, + $username, + censor_text($this->get_data('message_subject')) + ); + } + + /** + * Get the user's avatar + */ + public function get_avatar() + { + return $this->_get_avatar($this->get_data('closer_id')); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array($this->data['closer_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('closer_id', $post['closer_id']); + + $data = parent::create_insert_array($post); + + $this->time = $data['time'] = time(); + + return $data; + } +} diff --git a/phpBB/includes/notification/type/report_post.php b/phpBB/includes/notification/type/report_post.php index df67a8e338..2346e4e57c 100644 --- a/phpBB/includes/notification/type/report_post.php +++ b/phpBB/includes/notification/type/report_post.php @@ -105,10 +105,15 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i { $this->user->add_lang('mcp'); + $user_data = $this->notification_manager->get_user($this->get_data('reporter_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + if (isset($this->user->lang[$this->get_data('reason_title')])) { return $this->user->lang( $this->language_key, + $username, censor_text($this->get_data('post_subject')), $this->user->lang[$this->get_data('reason_title')] ); @@ -116,12 +121,31 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i return $this->user->lang( $this->language_key, + $username, censor_text($this->get_data('post_subject')), $this->get_data('reason_description') ); } /** + * Get the user's avatar + */ + public function get_avatar() + { + return $this->_get_avatar($this->get_data('reporter_id')); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array($this->data['reporter_id']); + } + + /** * Function for preparing the data for insertion in an SQL query * (The service handles insertion) * @@ -131,6 +155,7 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i */ public function create_insert_array($post) { + $this->set_data('reporter_id', $this->user->data['user_id']); $this->set_data('reason_title', strtoupper($post['reason_title'])); $this->set_data('reason_description', $post['reason_description']); diff --git a/phpBB/includes/notification/type/report_post_closed.php b/phpBB/includes/notification/type/report_post_closed.php new file mode 100644 index 0000000000..d8537a8152 --- /dev/null +++ b/phpBB/includes/notification/type/report_post_closed.php @@ -0,0 +1,140 @@ +<?php +/** +* +* @package notifications +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Reported post notifications class +* This class handles notifications for reported posts +* +* @package notifications +*/ +class phpbb_notification_type_report_post_closed extends phpbb_notification_type_post +{ + /** + * Email template to use to send notifications + * + * @var string + */ + public $email_template = ''; + + /** + * Language key used to output the text + * + * @var string + */ + protected $language_key = 'NOTIFICATION_REPORT_CLOSED'; + + public function is_available() + { + return false; + } + + /** + * Get the type of notification this is + * phpbb_notification_type_ + */ + public static function get_item_type() + { + return 'report_post_closed'; + } + + /** + * Find the users who want to receive notifications + * + * @param array $post Data from + * + * @return array + */ + public function find_users_for_notification($post, $options = array()) + { + return array($post['reporter'] => array('')); + } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + return array(); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return ''; + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_title() + { + $user_data = $this->notification_manager->get_user($this->get_data('closer_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + + return $this->user->lang( + $this->language_key, + $username, + censor_text($this->get_data('post_subject')) + ); + } + + /** + * Get the user's avatar + */ + public function get_avatar() + { + return $this->_get_avatar($this->get_data('closer_id')); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array($this->data['closer_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('closer_id', $post['closer_id']); + + $data = parent::create_insert_array($post); + + $this->time = $data['time'] = time(); + + return $data; + } +} diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index cbf8e6ee4c..78ba02ed0f 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -397,8 +397,9 @@ $lang = array_merge($lang, array( 'NOTIFICATION_POST_DISAPPROVED' => 'Your post "%1$s" was disapproved because "%2$s".', 'NOTIFICATION_POST_IN_QUEUE' => 'A new post titled "%2$s" was posted by "%1$s" and needs approval.', 'NOTIFICATION_QUOTE' => '%1$s quoted you in the post "%2$s".', - 'NOTIFICATION_REPORT_PM' => 'A Private Message "%1$s" was reported because "%2$s".', - 'NOTIFICATION_REPORT_POST' => 'A post "%1$s" was reported because "%2$s".', + 'NOTIFICATION_REPORT_PM' => '%1$s reported a Private Message "%2$s" because "%3$s".', + 'NOTIFICATION_REPORT_POST' => '%1$s reported a post "%2$s" because "%3$s".', + 'NOTIFICATION_REPORT_CLOSED' => '%1$s closed the report you made for "%2$s".', 'NOTIFICATION_TOPIC' => '%1$s posted a new topic "%2$s" in the forum "%3$s".', 'NOTIFICATION_TOPIC_APPROVED' => 'Your topic "%2$s" in the forum "%3$s" was approved.', 'NOTIFICATION_TOPIC_DISAPPROVED' => 'Your topic "%1$s" was disapproved because "%2$s".', |