From 6d53bd4675e00419bcfcf476b03166b9774bebca Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 9 Oct 2012 22:28:41 -0500 Subject: [ticket/11103] Finishing up PM Report notifications PHPBB3-11103 --- phpBB/includes/mcp/mcp_pm_reports.php | 4 +++ phpBB/includes/notification/type/report_pm.php | 44 ++++++++++++++++-------- phpBB/includes/notification/type/report_post.php | 2 +- 3 files changed, 34 insertions(+), 16 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index 24e531517c..227c89bb79 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -34,6 +34,7 @@ class mcp_pm_reports { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action; + global $phpbb_notifications; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); @@ -89,6 +90,9 @@ class mcp_pm_reports trigger_error('NO_REPORT'); } + // Mark the notification as read + $phpbb_notifications->mark_notifications_read_by_parent('report_pm', $report_id, $user->data['user_id']); + $pm_id = $report['pm_id']; $report_id = $report['report_id']; diff --git a/phpBB/includes/notification/type/report_pm.php b/phpBB/includes/notification/type/report_pm.php index 9c680ce6a9..e9fa4c0f11 100644 --- a/phpBB/includes/notification/type/report_pm.php +++ b/phpBB/includes/notification/type/report_pm.php @@ -28,7 +28,14 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm * * @var string */ - public $email_template = 'notifications/report_post'; + public $email_template = 'notifications/report_pm'; + + /** + * Language key used to output the text + * + * @var string + */ + protected $language_key = 'NOTIFICATION_REPORT_PM'; /** * Permission to check for (in find_users_for_notification) @@ -57,8 +64,19 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm return 'report_pm'; } + /** + * Get the id of the parent + * + * @param array $pm The data from the pm + */ + public static function get_item_parent_id($pm) + { + return (int) $pm['report_id']; + } + /** * Find the users who want to receive notifications + * (copied from post_in_queue) * * @param array $post Data from the post * @@ -70,6 +88,9 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm 'ignore_users' => array(), ), $options); + // Global + $post['forum_id'] = 0; + $auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']); if (empty($auth_approve)) @@ -110,18 +131,11 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm */ public function get_email_template_variables() { - $board_url = generate_board_url(); - return array( - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), - - 'U_VIEW_REPORT' => "{$board_url}mcp.{$this->php_ext}?f={$this->get_data('forum_id')}&p={$this->item_id}&i=reports&mode=report_details#reports", - 'U_VIEW_POST' => "{$board_url}/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}", - 'U_NEWEST_POST' => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&view=unread#unread", - 'U_TOPIC' => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", - 'U_VIEW_TOPIC' => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", - 'U_FORUM' => "{$board_url}/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}", + 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']), + 'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))), + + 'U_VIEW_REPORT' => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details", ); } @@ -132,7 +146,7 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm */ public function get_url() { - return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "f={$this->get_data('forum_id')}&p={$this->item_id}&i=reports&mode=report_details#reports"); + return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details"); } /** @@ -148,14 +162,14 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm { return $this->user->lang( $this->language_key, - censor_text($this->get_data('post_subject')), + censor_text($this->get_data('message_subject')), $this->user->lang[$this->get_data('reason_title')] ); } return $this->user->lang( $this->language_key, - censor_text($this->get_data('post_subject')), + censor_text($this->get_data('message_subject')), $this->get_data('reason_description') ); } diff --git a/phpBB/includes/notification/type/report_post.php b/phpBB/includes/notification/type/report_post.php index 70d3a4c114..df67a8e338 100644 --- a/phpBB/includes/notification/type/report_post.php +++ b/phpBB/includes/notification/type/report_post.php @@ -35,7 +35,7 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i * * @var string */ - protected $language_key = 'NOTIFICATION_REPORT'; + protected $language_key = 'NOTIFICATION_REPORT_POST'; /** * Permission to check for (in find_users_for_notification) -- cgit v1.2.1