Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
calendarevent.php
1<?php
2
4
8
9Loc::loadMessages(__FILE__);
10
11final class CalendarEvent extends Provider
12{
13 public const PROVIDER_ID = 'CALENDAR';
14 public const CONTENT_TYPE_ID = 'CALENDAR_EVENT';
15
16 protected static $calendarEventClass = \CCalendarEvent::class;
17
18 public static function getId(): string
19 {
20 return static::PROVIDER_ID;
21 }
22
23 public function getEventId(): array
24 {
25 return [ 'calendar' ];
26 }
27
28 public function getType(): string
29 {
31 }
32
33 public static function canRead($params): bool
34 {
35 return true;
36 }
37
38 protected function getPermissions(array $post): string
39 {
41 }
42
43 public function getCommentProvider(): Provider
44 {
45 return new ForumPost();
46 }
47
48 public function initSourceFields()
49 {
50 static $cache = [];
51
52 $calendarEventId = $this->entityId;
53
54 if ($calendarEventId <= 0)
55 {
56 return;
57 }
58
59 $calendarEvent = [];
60
61 if (isset($cache[$calendarEventId]))
62 {
63 $calendarEvent = $cache[$calendarEventId];
64 }
65 elseif (Loader::includeModule('calendar'))
66 {
67 $res = self::$calendarEventClass::getList(
68 [
69 'arFilter' => [
70 "ID" => $calendarEventId,
71 ],
72 'parseRecursion' => false,
73 'fetchAttendees' => false,
74 'checkPermissions' => false,
75 'setDefaultLimit' => false
76 ]
77 );
78
79 $calendarEvent = is_array($res) && is_array($res[0]) ? $res[0] : [];
80 $cache[$calendarEventId] = $calendarEvent;
81 }
82
83 if (empty($calendarEvent))
84 {
85 return;
86 }
87
88 $this->setSourceFields($calendarEvent);
89 $this->setSourceDescription($calendarEvent['DESCRIPTION']);
90 $this->setSourceTitle($calendarEvent['NAME']);
91 $this->setSourceAttachedDiskObjects($this->getAttachedDiskObjects($this->cloneDiskObjects));
92 $this->setSourceDiskObjects($this->getDiskObjects($calendarEventId, $this->cloneDiskObjects));
93 }
94
95 public function getPinnedTitle(): string
96 {
97 $result = '';
98
99 if (empty($this->sourceFields))
100 {
101 $this->initSourceFields();
102 }
103
104 $calendarEvent = $this->getSourceFields();
105 if (empty($calendarEvent))
106 {
107 return $result;
108 }
109
110 return Loc::getMessage('SONET_LIVEFEED_CALENDAR_EVENT_PINNED_TITLE', [
111 '#TITLE#' => $calendarEvent['NAME']
112 ]);
113 }
114
115 public function getLiveFeedUrl(): string
116 {
117 $pathToCalendarEvent = '';
118 $userPage = Option::get('socialnetwork', 'user_page', '', SITE_ID);
119 if (
120 !empty($userPage)
121 && ($calendarEvent = $this->getSourceFields())
122 && !empty($calendarEvent)
123 )
124 {
125 $pathToCalendarEvent = \CComponentEngine::makePathFromTemplate($userPage."user/#user_id#/calendar/?EVENT_ID=#event_id#", [
126 "user_id" => $calendarEvent["CREATED_BY"],
127 "event_id" => $calendarEvent["ID"]
128 ]);
129 }
130
131 return $pathToCalendarEvent;
132 }
133}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
Definition forumpost.php:22
setSourceAttachedDiskObjects(array $diskAttachedObjects)
Definition provider.php:739
getDiskObjects($entityId, $clone=false)
Definition provider.php:822