[ticket/11103] Use report text for report notification, never notify reporter

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-10-16 17:44:46 -05:00
parent 3557b39115
commit 3839fe6902
3 changed files with 45 additions and 2 deletions

View file

@ -115,7 +115,8 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . " FROM ' . USER_NOTIFICATIONS_TABLE . "
WHERE item_type = '" . self::$notification_option['id'] . "' WHERE item_type = '" . self::$notification_option['id'] . "'
AND " . $this->db->sql_in_set('user_id', $auth_approve[$post['forum_id']][$this->permission]); AND " . $this->db->sql_in_set('user_id', $auth_approve[$post['forum_id']][$this->permission]) . '
AND user_id <> ' . $this->user->data['user_id'];
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
@ -174,6 +175,16 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
if ($this->get_data('report_text'))
{
return $this->user->lang(
$this->language_key,
$username,
censor_text($this->get_data('message_subject')),
$this->get_data('report_text')
);
}
if (isset($this->user->lang[$this->get_data('reason_title')])) if (isset($this->user->lang[$this->get_data('reason_title')]))
{ {
return $this->user->lang( return $this->user->lang(
@ -224,6 +235,7 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
$this->set_data('reporter_id', $this->user->data['user_id']); $this->set_data('reporter_id', $this->user->data['user_id']);
$this->set_data('reason_title', strtoupper($post['reason_title'])); $this->set_data('reason_title', strtoupper($post['reason_title']));
$this->set_data('reason_description', $post['reason_description']); $this->set_data('reason_description', $post['reason_description']);
$this->set_data('report_text', $post['report_text']);
return parent::create_insert_array($post, $pre_create_data); return parent::create_insert_array($post, $pre_create_data);
} }

View file

@ -65,6 +65,23 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i
return 'report_post'; return 'report_post';
} }
/**
* Find the users who want to receive notifications
*
* @param array $post Data from the post
*
* @return array
*/
public function find_users_for_notification($post, $options = array())
{
$notify_users = parent::find_users_for_notification($post, $options);
// never notify reporter
unset($notify_users[$this->user->data['user_id']]);
return $notify_users;
}
/** /**
* Get email template variables * Get email template variables
* *
@ -110,6 +127,16 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
if ($this->get_data('report_text'))
{
return $this->user->lang(
$this->language_key,
$username,
censor_text($this->get_data('post_subject')),
$this->get_data('report_text')
);
}
if (isset($this->user->lang[$this->get_data('reason_title')])) if (isset($this->user->lang[$this->get_data('reason_title')]))
{ {
return $this->user->lang( return $this->user->lang(
@ -160,6 +187,7 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i
$this->set_data('reporter_id', $this->user->data['user_id']); $this->set_data('reporter_id', $this->user->data['user_id']);
$this->set_data('reason_title', strtoupper($post['reason_title'])); $this->set_data('reason_title', strtoupper($post['reason_title']));
$this->set_data('reason_description', $post['reason_description']); $this->set_data('reason_description', $post['reason_description']);
$this->set_data('report_text', $post['report_text']);
return parent::create_insert_array($post, $pre_create_data); return parent::create_insert_array($post, $pre_create_data);
} }

View file

@ -186,7 +186,9 @@ if ($submit && $reason_id)
$lang_success = $user->lang['POST_REPORTED_SUCCESS']; $lang_success = $user->lang['POST_REPORTED_SUCCESS'];
// Notify relevant users // Notify relevant users
$phpbb_notifications->add_notifications('report_post', array_merge($report_data, $row, $forum_data)); $phpbb_notifications->add_notifications('report_post', array_merge($report_data, $row, $forum_data, array(
'report_text' => $report_text,
)));
} }
else else
{ {
@ -216,6 +218,7 @@ if ($submit && $reason_id)
// Notify relevant users // Notify relevant users
$phpbb_notifications->add_notifications('report_pm', array_merge($report_data, $row, array( $phpbb_notifications->add_notifications('report_pm', array_merge($report_data, $row, array(
'report_text' => $report_text,
'from_user_id' => $report_data['author_id'], 'from_user_id' => $report_data['author_id'],
'report_id' => $report_id, 'report_id' => $report_id,
))); )));