3namespace Bitrix\Calendar\ICal\Builder;
5use Bitrix\Calendar\ICal\Basic\AttachPropertytype;
6use Bitrix\Calendar\ICal\Basic\AttendeesProperty;
7use Bitrix\Calendar\ICal\Basic\AttendeesPropertyType;
8use Bitrix\Calendar\ICal\Basic\BasicComponent;
9use Bitrix\Calendar\ICal\Basic\Content;
10use Bitrix\Calendar\ICal\Basic\Dictionary;
11use Bitrix\Calendar\ICal\Basic\RecurrenceRuleProperty;
12use Bitrix\Calendar\ICal\Basic\RecurrenceRulePropertyType;
13use Bitrix\Calendar\ICal\MailInvitation\Helper;
14use Bitrix\Calendar\Util;
15use Bitrix\Main\Localization\Loc;
16use Bitrix\Main\Text\Emoji;
17use Bitrix\Main\Type\Date;
21 public const TYPE =
'VEVENT';
27 private $description =
'';
31 private $withTimezone =
false;
32 private $classification =
null;
33 private $transparent =
null;
34 private $attendees = [];
36 private $status =
null;
39 private $location =
null;
41 private $sequence = 0;
42 private $attaches = [];
43 private $exdates = [];
70 return new self($uid);
92 $this->rrule = $rrule;
103 $this->withTime = $withTime;
114 $this->location = $location;
125 $this->modified = $modified;
137 $this->sequence = $sequence;
161 $this->starts = $starts;
183 $this->name = $name ? Emoji::decode($name) : Loc::getMessage(
'CAL_ICAL_NEW_EVENT');
194 $this->description = $description ? Emoji::decode($description) : $description;
205 $this->address = $address;
216 $this->created = $created;
227 $this->withTimezone = $withTimeZone;
238 $this->classification = $classification;
249 $this->transparent = $transparent;
260 foreach ($attendees as $attendee)
265 $attendee->getEmail(),
266 $attendee->getFullName(),
267 $attendee->getStatus(),
268 $attendee->getRole(),
269 $attendee->getCuType(),
270 $attendee->getMailTo(),
287 $organizer->getEmail(),
288 $organizer->getFullName(),
289 $organizer->getStatus(),
290 $organizer->getRole(),
291 $organizer->getCuType(),
305 $this->status = $status;
316 $this->attaches[] = $attaches;
327 $this->exdates = $exdates;
338 $this->dtStamp = $dtStamp;
359 $this->alerts = $alerts;
366 $this->priority = $priority;
376 $content = Content::getInstance(self::TYPE)
377 ->textProperty(
'UID', $this->uid)
378 ->textProperty(
'SUMMARY', $this->name)
379 ->textProperty(
'DESCRIPTION', $this->description)
380 ->textProperty(
'LOCATION', $this->address)
381 ->textProperty(
'CLASS', $this->classification)
382 ->textProperty(
'TRANSP', $this->transparent)
383 ->textProperty(
'STATUS', $this->status)
384 ->textProperty(
'LOCATION', $this->location)
385 ->textProperty(
'SEQUENCE', $this->sequence)
386 ->dateTimeProperty(
'DTSTART', $this->starts, $this->withTime, $this->withTimezone)
387 ->dateTimeProperty(
'DTEND', $this->ends, $this->withTime, $this->withTimezone)
388 ->dateTimeProperty(
'DTSTAMP', $this->dtStamp,
true,
false,
true)
389 ->dateTimeProperty(
'CREATED', $this->created,
true,
false,
true)
390 ->dateTimeProperty(
'LAST-MODIFIED', $this->modified,
true,
false,
true)
391 ->subComponent(...$this->alerts);
393 if ($this->organizer !==
null)
398 foreach ($this->attendees as $attendee)
403 if ($this->isRecurringEvent())
407 if (!empty($this->exdates))
409 foreach ($this->exdates as $exdate)
411 $content->dateTimeProperty(
'EXDATE', $exdate, $this->withTime, $this->withTimezone);
416 if (!empty($this->attaches))
418 foreach ($this->attaches as $attach)
424 if (!empty($this->url))
426 $content->textProperty(
'URL', $this->url);
429 if (!empty($this->priority))
431 $content->textProperty(
'PRIORITY', $this->priority);
440 private function isRecurringEvent(): bool
442 return !empty($this->rrule) && !empty($this->rrule->freq) && $this->rrule->freq !==
'NONE';
452 return $event[
'SKIP_TIME']
463 private static function createFromReply(
array $event): static
473 ->setDtStamp(Helper::getIcalDateTime())
476 ->setWithTimezone(!
$event[
'SKIP_TIME'])
477 ->setWithTime(!
$event[
'SKIP_TIME'])
480 $event[
'ORGANIZER_MAIL'][
'MAILTO'] ??
$event[
'ORGANIZER_MAIL'][
'EMAIL']
483 ->setSequence(((
int)
$event[
'VERSION']))
484 ->setStatus(Dictionary::INVITATION_STATUS[
'confirmed'])
485 ->setUrl(
$event[
'URL'] ??
null)
494 private static function createFromCancel(
array $event): static
496 $fullDay =
$event[
'DT_SKIP_TIME'] ===
'Y';
498 return (
new static(
$event[
'DAV_XML_ID']))
503 ->setDtStamp(Helper::getIcalDateTime())
505 ->setWithTimezone(!$fullDay)
506 ->setWithTime(!$fullDay)
507 ->setDescription(
$event[
'DESCRIPTION'])
509 ->setLocation(
$event[
'TEXT_LOCATION'])
510 ->setSequence((
int)
$event[
'VERSION'] + 1)
511 ->setStatus(Dictionary::INVITATION_STATUS[
'cancelled'])
520 private static function createFromRequest(
array $event): static
522 return (
new static(
$event[
'DAV_XML_ID']))
529 ->setWithTimezone(!
$event[
'SKIP_TIME'])
530 ->setWithTime(!
$event[
'SKIP_TIME'])
531 ->setDescription(
$event[
'DESCRIPTION'])
533 ->setRRule(
$event[
'RRULE'])
534 ->setExdates(
$event[
'EXDATE'])
535 ->setLocation(
$event[
'TEXT_LOCATION'])
536 ->setSequence((
int)
$event[
'VERSION'])
537 ->setStatus(Dictionary::INVITATION_STATUS[
'confirmed'])
static getInstance($names, AttachProperty $attach)
static createInstance($names, AttendeesProperty $calendarAddress)
static createInstance($names, RecurrenceRuleProperty $rrule)
setExdates(array $exdates=null)
setTransparent(string $transparent)
setAttaches(array $attaches=null)
setRRule(RecurrenceRuleProperty $rrule=null)
setName(string $name=null)
setCreatedAt(Date $created)
static create(array $event, string $type)
setWithTime(bool $withTime=false)
setAttendees(iterable $attendees)
setWithTimezone(bool $withTimeZone)
setOrganizer(Attendee $organizer, string $mailTo)
setStatus(string $status)
setStartsAt(Date $starts)
static createInstance($uid)
setAddress(string $address=null)
setLocation(string $location=null)
setDtStamp(Date $dtStamp)
setSequence(int $sequence)
setClassification(string $classification=null)
setDescription(string $description=null)
setModified(Date $modified)
setPriority(int $priority)
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)