mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/16208] Fix posts/PM report notifications
PHPBB3-16208
This commit is contained in:
@@ -60,11 +60,11 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
* @var bool|array False if the service should use it's default data
|
||||
* Array of data (including keys 'id', 'lang', and 'group')
|
||||
*/
|
||||
static public $notification_option = array(
|
||||
'id' => 'notification.type.report',
|
||||
'lang' => 'NOTIFICATION_TYPE_REPORT',
|
||||
static public $notification_option = [
|
||||
'id' => 'notification.type.report_pm',
|
||||
'lang' => 'NOTIFICATION_TYPE_REPORT_PM',
|
||||
'group' => 'NOTIFICATION_GROUP_MODERATION',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the id of the parent
|
||||
@@ -84,9 +84,8 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
*/
|
||||
public function is_available()
|
||||
{
|
||||
$m_approve = $this->auth->acl_getf($this->permission, true);
|
||||
|
||||
return (!empty($m_approve));
|
||||
return !empty($this->auth->acl_get($this->permission)) &&
|
||||
$this->config['allow_pm_report'];
|
||||
}
|
||||
|
||||
|
||||
@@ -99,11 +98,11 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function find_users_for_notification($post, $options = array())
|
||||
public function find_users_for_notification($post, $options = [])
|
||||
{
|
||||
$options = array_merge(array(
|
||||
'ignore_users' => array(),
|
||||
), $options);
|
||||
$options = array_merge([
|
||||
'ignore_users' => [],
|
||||
], $options);
|
||||
|
||||
// Global
|
||||
$post['forum_id'] = 0;
|
||||
@@ -112,7 +111,7 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
|
||||
if (empty($auth_approve))
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (($key = array_search($this->user->data['user_id'], $auth_approve[$post['forum_id']][$this->permission])))
|
||||
@@ -120,9 +119,9 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
unset($auth_approve[$post['forum_id']][$this->permission][$key]);
|
||||
}
|
||||
|
||||
return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, array(
|
||||
return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, [
|
||||
'item_type' => static::$notification_option['id'],
|
||||
)));
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +143,7 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
{
|
||||
$user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
|
||||
|
||||
return array(
|
||||
return [
|
||||
'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
|
||||
'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
|
||||
|
||||
@@ -152,7 +151,7 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
'TOPIC_TITLE' => 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",
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,15 +238,16 @@ class report_pm extends \phpbb\notification\type\pm
|
||||
*/
|
||||
public function users_to_query()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
$this->get_data('from_user_id'),
|
||||
$this->get_data('reporter_id'),
|
||||
); }
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function create_insert_array($post, $pre_create_data = array())
|
||||
public function create_insert_array($post, $pre_create_data = [])
|
||||
{
|
||||
$this->set_data('reporter_id', $this->user->data['user_id']);
|
||||
$this->set_data('reason_title', strtoupper($post['reason_title']));
|
||||
|
@@ -35,18 +35,30 @@ class report_pm_closed extends \phpbb\notification\type\pm
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $email_template = '';
|
||||
public $email_template = 'report_pm_closed';
|
||||
|
||||
/**
|
||||
* Language key used to output the text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $language_key = 'NOTIFICATION_REPORT_CLOSED';
|
||||
protected $language_key = 'NOTIFICATION_REPORT_PM_CLOSED';
|
||||
|
||||
/**
|
||||
* 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', 'lang', and 'group')
|
||||
*/
|
||||
static public $notification_option = [
|
||||
'id' => 'notification.type.report_pm_closed',
|
||||
'lang' => 'NOTIFICATION_TYPE_REPORT_PM_CLOSED',
|
||||
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
|
||||
];
|
||||
|
||||
public function is_available()
|
||||
{
|
||||
return false;
|
||||
return (bool) $this->config['allow_pm_report'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,14 +69,18 @@ class report_pm_closed extends \phpbb\notification\type\pm
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function find_users_for_notification($pm, $options = array())
|
||||
public function find_users_for_notification($pm, $options = [])
|
||||
{
|
||||
$options = array_merge([
|
||||
'ignore_users' => [],
|
||||
], $options);
|
||||
|
||||
if ($pm['reporter'] == $this->user->data['user_id'])
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return array($pm['reporter'] => $this->notification_manager->get_default_methods());
|
||||
return $this->check_user_notification_options([$pm['reporter']], $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +90,7 @@ class report_pm_closed extends \phpbb\notification\type\pm
|
||||
*/
|
||||
public function get_email_template()
|
||||
{
|
||||
return false;
|
||||
return $this->email_template;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,17 +100,16 @@ class report_pm_closed extends \phpbb\notification\type\pm
|
||||
*/
|
||||
public function get_email_template_variables()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
$sender_data = $this->user_loader->get_user($this->get_data('from_user_id'));
|
||||
$closer_data = $this->user_loader->get_user($this->get_data('closer_id'));
|
||||
|
||||
/**
|
||||
* Get the url to this item
|
||||
*
|
||||
* @return string URL
|
||||
*/
|
||||
public function get_url()
|
||||
{
|
||||
return '';
|
||||
return [
|
||||
'AUTHOR_NAME' => htmlspecialchars_decode($sender_data['username']),
|
||||
'CLOSER_NAME' => htmlspecialchars_decode($closer_data['username']),
|
||||
'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
|
||||
|
||||
'U_VIEW_MESSAGE'=> generate_board_url() . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$this->item_id}",
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,13 +155,13 @@ class report_pm_closed extends \phpbb\notification\type\pm
|
||||
*/
|
||||
public function users_to_query()
|
||||
{
|
||||
return array($this->get_data('closer_id'));
|
||||
return [$this->get_data('closer_id')];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function create_insert_array($pm, $pre_create_data = array())
|
||||
public function create_insert_array($pm, $pre_create_data = [])
|
||||
{
|
||||
$this->set_data('closer_id', $pm['closer_id']);
|
||||
|
||||
|
Reference in New Issue
Block a user