Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
contentviewhandler.php
1<?php
2
4
6
14{
15 const CONTENT_TYPE_ID_POST = 'BLOG_POST';
16 const CONTENT_TYPE_ID_COMMENT = 'BLOG_COMMENT';
17
18 final public static function getContentTypeIdList()
19 {
20 return array(
21 self::CONTENT_TYPE_ID_POST,
22 self::CONTENT_TYPE_ID_COMMENT
23 );
24 }
25
32 public static function onContentViewed(\Bitrix\Main\Event $event)
33 {
34 $userId = intval($event->getParameter('userId'));
35 $contentTypeId = $event->getParameter('typeId');
36 $contentEntityId = intval($event->getParameter('entityId'));
37
38 if (
39 $userId <= 0
40 || !in_array($contentTypeId, self::getContentTypeIdList())
41 || $contentEntityId <= 0
42 || !Loader::includeModule('im')
43 )
44 {
45 return false;
46 }
47
48 $subTagList = array();
49
50 if ($contentTypeId == self::CONTENT_TYPE_ID_POST)
51 {
52 $subTagList[] = "BLOG|POST|".$contentEntityId.'|'.$userId;
53 $subTagList[] = "BLOG|POST_MENTION|".$contentEntityId.'|'.$userId;
54 }
55 elseif ($contentTypeId == self::CONTENT_TYPE_ID_COMMENT)
56 {
57 $subTagList[] = "BLOG|COMMENT|".$contentEntityId.'|'.$userId;
58 $subTagList[] = "BLOG|COMMENT_MENTION|".$contentEntityId.'|'.$userId;
59 }
60
61 if (!empty($subTagList))
62 {
63 $CIMNotify = new \CIMNotify();
64 $CIMNotify->MarkNotifyReadBySubTag($subTagList);
65 }
66
67 return true;
68 }
69}