3namespace Bitrix\Calendar\OpenEvents\Controller;
5use Bitrix\Calendar\OpenEvents\Exception\EventBusyException;
6use Bitrix\Calendar\OpenEvents\Exception\MaxAttendeesReachedException;
7use Bitrix\Calendar\OpenEvents\Provider;
8use Bitrix\Calendar\OpenEvents\Controller\Filter\OpenEvent as ValidateFilter;
9use Bitrix\Calendar\OpenEvents\Controller\Request\OpenEvent as RequestDto;
10use Bitrix\Calendar\Event\Service\OpenEventPullService;
11use Bitrix\Calendar\Internals\Exception\PermissionDenied;
12use Bitrix\Calendar\OpenEvents\Service\OpenEventAttendeeService;
13use Bitrix\Calendar\OpenEvents\Service\OpenEventService;
14use Bitrix\Calendar\Ui\CountersManager;
15use Bitrix\Main\Engine\AutoWire\Parameter;
16use Bitrix\Main\Engine\Controller;
17use Bitrix\Main\Engine\CurrentUser;
19use Bitrix\Main\Type\Date;
28 protected function init(): void
32 $this->userId = (int)CurrentUser::get()->getId();
41 new ValidateFilter\ValidateGetOpenEventList(),
44 'setAttendeeStatus' => [
46 new ValidateFilter\ValidateSetEventAttendeeStatus(),
51 new ValidateFilter\ValidateSetEventsWatched(),
63 RequestDto\SetEventAttendeeStatusDto::class,
64 static fn () => RequestDto\SetEventAttendeeStatusDto::fromRequest(
$request->toArray())
67 RequestDto\GetOpenEventListDto::class,
71 $today = new \DateTimeImmutable();
72 $plus3month = new \DateTimeImmutable(
'+3 month');
73 $fromYear =
$request[
'fromYear'] ?? $today->format(
'Y');
74 $fromMonth =
$request[
'fromMonth'] ?? $today->format(
'm');
75 $toYear =
$request[
'toYear'] ?? $plus3month->format(
'Y');
76 $toMonth =
$request[
'toMonth'] ?? $plus3month->format(
'm');
78 return RequestDto\GetOpenEventListDto::fromRequest([
80 'fromYear' => $fromYear,
81 'fromMonth' => $fromMonth,
83 'toMonth' => $toMonth,
88 RequestDto\SetEventWatchedDto::class,
89 static fn () => RequestDto\SetEventWatchedDto::fromRequest(
$request->toArray())
94 public function listAction(RequestDto\GetOpenEventListDto $getOpenEventListDto):
array
96 OpenEventPullService::getInstance()->addToWatch($this->userId);
98 $fromDate =
"01.$getOpenEventListDto->fromMonth.$getOpenEventListDto->fromYear";
99 $toMonth = $getOpenEventListDto->toMonth + 1;
100 $toDate =
"00.$toMonth.$getOpenEventListDto->toYear";
103 categoriesIds: $getOpenEventListDto->categoryId ? [$getOpenEventListDto->categoryId] :
null,
104 fromDate: (
new Date($fromDate,
'd.m.Y'))->toString(),
105 toDate: (
new Date($toDate,
'd.m.Y'))->toString(),
108 return $this->eventProvider->list(
$filter);
114 categoriesIds: $categoryId ? [$categoryId] :
null,
117 return $this->eventProvider->getTsRange(
$filter);
124 OpenEventAttendeeService::getInstance()->setEventAttendeeStatus($this->userId, $setEventAttendeeStatusDto);
128 $this->addError(
new Error(
'permission denied',
'permission_denied'));
134 $this->addError(
new Error(
'max attendees reached',
'max_attendees_reached'));
140 $this->addError(
new Error(
'internal error',
'internal_error'));
148 OpenEventService::getInstance()->setEventsWatched($this->userId, $setEventWatchedDto->eventIds);
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
setWatchedAction(RequestDto\SetEventWatchedDto $setEventWatchedDto)
Provider EventProvider $eventProvider
setAttendeeStatusAction(RequestDto\SetEventAttendeeStatusDto $setEventAttendeeStatusDto)
getTsRangeAction(int $categoryId)
listAction(RequestDto\GetOpenEventListDto $getOpenEventListDto)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)