[ticket/11103] Finishing up PM Report notifications

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-10-09 22:28:41 -05:00
parent 9d955507b6
commit 6d53bd4675
6 changed files with 53 additions and 17 deletions

View file

@ -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'];

View file

@ -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'))),
'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
'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')}",
'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')
);
}

View file

@ -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)

View file

@ -397,7 +397,8 @@ $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' => 'A post "%1$s" was reported because "%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_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".',

View file

@ -0,0 +1,14 @@
Subject: Topic reply notification - "{TOPIC_TITLE}"
Hello {USERNAME},
You are receiving this notification because a Private Message titled, "{SUBJECT}" by "{AUTHOR_NAME}" at "{SITENAME}" was reported.
If you want to view the report, click the following link:
{U_VIEW_REPORT}
If you no longer wish to receive updates about replies to bookmarks, please update your notification settings here:
{U_NOTIFICATION_SETTINGS}
{EMAIL_SIG}

View file

@ -215,7 +215,10 @@ if ($submit && $reason_id)
$lang_success = $user->lang['PM_REPORTED_SUCCESS'];
// Notify relevant users
//$phpbb_notifications->add_notifications('report_pm', $report_data);
$phpbb_notifications->add_notifications('report_pm', array_merge($report_data, $row, array(
'from_user_id' => $report_data['author_id'],
'report_id' => $report_id,
)));
}
meta_refresh(3, $redirect_url);