Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
calendarevent.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Livefeed
;
4
5
use
Bitrix\Main\Config\Option
;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Main\Localization\Loc
;
8
9
Loc::loadMessages
(__FILE__);
10
11
final
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
{
30
return
Provider::TYPE_POST
;
31
}
32
33
public
static
function
canRead
($params): bool
34
{
35
return
true
;
36
}
37
38
protected
function
getPermissions
(array $post): string
39
{
40
return
self::PERMISSION_READ
;
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
}
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Socialnetwork\Livefeed\CalendarEvent
Definition
calendarevent.php:12
Bitrix\Socialnetwork\Livefeed\CalendarEvent\initSourceFields
initSourceFields()
Definition
calendarevent.php:48
Bitrix\Socialnetwork\Livefeed\CalendarEvent\getCommentProvider
getCommentProvider()
Definition
calendarevent.php:43
Bitrix\Socialnetwork\Livefeed\CalendarEvent\CONTENT_TYPE_ID
const CONTENT_TYPE_ID
Definition
calendarevent.php:14
Bitrix\Socialnetwork\Livefeed\CalendarEvent\getPinnedTitle
getPinnedTitle()
Definition
calendarevent.php:95
Bitrix\Socialnetwork\Livefeed\CalendarEvent\getPermissions
getPermissions(array $post)
Definition
calendarevent.php:38
Bitrix\Socialnetwork\Livefeed\CalendarEvent\getType
getType()
Definition
calendarevent.php:28
Bitrix\Socialnetwork\Livefeed\CalendarEvent\getLiveFeedUrl
getLiveFeedUrl()
Definition
calendarevent.php:115
Bitrix\Socialnetwork\Livefeed\CalendarEvent\getEventId
getEventId()
Definition
calendarevent.php:23
Bitrix\Socialnetwork\Livefeed\CalendarEvent\canRead
static canRead($params)
Definition
calendarevent.php:33
Bitrix\Socialnetwork\Livefeed\CalendarEvent\getId
static getId()
Definition
calendarevent.php:18
Bitrix\Socialnetwork\Livefeed\CalendarEvent\PROVIDER_ID
const PROVIDER_ID
Definition
calendarevent.php:13
Bitrix\Socialnetwork\Livefeed\CalendarEvent\$calendarEventClass
static $calendarEventClass
Definition
calendarevent.php:16
Bitrix\Socialnetwork\Livefeed\ForumPost
Definition
forumpost.php:22
Bitrix\Socialnetwork\Livefeed\Provider
Definition
provider.php:22
Bitrix\Socialnetwork\Livefeed\Provider\setSourceFields
setSourceFields(array $fields)
Definition
provider.php:627
Bitrix\Socialnetwork\Livefeed\Provider\setSourceTitle
setSourceTitle($title)
Definition
provider.php:665
Bitrix\Socialnetwork\Livefeed\Provider\getAttachedDiskObjects
getAttachedDiskObjects($clone=false)
Definition
provider.php:784
Bitrix\Socialnetwork\Livefeed\Provider\setSourceDiskObjects
setSourceDiskObjects(array $files)
Definition
provider.php:744
Bitrix\Socialnetwork\Livefeed\Provider\PERMISSION_READ
const PERMISSION_READ
Definition
provider.php:47
Bitrix\Socialnetwork\Livefeed\Provider\getSourceFields
getSourceFields()
Definition
provider.php:637
Bitrix\Socialnetwork\Livefeed\Provider\setSourceAttachedDiskObjects
setSourceAttachedDiskObjects(array $diskAttachedObjects)
Definition
provider.php:739
Bitrix\Socialnetwork\Livefeed\Provider\TYPE_POST
const TYPE_POST
Definition
provider.php:25
Bitrix\Socialnetwork\Livefeed\Provider\setSourceDescription
setSourceDescription($description)
Definition
provider.php:642
Bitrix\Socialnetwork\Livefeed\Provider\$entityId
$entityId
Definition
provider.php:52
Bitrix\Socialnetwork\Livefeed\Provider\getDiskObjects
getDiskObjects($entityId, $clone=false)
Definition
provider.php:822
Bitrix\Socialnetwork\Livefeed
Definition
bitrix24newuser.php:3
modules
socialnetwork
lib
livefeed
calendarevent.php
Создано системой
1.10.0