20 private const MODULE_ID =
'rest';
21 private const OPTION_ACCESS_NOTIFICATION =
'rest_access_notification';
22 private const OPTION_LAST_CHECK_ACCESS_NOTIFICATION =
'last_check_rest_access_notify';
23 private const OPTION_LAST_CHECK_NOTIFICATION =
'last_check_rest_notify';
24 private const OPTION_NOTIFICATION_URL =
'rest_notify_url';
25 private const CODE_CHECK_BY_AGENT = [
27 'SUBSCRIPTION_MARKET_DEMO_END',
28 'SUBSCRIPTION_MARKET_TARIFF_MARKET',
29 'SUBSCRIPTION_MARKET_TRIAL_END',
31 private static $timestampNotifyDays = 259200;
32 private static $codeToNotification = [
33 'rest_buy' =>
'REST_BUY',
34 'limit_subscription_market_demomarket_end' =>
'SUBSCRIPTION_MARKET_DEMO_END',
35 'limit_subscription_market_tarifwithmarket' =>
'SUBSCRIPTION_MARKET_TARIFF_MARKET',
36 'plus_need_trial' =>
'SUBSCRIPTION_MARKET_TRIAL_END',
42 public static function get()
45 $option = Option::get(static::MODULE_ID, static::OPTION_ACCESS_NOTIFICATION,
'');
47 if (static::$codeToNotification[$option])
49 $option = static::$codeToNotification[$option];
54 $url = Option::get(static::MODULE_ID, static::OPTION_NOTIFICATION_URL,
'');
57 $url =
Loc::getMessage(
'REST_MARKETPLACE_NOTIFICATION_' . $option .
'_URL');
58 if ($option ===
'REST_BUY' && Loader::includeModule(
'bitrix24'))
60 $prefix = \CBitrix24::getLicensePrefix();
63 $url =
'https://goodbye-2020.bitrix24.site/';
65 elseif ($prefix ===
'kz')
67 $url =
'https://goodbye2020.bitrix24.site/';
69 elseif ($prefix ===
'ua')
71 $url =
'https://skilky-mozhna.bitrix24site.ua/';
73 elseif ($prefix ===
'ru')
75 $url =
'https://goodbye2020.bitrix24.tech/';
77 elseif ($prefix ===
'en')
79 $url =
'https://www.bitrix24.com/promo/sales/holiday-sale/';
81 elseif ($prefix ===
'jp')
83 $url =
'https://www.bitrix24.jp/promo/sales/holiday-sale/';
85 elseif ($prefix ===
'pl')
87 $url =
'https://www.bitrix24.pl/promo/sales/holiday-sale/';
89 elseif ($prefix ===
'it')
91 $url =
'https://www.bitrix24.it/promo/sales/holiday-sale/';
93 elseif ($prefix ===
'br')
95 $url =
'https://www.bitrix24.com.br/promo/sales/holiday-sale/';
97 elseif ($prefix ===
'fr')
99 $url =
'https://www.bitrix24.fr/promo/sales/holiday-sale/';
101 elseif ($prefix ===
'de')
103 $url =
'https://www.bitrix24.de/promo/sales/holiday-sale/';
105 elseif ($prefix ===
'in')
107 $url =
'https://www.bitrix24.in/promo/sales/holiday-sale/';
109 elseif ($prefix ===
'eu')
111 $url =
'https://www.bitrix24.eu/promo/sales/holiday-sale/';
113 elseif ($prefix ===
'es' || $prefix ===
'la')
115 $url =
'https://www.bitrix24.es/promo/sales/holiday-sale/';
119 if ($option ===
'SUBSCRIPTION_MARKET_TRIAL_END')
121 $url = \Bitrix\Rest\Marketplace\Url::getSubscriptionBuyUrl();
127 $urlBtn =
'<a target="_blank" href="'
135 'REST_MARKETPLACE_NOTIFICATION_' . $option .
'_MESS',
143 'PANEL_MESSAGE' => $message
157 Option::set(static::MODULE_ID, static::OPTION_LAST_CHECK_NOTIFICATION, $timestamp);
164 $option = (int) Option::get(static::MODULE_ID, static::OPTION_LAST_CHECK_NOTIFICATION, 0);
167 $result = $option + static::$timestampNotifyDays;
181 public static function set(
string $code,
string $url =
'') : bool
183 Option::set(static::MODULE_ID, static::OPTION_ACCESS_NOTIFICATION, $code);
184 Option::set(static::MODULE_ID, static::OPTION_LAST_CHECK_ACCESS_NOTIFICATION, time());
185 Option::set(static::MODULE_ID, static::OPTION_NOTIFICATION_URL, $url);
197 Option::delete(static::MODULE_ID, [
'name' => static::OPTION_ACCESS_NOTIFICATION]);
198 Option::delete(static::MODULE_ID, [
'name' => static::OPTION_LAST_CHECK_ACCESS_NOTIFICATION]);
199 Option::delete(static::MODULE_ID, [
'name' => static::OPTION_NOTIFICATION_URL]);
209 if (Loader::includeModule(
'bitrix24'))
217 $isSubscriptionFinish = $dateFinish
218 && $dateFinish < (
new Date())
219 && (time() - static::$timestampNotifyDays) < $dateFinish->getTimestamp();
229 && static::getLastCheckTimestamp() > time()
232 $code =
'SUBSCRIPTION_MARKET_TARIFF_MARKET';
234 elseif ($isSubscriptionFinish)
236 $code =
'SUBSCRIPTION_MARKET_DEMO_END';
241 $code =
'SUBSCRIPTION_MARKET_TRIAL_END';
251 $lastCode = Option::get(static::MODULE_ID, static::OPTION_ACCESS_NOTIFICATION,
null);
252 if (!is_null($lastCode) && in_array($lastCode, static::CODE_CHECK_BY_AGENT))
259 return '\Bitrix\Rest\Marketplace\Notification::checkAgent();';
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)