Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
CalendarItem.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Entity\Calendar
;
4
5
use Bitrix\Im\V2\Common\ContextCustomer;
6
use
Bitrix\Im\V2\Rest\RestEntity
;
7
use
Bitrix\Im\V2\Service\Context
;
8
use
Bitrix\Im\V2\Service\Locator
;
9
use
Bitrix\Main\Type\DateTime
;
10
use CCalendar;
11
use CCalendarEvent;
12
13
class
CalendarItem
implements
RestEntity
14
{
15
use ContextCustomer;
16
17
protected
?
int
$id
;
18
protected
int
$ownerId
;
19
protected
int
$createdBy
;
20
protected
string
$title
;
21
protected
string
$type
;
22
protected
DateTime
$dateFrom
;
23
protected
DateTime
$dateTo
;
24
protected
array
$membersIds
;
25
26
public
static
function
getRestEntityName
(): string
27
{
28
return
'calendar'
;
29
}
30
31
public
static
function
initByGetListArray
(array $calendarInfo): self
32
{
33
$calendar =
new
static
();
34
35
if
($calendarInfo[
'DT_SKIP_TIME'
] ===
'Y'
)
36
{
37
$calendarSettings = CCalendar::GetSettings([
'getDefaultForEmpty'
=>
false
]);
38
$workTimeStart = explode(
'.'
, $calendarSettings[
'work_time_start'
]);
39
$workTimeEnd = explode(
'.'
, $calendarSettings[
'work_time_end'
]);
40
$dateFrom
=
new
DateTime
($calendarInfo[
'DATE_FROM'
]);
41
$dateTo
=
new
DateTime
($calendarInfo[
'DATE_TO'
]);
42
$dateFrom
->
setTime
((
int
)$workTimeStart[0], (
int
)($workTimeStart[1] ?? 0));
43
$dateTo
->
setTime
((
int
)$workTimeEnd[0], (
int
)($workTimeEnd[1] ?? 0));
44
}
45
else
46
{
47
$dateFrom
=
DateTime::createFromTimestamp
($calendarInfo[
'DATE_FROM_TS_UTC'
] + (
int
)date(
'Z'
));
48
$dateTo
=
DateTime::createFromTimestamp
($calendarInfo[
'DATE_TO_TS_UTC'
] + (
int
)date(
'Z'
));
49
}
50
$calendar
51
->setId($calendarInfo[
'ID'
])
52
->setTitle($calendarInfo[
'NAME'
])
53
->setType($calendarInfo[
'CAL_TYPE'
])
54
->setOwnerId((
int
)$calendarInfo[
'OWNER_ID'
])
55
->setCreatedBy((
int
)$calendarInfo[
'CREATED_BY'
])
56
->setDateFrom(
$dateFrom
)
57
->setDateTo(
$dateTo
)
58
->setMembersIds(array_map(
'intval'
, array_column($calendarInfo[
'ATTENDEE_LIST'
],
'id'
)))
59
;
60
61
return
$calendar;
62
}
63
64
public
static
function
initById
(
int
$id
, ?
Context
$context =
null
): self
65
{
66
$context = $context ?? Locator::getContext();
67
$checkPermissions =
false
;
68
69
$calendarGetList = CCalendarEvent::GetList([
70
'arFilter'
=> [
71
'ID'
=>
$id
,
72
'DELETED'
=>
false
,
73
],
74
'parseRecursion'
=>
false
,
75
'fetchAttendees'
=>
true
,
76
'userId'
=> $context->getUserId(),
77
'fetchMeetings'
=>
false
,
78
'setDefaultLimit'
=>
false
,
79
'checkPermissions'
=> $checkPermissions,
80
]);
81
82
return
static::initByGetListArray($calendarGetList[0]);
83
}
84
85
public
function
toRestFormat
(array $option = []): array
86
{
87
return
[
88
'id'
=> $this->
getId
(),
89
'title'
=> $this->
getTitle
(),
90
'dateFrom'
=> $this->
getDateFrom
()->format(
'c'
),
91
'dateTo'
=> $this->
getDateTo
()->format(
'c'
),
92
'source'
=> $this->
getUrl
(),
93
];
94
}
95
96
public
function
getUrl
(): string
97
{
98
return
CCalendar::GetPath($this->
getType
(), $this->
getOwnerId
()) .
'?EVENT_ID='
. $this->
getId
();
99
}
100
101
//region Getters & setters
102
103
public
function
getId
(): int
104
{
105
return
$this->id
;
106
}
107
108
public
function
setId
(?
int
$id
):
CalendarItem
109
{
110
$this->
id
=
$id
;
111
return
$this;
112
}
113
114
public
function
getTitle
(): string
115
{
116
return
$this->title
;
117
}
118
119
public
function
setTitle
(
string
$title
):
CalendarItem
120
{
121
$this->title =
$title
;
122
return
$this;
123
}
124
125
public
function
getDateFrom
():
DateTime
126
{
127
return
$this->dateFrom
;
128
}
129
130
public
function
setDateFrom
(
DateTime
$dateFrom
):
CalendarItem
131
{
132
$this->dateFrom =
$dateFrom
;
133
return
$this;
134
}
135
136
public
function
getDateTo
():
DateTime
137
{
138
return
$this->dateTo
;
139
}
140
141
public
function
setDateTo
(
DateTime
$dateTo
):
CalendarItem
142
{
143
$this->dateTo =
$dateTo
;
144
return
$this;
145
}
146
147
public
function
getOwnerId
(): int
148
{
149
return
$this->ownerId
;
150
}
151
152
public
function
setOwnerId
(
int
$ownerId
):
CalendarItem
153
{
154
$this->ownerId =
$ownerId
;
155
return
$this;
156
}
157
158
public
function
getCreatedBy
(): int
159
{
160
return
$this->createdBy
;
161
}
162
163
public
function
setCreatedBy
(
int
$createdBy
):
CalendarItem
164
{
165
$this->createdBy =
$createdBy
;
166
return
$this;
167
}
168
169
public
function
getType
(): string
170
{
171
return
$this->type
;
172
}
173
174
public
function
setType
(
string
$type
):
CalendarItem
175
{
176
$this->type =
$type
;
177
return
$this;
178
}
179
183
public
function
getMembersIds
(): array
184
{
185
return
$this->membersIds
;
186
}
187
191
public
function
setMembersIds
(array
$membersIds
):
CalendarItem
192
{
193
$this->membersIds = array_unique(
$membersIds
);
194
return
$this;
195
}
196
197
//endregion
198
}
Bitrix\Im\V2\Entity\Calendar\CalendarItem
Definition
CalendarItem.php:14
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setId
setId(?int $id)
Definition
CalendarItem.php:108
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getRestEntityName
static getRestEntityName()
Definition
CalendarItem.php:26
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setOwnerId
setOwnerId(int $ownerId)
Definition
CalendarItem.php:152
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getMembersIds
getMembersIds()
Definition
CalendarItem.php:183
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getId
getId()
Definition
CalendarItem.php:103
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$createdBy
int $createdBy
Definition
CalendarItem.php:19
Bitrix\Im\V2\Entity\Calendar\CalendarItem\toRestFormat
toRestFormat(array $option=[])
Definition
CalendarItem.php:85
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$id
int $id
Definition
CalendarItem.php:17
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getCreatedBy
getCreatedBy()
Definition
CalendarItem.php:158
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$title
string $title
Definition
CalendarItem.php:20
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setTitle
setTitle(string $title)
Definition
CalendarItem.php:119
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getDateFrom
getDateFrom()
Definition
CalendarItem.php:125
Bitrix\Im\V2\Entity\Calendar\CalendarItem\initById
static initById(int $id, ?Context $context=null)
Definition
CalendarItem.php:64
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getType
getType()
Definition
CalendarItem.php:169
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$dateTo
DateTime $dateTo
Definition
CalendarItem.php:23
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setCreatedBy
setCreatedBy(int $createdBy)
Definition
CalendarItem.php:163
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getTitle
getTitle()
Definition
CalendarItem.php:114
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setMembersIds
setMembersIds(array $membersIds)
Definition
CalendarItem.php:191
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$type
string $type
Definition
CalendarItem.php:21
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getDateTo
getDateTo()
Definition
CalendarItem.php:136
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getOwnerId
getOwnerId()
Definition
CalendarItem.php:147
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setDateFrom
setDateFrom(DateTime $dateFrom)
Definition
CalendarItem.php:130
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$ownerId
int $ownerId
Definition
CalendarItem.php:18
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setDateTo
setDateTo(DateTime $dateTo)
Definition
CalendarItem.php:141
Bitrix\Im\V2\Entity\Calendar\CalendarItem\getUrl
getUrl()
Definition
CalendarItem.php:96
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$dateFrom
DateTime $dateFrom
Definition
CalendarItem.php:22
Bitrix\Im\V2\Entity\Calendar\CalendarItem\initByGetListArray
static initByGetListArray(array $calendarInfo)
Definition
CalendarItem.php:31
Bitrix\Im\V2\Entity\Calendar\CalendarItem\$membersIds
array $membersIds
Definition
CalendarItem.php:24
Bitrix\Im\V2\Entity\Calendar\CalendarItem\setType
setType(string $type)
Definition
CalendarItem.php:174
Bitrix\Im\V2\Service\Context
Definition
Context.php:8
Bitrix\Im\V2\Service\Locator
Definition
Locator.php:8
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\Type\DateTime\createFromTimestamp
static createFromTimestamp($timestamp)
Definition
datetime.php:246
Bitrix\Main\Type\DateTime\setTime
setTime($hour, $minute, $second=0, $microseconds=0)
Definition
datetime.php:144
Bitrix\Im\V2\Rest\RestEntity
Definition
RestEntity.php:8
Bitrix\Im\V2\Entity\Calendar
Definition
CalendarCollection.php:3
modules
im
lib
V2
Entity
Calendar
CalendarItem.php
Создано системой
1.10.0