1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-18 22:58:10 +01:00

[ticket/11103] Working on report notifications (post/pm)

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-10-09 22:02:49 -05:00
parent 7411d1d1bd
commit b33e527394
9 changed files with 349 additions and 88 deletions

View File

@ -34,6 +34,7 @@ class mcp_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);
@ -87,6 +88,9 @@ class mcp_reports
trigger_error('NO_REPORT');
}
// Mark the notification as read
$phpbb_notifications->mark_notifications_read('report_post', $post_id, $user->data['user_id']);
if (!$report_id && $report['report_closed'])
{
trigger_error('REPORT_CLOSED');
@ -413,7 +417,7 @@ class mcp_reports
$base_url = $this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir";
phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
// Now display the page
$template->assign_vars(array(
'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'],

View File

@ -99,7 +99,7 @@ class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
WHERE item_type = '" . self::$notification_option['id'] . "'
AND " . $this->db->sql_in_set('user_id', $auth_approve[$post['forum_id']]['m_approve']);
AND " . $this->db->sql_in_set('user_id', $auth_approve[$post['forum_id']][$this->permission]);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{

View File

@ -1,85 +0,0 @@
<?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;
}
/**
* Post notifications class
* This class handles notifications for replies to a topic
*
* @package notifications
*/
class phpbb_notification_type_report extends phpbb_notification_type_post_in_queue
{
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'topic_notify';
/**
* Language key used to output the text
*
* @var string
*/
protected $language_key = 'NOTIFICATION_REPORT';
/**
* Permission to check for (in find_users_for_notification)
*
* @var string Permission name
*/
protected $permission = 'm_report';
/**
* Get the type of notification this is
* phpbb_notification_type_
*/
public static function get_item_type()
{
return 'report';
}
/**
* 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'))),
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
'U_VIEW_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}",
'U_NEWEST_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&view=unread#unread",
'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
'U_FORUM' => generate_board_url() . "/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}",
'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?uid={$this->user_id}&f={$this->get_data('forum_id')}&t={$this->item_parent_id}&unwatch=topic",
);
}
/**
* Get the url to this item
*
* @return string URL
*/
public function get_url()
{
return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "f={$this->get_data('forum_id')}&amp;p={$this->item_id}&amp;i=reports&amp;mode=report_details#reports");
}
}

View File

