1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
eventdescription.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Sync\Util;
4
5use Bitrix\Calendar\Core\Event\Event;
6use Bitrix\Calendar\UserField\ResourceBooking;
7use Bitrix\Main\Localization\Loc;
8
10
12{
21 public function prepareForExport(Event $event): ?string
22 {
23 $languageId = \CCalendar::getUserLanguageId($event->getOwner()?->getId());
24 $description = $this->addAttendeesInfo($event->getDescription(), $event, $languageId);
25
26 return $this->addSpecialInfo($description, $event, $languageId);
27 }
28
35 public function prepareAfterImport(string $description, string $languageId): string
36 {
37 $description = $this->removeAttendeesInfo($description, $languageId);
38
39 return $this->removeSpecialInfo($description, $languageId);
40 }
41
48 private function removeAttendeesInfo(string $description, string $languageId): string
49 {
50 return (new AttendeesDescription($languageId))
51 ->cutAttendeesFromDescription($description)
52 ;
53 }
54
65 private function addAttendeesInfo(?string $description, Event $event, string $languageId): string
66 {
67 if (!$description)
68 {
69 $description = '';
70 }
71
72 if (
73 $event->getAttendeesCollection()
74 && ($attendees = $event->getAttendeesCollection()->getAttendeesCodes())
75 && count($attendees) > 1
76 )
77 {
78 $description = (new AttendeesDescription($languageId))
79 ->addAttendeesToDescription($attendees, $description, $event->getParentId())
80 ;
81 }
82
83 return $description;
84 }
85
93 private function addSpecialInfo(string $description, Event $event, string $languageId): string
94 {
95 $padding = "\r\n\r\n";
96 if (!$event->getDescription())
97 {
98 $padding = '';
99 }
100
101 // temporary this functionality is turned off
102
103 // if ($this->isGuest($event) || $this->isReservation($event))
104 // {
105 // $description .= $padding . Loc::getMessage('CALENDAR_EXPORT_EVENT_LOCK', null, $languageId);
106 // }
107 // elseif ($this->isEventWithAttendees($event))
108 // {
109 // $description .= $padding . Loc::getMessage('CALENDAR_EXPORT_EVENT_MEETING', null, $languageId);
110 // }
111
112 return $description;
113 }
114
120 private function isGuest(Event $event): bool
121 {
122 return $event->getId() !== $event->getParentId();
123 }
124
130 private function isReservation(Event $event): bool
131 {
132 return $event->getSpecialLabel() === ResourceBooking::EVENT_LABEL;
133 }
134
140 private function isEventWithAttendees(Event $event): bool
141 {
142 return $event->getAttendeesCollection() !== null
143 && count($event->getAttendeesCollection()->getAttendeesCodes()) > 1;
144 }
145
151 private function removeSpecialInfo(string $description, string $languageId)
152 {
153 return str_replace(
154 [
155 Loc::getMessage('CALENDAR_EXPORT_EVENT_LOCK', null, $languageId),
156 Loc::getMessage('CALENDAR_EXPORT_EVENT_MEETING', null, $languageId)
157 ],
158 '',
160 );
161 }
162}
prepareAfterImport(string $description, string $languageId)
Определения eventdescription.php:35
Определения event.php:5
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
$event
Определения prolog_after.php:141
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936