3namespace Bitrix\Calendar\Core\Builders;
5use Bitrix\Calendar\Core\Base\BaseException;
6use Bitrix\Calendar\Core\Base\DateTimeZone;
7use Bitrix\Calendar\Core\Event;
8use Bitrix\Calendar\Core\Event\Properties\AttendeeCollection;
9use Bitrix\Calendar\Core\Base\Date;
10use Bitrix\Calendar\Core\Event\Properties\Location;
11use Bitrix\Calendar\Core\Event\Properties\MeetingDescription;
12use Bitrix\Calendar\Core\Event\Properties\RecurringEventRules;
13use Bitrix\Calendar\Core\Event\Properties\Relations;
14use Bitrix\Calendar\Core\Event\Properties\RemindCollection;
15use Bitrix\Calendar\Core\eventoption\EventOption;
16use Bitrix\Calendar\Core\Mappers\Factory;
17use Bitrix\Calendar\Core\Role\Helper;
18use Bitrix\Calendar\Core\Role\Role;
19use Bitrix\Calendar\Core\Role\User;
20use Bitrix\Calendar\Core\Section\Section;
21use Bitrix\Calendar\Util;
22use Bitrix\Main\ArgumentException;
23use Bitrix\Main\DI\ServiceLocator;
24use Bitrix\Main\ObjectException;
25use Bitrix\Main\ObjectPropertyException;
26use Bitrix\Main\SystemException;
44 $this->prepareRecurrenceRuleField();
47 private function prepareRecurrenceRuleField(): void
49 if (!empty($this->fields[
'RRULE']) && is_string($this->fields[
'RRULE']))
52 foreach (explode(
';', $this->fields[
'RRULE']) as $item) {
55 [
$key, $value] = explode(
'=', $item);
59 $this->fields[
'RRULE'] =
$result;
68 return $this->fields[
'NAME'] ??
'';
76 if (!isset($this->fields[
'TZ_FROM']))
89 if (!isset($this->fields[
'TZ_TO']))
104 if (!empty($this->fields[
'RRULE']))
106 if (is_string($this->fields[
'RRULE']))
108 $this->fields[
'RRULE'] = \CCalendarEvent::convertDateToCulture($this->fields[
'RRULE']);
110 elseif (is_array($this->fields[
'RRULE']) && !empty($this->fields[
'RRULE'][
'UNTIL']))
112 $this->fields[
'RRULE'][
'UNTIL'] = \CCalendarEvent::convertDateToCulture($this->fields[
'RRULE'][
'UNTIL']);
139 $this->fields[
'DATE_FROM'] ??
null,
141 $this->fields[
'TZ_FROM'] ??
null
154 $this->fields[
'DATE_TO'] ??
null,
156 $this->fields[
'TZ_TO'] ??
null,
161 private function isFullDay(): bool
163 return (isset($this->fields[
'SKIP_TIME']) && $this->fields[
'SKIP_TIME'] ===
'Y')
164 || (isset($this->fields[
'DT_SKIP_TIME']) && $this->fields[
'DT_SKIP_TIME'] ===
'Y');
173 if (!isset($this->fields[
'ORIGINAL_DATE_FROM']))
179 $this->fields[
'ORIGINAL_DATE_FROM'],
180 ($this->fields[
'SKIP_TIME'] ??
null) ===
'Y' || ($this->fields[
'DT_SKIP_TIME'] ??
null) ===
'Y',
181 $this->fields[
'TZ_FROM'] ??
null
190 return $this->isFullDay();
200 if (isset($this->fields[
'ATTENDEES_CODES']))
202 if (is_string($this->fields[
'ATTENDEES_CODES']))
204 $collection->setAttendeesCodes(explode(
',', $this->fields[
'ATTENDEES_CODES']));
206 else if (is_array($this->fields[
'ATTENDEES_CODES']))
208 $collection->setAttendeesCodes($this->fields[
'ATTENDEES_CODES']);
212 if (isset($this->fields[
'ATTENDEES']) && is_array($this->fields[
'ATTENDEES']))
214 $collection->setAttendeesId($this->fields[
'ATTENDEES']);
218 $collection->setAttendeesId([(
int)$this->fields[
'OWNER_ID']]);
231 if (isset($this->fields[
'REMIND']) && is_string($this->fields[
'REMIND']))
233 $this->fields[
'REMIND'] = unserialize($this->fields[
'REMIND'], [
'allowed_classes' =>
false]);
236 if (!isset($this->fields[
'REMIND']) || !is_array($this->fields[
'REMIND']))
244 $collection->setEventStart($eventStart);
246 foreach ($this->fields[
'REMIND'] as $remind)
248 if ($remind[
'type'] ===
Event\
Tools\Dictionary::REMIND_UNIT[
'date'])
256 $this->fields[
'TZ_FROM']
260 ->setEventStart($eventStart)
266 ->setEventStart($eventStart)
270 $eventStart->toString(),
272 $this->fields[
'TZ_FROM'])
275 ->sub(
"{$remind['before']} days")
276 ->add(
"{$remind['time']} minutes")
278 ->setDaysBefore($remind[
'before'])
284 ->setTimeBeforeEvent(
286 Event\
Tools\Dictionary::REMIND_UNIT[$remind[
'type']]
289 ->setEventStart($eventStart)
302 return $this->fields[
'DESCRIPTION'] ??
null;
313 $sectionId = $this->fields[
'SECTION_ID'] ??
314 (is_array($this->fields[
'SECTIONS'])
315 ? (int)$this->fields[
'SECTIONS'][0]
334 return $this->fields[
'COLOR'] ??
null;
342 return $this->fields[
'TRANSPARENT'] ??
null;
350 return $this->fields[
'IMPORTANCE'] ??
null;
358 return $this->fields[
'ACCESSIBILITY'] ??
null;
366 return $this->fields[
'PRIVATE_EVENT'] ??
false;
377 if (empty($this->fields[
'MEETING_HOST']))
384 return Helper::getUserRole($this->fields[
'MEETING_HOST']);
400 if (empty($this->fields[
'CREATED_BY']))
407 return Helper::getUserRole($this->fields[
'CREATED_BY']);
423 if (empty($this->fields[
'OWNER_ID']))
427 if (empty($this->fields[
'CAL_TYPE']))
429 $this->fields[
'CAL_TYPE'] = User::TYPE;
434 return Helper::getRole($this->fields[
'OWNER_ID'], $this->fields[
'CAL_TYPE']);
455 return (
int)($this->fields[
'VERSION'] ??
null);
463 return $this->fields[
'CAL_TYPE'] ??
null;
471 return $this->fields[
'DAV_XML_ID'] ??
null;
479 return isset($this->fields[
'DELETED']) && $this->fields[
'DELETED'] ===
'Y';
487 return isset($this->fields[
'ACTIVE']) && $this->fields[
'ACTIVE'] ===
'Y';
495 return $this->fields[
'RECURRENCE_ID'] ??
null;
504 if (!isset($this->fields[
'DATE_CREATE']))
510 $this->fields[
'DATE_CREATE'],
512 (
new DateTime())->getTimezone()->
getName()
522 if (!isset($this->fields[
'TIMESTAMP_X']))
528 $this->fields[
'TIMESTAMP_X'],
530 (
new DateTime())->getTimezone()->
getName()
540 if (empty($this->fields[
'EXDATE']))
546 if (is_string($this->fields[
'EXDATE']))
548 foreach (explode(
";", $this->fields[
'EXDATE']) as $exDate)
554 else if (is_array($this->fields[
'EXDATE']))
556 foreach ($this->fields[
'EXDATE'] as $exDate)
570 return $this->fields[
'ID'] ??
null;
578 return $this->fields[
'PARENT_ID'] ??
null;
586 return (
bool)($this->fields[
'IS_MEETING'] ??
null);
594 return $this->fields[
'MEETING_STATUS'] ??
null;
610 return $this->fields[
'EVENT_TYPE'] ??
null;
615 if ($eventId = $this->fields[
'ID'] ??
null)
618 $mapper = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
620 return $mapper->getEventOption()->getMap([
'=EVENT_ID' => $eventId])->fetch();
628 return $this->fields[
'DT_LENGTH'] ??
null;
633 return $this->fields[
'COLLAB_ID'] ??
null;
__construct(array $fields)
prepareLocation($locationData='')
prepareRelations($relations)
prepareMeetingDescription($meeting=null)
createDateForRecurrence(string $date)
prepareRecurringRule($ruleData=null)
static prepareTimezone(?string $tz=null)
static getDateObject(string $date=null, ?bool $fullDay=true, ?string $tz='UTC')
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key