1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
SubscriptionCurtain.php
См. документацию.
1<?php
2
3namespace Bitrix\Rest\Notification\MarketExpired\Curtain;
4
5use Bitrix\Intranet\CurrentUser;
6
8{
9 private const SHOW_DELAY = 86400; // 1 day
10
12 {
13 return CurrentUser::get()->isAdmin()
14 ? $this->isEnabledForAdmin($type)
15 : $this->isEnabledForUser($type);
16 }
17
19 {
20 $lastShowTimestamp = $this->userOption->get("marketSubscriptionCurtain{$type->value}Ts", null);
21
22 if (!$lastShowTimestamp || !is_numeric($lastShowTimestamp))
23 {
24 return true;
25 }
26
27 return $lastShowTimestamp + self::SHOW_DELAY < time();
28 }
29
30 private function isDismissedByUser(CurtainPageType $type): bool
31 {
32 return $this->userOption->get("marketSubscriptionCurtain{$type->value}Dismiss", 'N') === 'Y';
33 }
34
35 private function isEnabledForAdmin(CurtainPageType $type): bool
36 {
38 {
39 return false;
40 }
41
42 return !$this->isDismissedByUser($type)
43 && $this->isTimeToShowForCurrentUser($type)
44 && $this->marketSubscriptionNotification->getPopup()->isDismissedByUser();
45 }
46
47 private function isEnabledForUser(CurtainPageType $type): bool
48 {
49 if ($this->marketSubscriptionNotification->marketSubscription->isActive())
50 {
51 return false;
52 }
53
54 return !$this->isDismissedByUser($type)
55 && $this->isTimeToShowForCurrentUser($type);
56 }
57}
$type
Определения options.php:106
isEnabledForCurrentUser(CurtainPageType $type=CurtainPageType::ANY_PAGE)
Определения SubscriptionCurtain.php:11