[ticket/13713] Remove unneeded code in helper

PHPBB3-13713
This commit is contained in:
lavigor 2018-08-06 14:17:34 +03:00 committed by Marc Alexander
parent d91e3bd66a
commit 89d65f5da0
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 10 additions and 26 deletions

View file

@ -75,7 +75,7 @@ class mention extends \phpbb\notification\type\post
'ignore_users' => array(), 'ignore_users' => array(),
), $options); ), $options);
$user_ids = $this->helper->get_mentioned_ids($post['post_text']); $user_ids = $this->helper->get_mentioned_user_ids($post['post_text']);
$user_ids = array_unique($user_ids); $user_ids = array_unique($user_ids);

View file

@ -242,14 +242,12 @@ class mention_helper
} }
/** /**
* Get a list of mentioned names * Get a list of mentioned user IDs
* *
* @param string $xml Parsed text * @param string $xml Parsed text
* @param string $type Name type ('u' for users, 'g' for groups, * @return int[] List of user IDs
* 'ug' for usernames mentioned separately or as group members)
* @return int[] List of IDs
*/ */
public function get_mentioned_ids($xml, $type = 'ug') public function get_mentioned_user_ids($xml)
{ {
$ids = array(); $ids = array();
if (strpos($xml, '<MENTION ') === false) if (strpos($xml, '<MENTION ') === false)
@ -261,8 +259,6 @@ class mention_helper
$dom->loadXML($xml); $dom->loadXML($xml);
$xpath = new \DOMXPath($dom); $xpath = new \DOMXPath($dom);
if ($type === 'ug')
{
/** @var \DOMElement $mention */ /** @var \DOMElement $mention */
foreach ($xpath->query('//MENTION') as $mention) foreach ($xpath->query('//MENTION') as $mention)
{ {
@ -275,18 +271,6 @@ class mention_helper
$this->get_user_ids_for_group($ids, (int) $mention->getAttribute('id')); $this->get_user_ids_for_group($ids, (int) $mention->getAttribute('id'));
} }
} }
}
else
{
/** @var \DOMElement $mention */
foreach ($xpath->query('//MENTION') as $mention)
{
if ($mention->getAttribute('type') === $type)
{
$ids[] = (int) $mention->getAttribute('id');
}
}
}
return $ids; return $ids;
} }