PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.0
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.0
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 1.5.5 All 68 releases
fluent-support / app / Services / Notifications / MentionParser.php

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

52 lines 1.4 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 * Extract agent IDs from message content.
9 *
10 * Handles two mention formats:
11 * - Rich editor: <span class="fs_agent_mention" data-mention-username="7">
12 * - Plain-text editor: @[7:Display Name]
13 *
14 * @param string $content
15 * @return array Integer agent IDs.
16 */
17 public function extractMentionIds($content)
18 {
19 $content = (string) $content;
20
21 if (!$content) {
22 return [];
23 }
24
25 $ids = [];
26
27 // Rich editor — span with numeric data-mention-username.
28 if (stripos($content, 'data-mention-username') !== false) {
29 preg_match_all(
30 '/<span\b[^>]*\bclass=["\'][^"\']*\bfs_agent_mention\b[^"\']*["\'][^>]*\bdata-mention-username=["\'](\d+)["\'][^>]*>/i',
31 $content,
32 $spanMatches
33 );
34
35 foreach ($spanMatches[1] ?? [] as $id) {
36 $ids[] = (int) $id;
37 }
38 }
39
40 // Plain-text editor — @[agentId:Display Name] token.
41 if (strpos($content, '@[') !== false) {
42 preg_match_all('/@\[(\d+):[^\]]+\]/', $content, $tokenMatches);
43
44 foreach ($tokenMatches[1] ?? [] as $id) {
45 $ids[] = (int) $id;
46 }
47 }
48
49 return array_values(array_unique(array_filter($ids)));
50 }
51 }
52