3namespace Bitrix\Calendar\Sharing;
5use Bitrix\Bitrix24\Form\AbuseZoneMap;
6use Bitrix\Calendar\Core\Base\Date;
7use Bitrix\Calendar\Core\Base\DateTimeZone;
8use Bitrix\Calendar\Integration\SocialNetwork\GroupService;
9use Bitrix\Main\Web\Uri;
10use Bitrix\UI\Form\FeedbackForm;
12use Bitrix\Main\Loader;
13use Bitrix\Main\Localization\Loc;
14use Bitrix\Main\Type\DateTime;
17use Bitrix\Main\Context;
19use Bitrix\Calendar\Sharing;
23 private const PAY_ATTENTION_TO_NEW_SHARING_JOINT_FEATURE_OPTION_NAME =
'payAttentionToNewSharingJointFeature';
24 private const PAY_ATTENTION_TO_NEW_FEATURE_JOINT =
'joint-sharing';
25 private const WEEK_TIMESTAMP = 604800;
28 public const ICS =
'ics';
33 public const ACTION_ICS =
'?'.self::ACTION.
'='.self::ICS;
41 private static array $shortUrl = [];
61 self::PAY_ATTENTION_TO_NEW_SHARING_JOINT_FEATURE_OPTION_NAME,
70 CUserOptions::setOption(
72 self::PAY_ATTENTION_TO_NEW_SHARING_JOINT_FEATURE_OPTION_NAME,
93 if (Loader::includeModule(
'bitrix24'))
95 return \CBitrix24::isEmailConfirmed();
108 if (isset(self::$shortUrl[
$url]))
110 return self::$shortUrl[
$url];
113 self::$shortUrl[
$url] = \CCalendar::GetServerPath() . \CBXShortUri::getShortUri(
$url);
115 return self::$shortUrl[
$url];
128 return trim(str_replace(
129 [
'#NAME#',
'#LAST_NAME#'],
130 [
$name ??
'', $lastName ??
''],
141 return self::getUserInfo($id);
148 $personalPhoto = CFile::resizeImageGet(
149 $user[
'PERSONAL_PHOTO'],
150 [
'width' => 512,
'height' => 512],
159 'name' =>
$user[
'NAME'],
160 'lastName' =>
$user[
'LAST_NAME'],
161 'photo' => $personalPhoto[
'src'] ??
null,
162 'gender' =>
$user[
'PERSONAL_GENDER'] ??
null,
172 'id' => $groupInfo[
'id'],
173 'name' => $groupInfo[
'name'],
175 'photo' => $groupInfo[
'avatar'],
182 return match ($link[
'type']) {
184 default => self::getOwnerInfo($link[
'userId']),
199 $timeFormat =
$culture->get(
'SHORT_TIME_FORMAT');
200 $weekDayFormat =
'l';
202 $timestampUTCWithServerOffset = self::getUserDateTimestamp($date);
203 $dayMonth =
FormatDate($dayMonthFormat, $timestampUTCWithServerOffset);
205 $weekDay = mb_strtolower(
FormatDate($weekDayFormat, $timestampUTCWithServerOffset));
207 return "$dayMonth $time, $weekDay";
220 $weekDayFormat =
'l';
223 $dayMonth =
FormatDate($dayMonthFormat, $timestamp);
224 $weekDay = mb_strtolower(
FormatDate($weekDayFormat, $timestamp));
226 return "$dayMonth, $weekDay";
251 $isLongDateTimeFormat =
false;
253 $culture = Context::getCurrent()->getCulture();
254 $formattedDateFrom =
FormatDate(
$culture->getFullDateFormat(), self::getUserDateTimestamp($from));
255 $formattedDateTo =
'';
256 $formattedTimeFrom =
'';
257 $formattedTimeTo =
'';
264 $isLongDateTimeFormat =
true;
265 $formattedDateTo =
FormatDate(
$culture->getFullDateFormat(), self::getUserDateTimestamp($to));
270 if (!isset($formattedDateTo))
272 $formattedDateTo =
FormatDate(
$culture->getFullDateFormat(), self::getUserDateTimestamp($to));
277 $formattedTimeFrom =
FormatDate(
$culture->getShortTimeFormat(), self::getUserDateTimestamp($from));
278 $formattedTimeTo =
FormatDate(
$culture->getShortTimeFormat(), self::getUserDateTimestamp($to));
283 if ($isLongDateTimeFormat)
285 return $formattedDateFrom .
" - " . $formattedDateTo;
288 return $formattedDateFrom . Loc::getMessage(
'EC_VIEW_FULL_DAY');
291 if ($isLongDateTimeFormat)
293 return $formattedDateFrom .
' ' . $formattedTimeFrom .
' - ' . $formattedDateTo .
' ' . $formattedTimeTo;
296 return $formattedDateFrom .
' ' . $formattedTimeFrom .
' - ' . $formattedTimeTo;
310 $utcOffset .=
" " .
$time->format(
'P');
313 return "($utcOffset) " . $timezone->
toString();
322 $dateTimezone = new \DateTimeZone($date->getFields()[
'timezone']);
323 $serverTimezone = (new \DateTime())->getTimezone();
325 $dateOffset = $dateTimezone->getOffset(
new \
DateTime());
326 $serverOffset = $serverTimezone->getOffset(
new \
DateTime());
327 $offset = - $serverOffset + $dateOffset;
329 $userDate = clone $date;
330 $userDate->setTime($date->getHour(), $date->getMinutes(), $date->getSeconds() + $offset);
342 return \Bitrix\Calendar\Util::getDateTimestampUtc($date, $eventTimezone);
360 if (array_key_exists($linkType,
Sharing\
Link\Helper::LIFETIME))
380 return self::getAbuseLink($ownerId, $calendarLink, self::ABUSE_SENDER_PAGE);
385 return self::getAbuseLink($ownerId, $calendarLink, self::ABUSE_SENDER_EMAIL);
388 private static function getAbuseLink(
int $ownerId,
string $calendarLink,
string $senderPage): ?string
390 if (!
Main\Loader::includeModule(
'bitrix24'))
395 $owner = self::getOwnerInfo($ownerId);
397 $feedbackForm =
new FeedbackForm(
'calendar_sharing_abuse');
398 $presets = $feedbackForm->getPresets();
400 'hostname' => $presets[
'hostname'],
401 'b24_plan' => $presets[
'b24_plan'],
402 'sender_page' => $senderPage,
403 'admin_data' => \COption::GetOptionString(
'main',
'email_from',
''),
404 'user_data' =>
"id: {$owner['id']}, name: {$owner['name']} {$owner['lastName']}",
405 'calendar_link' => $calendarLink,
408 $formParamsQuery = http_build_query($formParams);
411 return AbuseZoneMap::getLink(
$region) .
"?$formParamsQuery";
416 if (!
Main\Loader::includeModule(
'bitrix24'))
422 $abuseLink = AbuseZoneMap::getLink(
$region);
424 $parsedUrl = parse_url($abuseLink);
426 $host = $parsedUrl[
'host'];
429 return rtrim($parsedUri->getLocator(),
'/');
435 if (
$site = $siteDb->fetchObject())
437 Loc::setCurrentLang(
$site->getLanguageId());
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getPageAbuseLink(int $ownerId, string $calendarLink)
static formatDate(Date $date)
static getOwnerInfo(int $id)
static getEmailAbuseLink(int $ownerId, string $calendarLink)
static isPhoneFeatureEnabled()
static formatTimeInterval(Date $from, Date $to, bool $isFullDay)
static disableOptionPayAttentionToNewSharingFeature()
static formatDateShort(Date $date)
static getEventTimestampUTC(DateTime $date, ?string $eventTimezone=null)
static payAttentionToNewSharingFeature()
static getShortUrl(string $url)
static getPersonFullNameLoc(?string $name, ?string $lastName)
static isMailFeatureEnabled()
static createSharingLinkExpireDate(?DateTime $dateTime, string $linkType)
static createSharingJointLinkExpireDate(?DateTime $dateTime)
static getGroupOwnerInfo(int $groupId)
static formatTimezone(DateTimeZone $timezone)
static getLinkOwnerInfo(array $link)
static getUserInfo(int $userId)
static formatDateWithoutTime(Date $date)
static getUserDateTimestamp(Date $date)
static convertFormatToPhp($format)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
const BX_RESIZE_IMAGE_EXACT
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)