Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
taskcomment.php
1<?php
3
6
8{
9 protected static $viewedCommentsCache = [];
10
11 private static function addViewedComment($params = [])
12 {
13 if (!is_array($params))
14 {
15 return false;
16 }
17
18 $taskId = (isset($params['taskId']) ? intval($params['taskId']) : 0);
19 $commentId = (isset($params['commentId']) ? intval($params['commentId']) : 0);
20 if (
21 !$taskId
22 || !$commentId
23 )
24 {
25 return false;
26 }
27
28 if (!isset(self::$viewedCommentsCache[$taskId]))
29 {
30 self::$viewedCommentsCache[$taskId] = [];
31 }
32
33 if (in_array($commentId, self::$viewedCommentsCache[$taskId]))
34 {
35 return true;
36 }
37
38 self::$viewedCommentsCache[$taskId][] = $commentId;
39
40 return true;
41 }
42
43 public static function getViewedCommentsTasksList()
44 {
45 return array_keys(self::$viewedCommentsCache);
46 }
47
48 public static function onViewed(Event $event)
49 {
50 $result = new EventResult(
51 EventResult::UNDEFINED,
52 [],
53 'socialnetwork'
54 );
55
56 $taskId = $event->getParameter('taskId');
57 $commentId = $event->getParameter('commentId');
58
59 if(
60 intval($taskId) <= 0
61 || intval($commentId) <= 0
62 )
63 {
64 return $result;
65 }
66
67 self::addViewedComment([
68 'taskId' => $taskId,
69 'commentId' => $commentId
70 ]);
71
72 return $result;
73 }
74}
getParameter($key)
Definition event.php:80