1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
publicevent.php
См. документацию.
1<?php
2
4
9
11{
12 public const PUBLIC_EVENT_PATH = 'pub/calendar-event';
13
14 public const ACTION = 'action';
15 public const ACCEPT = 'accept';
16 public const DECLINE = 'decline';
17 public const ICS = 'ics';
18 public const ACTION_ACCEPT = '?'.self::ACTION.'='.self::ACCEPT;
19 public const ACTION_DECLINE = '?'.self::ACTION.'='.self::DECLINE;
20 public const ACTION_ICS = '?'.self::ACTION.'='.self::ICS;
21
22 public static function isHashValid(Event $event, ?string $hash): bool
23 {
24 $eventId = $event->getId();
25 $userId = $event->getOwner()?->getId();
26 $dateCreate = $event->getDateCreate();
27
28 if ($userId === null || $dateCreate === null)
29 {
30 return false;
31 }
32
33 $dateCreateTimestamp = (int)Util::getTimestamp($dateCreate->toString());
34
35 return self::getHashForPubEvent($eventId, $userId, $dateCreateTimestamp) === $hash;
36 }
37
38 public static function getDetailLinkFromEvent(Event $event): ?string
39 {
40 $eventId = $event->getId();
41 $ownerId = $event->getOwner()?->getId();
42 $dateCreate = $event->getDateCreate();
43
44 if ($ownerId === null || $dateCreate === null)
45 {
46 return null;
47 }
48
49 $dateCreateTimestamp = (int)Util::getTimestamp(
50 $dateCreate->format(Date::convertFormatToPhp(FORMAT_DATETIME)),
51 );
52
53 return self::getDetailLink($eventId, $ownerId, $dateCreateTimestamp);
54 }
55
56 public static function getDetailLink(int $eventId, int $userId, int $dateCreateTimestamp): string
57 {
58 $serverPath = \CCalendar::GetServerPath();
59 $publicPath = self::PUBLIC_EVENT_PATH;
60
61 return "$serverPath/$publicPath/$eventId/".self::getHashForPubEvent($eventId, $userId, $dateCreateTimestamp)."/";
62 }
63
64 protected static function getHashForPubEvent(int $eventId, int $userId, int $dateCreateTimestamp): string
65 {
66 return md5($eventId.self::getSaltForPubLink().$dateCreateTimestamp.$userId);
67 }
68
69 protected static function getSaltForPubLink(): string
70 {
71 $salt = \COption::GetOptionString('calendar', 'pub_event_salt', '');
72
73 if (empty($salt))
74 {
75 $salt = uniqid('', true);
76 \COption::SetOptionString('calendar', 'pub_event_salt', $salt);
77 }
78
79 return $salt;
80 }
81
82 public static function prepareEventDescriptionForIcs(Event $event): string
83 {
84 if ($event->getMeetingDescription()?->getHideGuests())
85 {
86 $event->setAttendeesCollection(null);
87 }
88
90 $description = IcsManager::getInstance()->prepareEventDescription($event, [
91 'eventUrl' => $detailLink,
92 ]);
93
94 return str_replace("\\n", "\n", $description);
95 }
96}
$hash
Определения ajax_redirector.php:8
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getDetailLinkFromEvent(Event $event)
Определения publicevent.php:38
static getDetailLink(int $eventId, int $userId, int $dateCreateTimestamp)
Определения publicevent.php:56
static getHashForPubEvent(int $eventId, int $userId, int $dateCreateTimestamp)
Определения publicevent.php:64
static isHashValid(Event $event, ?string $hash)
Определения publicevent.php:22
static prepareEventDescriptionForIcs(Event $event)
Определения publicevent.php:82
static getSaltForPubLink()
Определения publicevent.php:69
Определения util.php:21
static getTimestamp($date, $round=true, $getTime=true)
Определения util.php:60
Определения date.php:9
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
const FORMAT_DATETIME
Определения include.php:64
$event
Определения prolog_after.php:141