mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-18 14:31:19 +02:00
[ticket/13680] Updated quote notifications
Added get_quote_authors() to text_formatter.utils service to retrieve the names used in first-level quotes PHPBB3-13680
This commit is contained in:
@@ -20,6 +20,11 @@ namespace phpbb\notification\type;
|
||||
|
||||
class quote extends \phpbb\notification\type\post
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\textformatter\utils_interface
|
||||
*/
|
||||
protected $utils;
|
||||
|
||||
/**
|
||||
* Get notification type name
|
||||
*
|
||||
@@ -30,13 +35,6 @@ class quote extends \phpbb\notification\type\post
|
||||
return 'notification.type.quote';
|
||||
}
|
||||
|
||||
/**
|
||||
* regular expression to match to find usernames
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $regular_expression_match = '#\[quote="(.+?)"#';
|
||||
|
||||
/**
|
||||
* Language key used to output the text
|
||||
*
|
||||
@@ -77,17 +75,16 @@ class quote extends \phpbb\notification\type\post
|
||||
'ignore_users' => array(),
|
||||
), $options);
|
||||
|
||||
$usernames = false;
|
||||
preg_match_all(self::$regular_expression_match, $post['post_text'], $usernames);
|
||||
$usernames = $this->utils->get_quote_authors($post['post_text']);
|
||||
|
||||
if (empty($usernames[1]))
|
||||
if (empty($usernames))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$usernames[1] = array_unique($usernames[1]);
|
||||
$usernames = array_unique($usernames);
|
||||
|
||||
$usernames = array_map('utf8_clean_string', $usernames[1]);
|
||||
$usernames = array_map('utf8_clean_string', $usernames);
|
||||
|
||||
$users = array();
|
||||
|
||||
@@ -187,4 +184,14 @@ class quote extends \phpbb\notification\type\post
|
||||
'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the utils service used to retrieve quote authors
|
||||
*
|
||||
* @param \phpbb\textformatter\utils_interface $utils
|
||||
*/
|
||||
public function set_utils(\phpbb\textformatter\utils_interface $utils)
|
||||
{
|
||||
$this->utils = $utils;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user