@ -0,0 +1,178 @@
<?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;
}
/**
* Private message notifications class
* This class handles notifications for reporting private messages
*
* @package notifications
*/
class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
{
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/report_post';
/**
* Permission to check for (in find_users_for_notification)
*
* @var string Permission name
*/
protected $permission = 'm_report';
/**
* Notification option data (for outputting to the user)
*
* @var bool|array False if the service should use it's default data
* Array of data (including keys 'id' and 'lang')
*/
public static $notification_option = array(
'id' => 'report',
'lang' => 'NOTIFICATION_TYPE_REPORT',
);
/**
* Get the type of notification this is
* phpbb_notification_type_
*/
public static function get_item_type()
{
return 'report_pm';
}
/**
* 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())
{
$options = array_merge(array(
'ignore_users' => array(),
), $options);
$auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']);
if (empty($auth_approve))
{
return array();
}
$notify_users = array();
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
WHERE item_type = '" . self::$notification_option['id'] . "'
AND " . $this->db->sql_in_set('user_id', $auth_approve[$post['forum_id']][$this->permission]);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if (isset($options['ignore_users'][$row['user_id']]) && in_array($row['method'], $options['ignore_users'][$row['user_id']]))
{
continue;
}
if (!isset($rowset[$row['user_id']]))
{
$notify_users[$row['user_id']] = array();
}
$notify_users[$row['user_id']][] = $row['method'];
}
$this->db->sql_freeresult($result);
return $notify_users;
}
/**
* Get email template variables
*
* @return array
*/
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')}&amp;p={$this->item_id}&amp;i=reports&amp;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')}",
);
}
/**
* Get the url to this item
*
* @return string URL
*/
public function get_url()
{
return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "f={$this->get_data('forum_id')}&amp;p={$this->item_id}&amp;i=reports&amp;mode=report_details#reports");
}
/**
* Get the HTML formatted title of this notification
*
* @return string
*/
public function get_title()
{
$this->user->add_lang('mcp');
if (isset($this->user->lang[$this->get_data('reason_title')]))
{
return $this->user->lang(
$this->language_key,
censor_text($this->get_data('post_subject')),
$this->user->lang[$this->get_data('reason_title')]
);
}
return $this->user->lang(
$this->language_key,
censor_text($this->get_data('post_subject')),
$this->get_data('reason_description')
);
}
/**
* 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('reason_title', strtoupper($post['reason_title']));
$this->set_data('reason_description', $post['reason_description']);
return parent::create_insert_array($post);
}
}

View File

@ -0,0 +1,139 @@
<?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 extends phpbb_notification_type_post_in_queue
{
/**
* Email template to use to send notifications
*
* @var string
*/
public $email_template = 'notifications/report_post';
/**
* Language key used to output the text
*
* @var string
*/
protected $language_key = 'NOTIFICATION_REPORT';
/**
* Permission to check for (in find_users_for_notification)
*
* @var string Permission name
*/
protected $permission = 'm_report';
/**
* Notification option data (for outputting to the user)
*
* @var bool|array False if the service should use it's default data
* Array of data (including keys 'id' and 'lang')
*/
public static $notification_option = array(
'id' => 'report',
'lang' => 'NOTIFICATION_TYPE_REPORT',
);
/**
* Get the type of notification this is
* phpbb_notification_type_
*/
public static function get_item_type()
{
return 'report_post';
}
/**
* Get email template variables
*
* @return array
*/
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')}&amp;p={$this->item_id}&amp;i=reports&amp;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')}",
);
}
/**
* Get the url to this item
*
* @return string URL
*/
public function get_url()
{
return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "f={$this->get_data('forum_id')}&amp;p={$this->item_id}&amp;i=reports&amp;mode=report_details#reports");
}
/**
* Get the HTML formatted title of this notification
*
* @return string
*/
public function get_title()
{
$this->user->add_lang('mcp');
if (isset($this->user->lang[$this->get_data('reason_title')]))
{
return $this->user->lang(
$this->language_key,
censor_text($this->get_data('post_subject')),
$this->user->lang[$this->get_data('reason_title')]
);
}
return $this->user->lang(
$this->language_key,
censor_text($this->get_data('post_subject')),
$this->get_data('reason_description')
);
}
/**
* 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('reason_title', strtoupper($post['reason_title']));
$this->set_data('reason_description', $post['reason_description']);
return parent::create_insert_array($post);
}
}

View File

@ -397,6 +397,7 @@ $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_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,17 @@
Subject: Topic reply notification - "{TOPIC_TITLE}"
Hello {USERNAME},
You are receiving this notification because the post, "{POST_SUBJECT}" at "{SITENAME}" was reported.
If you want to view the report, click the following link:
{U_VIEW_REPORT}
If you want to view the post, click the following link:
{U_VIEW_POST}
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

@ -298,6 +298,7 @@ $lang = array_merge($lang, array(
'NOTIFICATION_TYPE_PM' => 'Someone sends you a private message',
'NOTIFICATION_TYPE_POST' => 'Someone replies to a topic you are subscribed to',
'NOTIFICATION_TYPE_QUOTE' => 'Someone quotes you in a post',
'NOTIFICATION_TYPE_REPORT' => 'Someone reports a post',
'NOTIFICATION_TYPE_TOPIC' => 'Someone creates a topic in a forum you are subscribed to',
'NOTIFY_METHOD' => 'Notification method',

View File

@ -131,7 +131,7 @@ else
$message .= '<br /><br />' . sprintf($user->lang['RETURN_PM'], '<a href="' . $redirect_url . '">', '</a>');
trigger_error($message);
}
$reported_post_text = $report_data['message_text'];
}
@ -184,6 +184,9 @@ if ($submit && $reason_id)
$lang_return = $user->lang['RETURN_TOPIC'];
$lang_success = $user->lang['POST_REPORTED_SUCCESS'];
// Notify relevant users
$phpbb_notifications->add_notifications('report_post', array_merge($report_data, $row, $forum_data));
}
else
{
@ -210,6 +213,9 @@ if ($submit && $reason_id)
$lang_return = $user->lang['RETURN_PM'];
$lang_success = $user->lang['PM_REPORTED_SUCCESS'];
// Notify relevant users
//$phpbb_notifications->add_notifications('report_pm', $report_data);
}
meta_refresh(3, $redirect_url);