PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.5
2.4.5 2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 All 69 releases
fluent-support / app / Services / Notifications / MentionParser.php

MentionParser.php in Fluent Support – Helpdesk & Customer Support Ticket System 2.4.5, at app/Services/Notifications/MentionParser.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Services\Notifications;
4
5 class MentionParser
6 {
7 /**
8 * Agent IDs mentioned in the content, in either format:
9 * - Rich editor: <span class="fs_agent_mention" data-mention-username="7">
10 * - Plain-text editor: @[7:Display Name]
11 *
12 * @param string $content
13 * @return array Integer agent IDs.
14 */
15 public function extractMentionIds($content)
16 {
17 $content = (string) $content;
18
19 if (!$content) {
20 return [];
21 }
22
23 $ids = [];
24
25 if (stripos($content, 'data-mention-username') !== false) {
26 preg_match_all(
27 '/<span\b[^>]*\bclass=["\'][^"\']*\bfs_agent_mention\b[^"\']*["\'][^>]*\bdata-mention-username=["\'](\d+)["\'][^>]*>/i',
28 $content,
29 $spanMatches
30 );
31
32 foreach ($spanMatches[1] ?? [] as $id) {
33 $ids[] = (int) $id;
34 }
35 }
36
37 if (strpos($content, '@[') !== false) {
38 preg_match_all('/@\[(\d+):[^\]]+\]/', $content, $tokenMatches);
39
40 foreach ($tokenMatches[1] ?? [] as $id) {
41 $ids[] = (int) $id;
42 }
43 }
44
45 return array_values(array_unique(array_filter($ids)));
46 }
47 }
48