1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
promotion.php
См. документацию.
1<?php
2namespace Bitrix\Im;
3
4use Bitrix\Im\V2\Promotion\Entity;
5use Bitrix\Im\V2\Promotion\Internals\DeviceType;
6use Bitrix\Im\V2\Promotion\Service\UIPromotionService;
7use Bitrix\Main\Config\Option;
8
14{
15 const DEVICE_TYPE_WEB = "web"; // browser + desktop
16 const DEVICE_TYPE_BROWSER = "browser";
17 const DEVICE_TYPE_DESKTOP = "desktop";
18 const DEVICE_TYPE_MOBILE = "mobile";
19 const DEVICE_TYPE_ALL = "all";
20
21 const USER_TYPE_OLD = "OLD";
22 const USER_TYPE_NEW = "NEW";
23 const USER_TYPE_ALL = "ALL";
24
25 private const ONE_MONTH = 3600 * 24 * 30;
26 private const ENDLESS_LIFETIME = 0;
27
28 public static function getActive($type = self::DEVICE_TYPE_ALL)
29 {
30 if (self::isDisable())
31 {
32 return [];
33 }
34
35 $promoType = DeviceType::tryFrom($type);
36 if (null === $promoType)
37 {
38 return [];
39 }
40
41 $promoService = UIPromotionService::getInstance();
42 $promoList = $promoService->getActive($promoType);
43
44 $result = [];
45 foreach ($promoList as $promo)
46 {
47 $result[] = $promo->getId();
48 }
49
50 return $result;
51 }
52
53 public static function read($id)
54 {
55 $promoService = UIPromotionService::getInstance();
56 $promotion = new Entity\Promotion($id);
57
58 return $promoService->markAsViewed($promotion)->isSuccess();
59 }
60
61 public static function getDeviceTypes()
62 {
63 return [
64 self::DEVICE_TYPE_ALL,
65 self::DEVICE_TYPE_WEB,
66 self::DEVICE_TYPE_BROWSER,
67 self::DEVICE_TYPE_DESKTOP,
68 self::DEVICE_TYPE_MOBILE,
69 ];
70 }
71
72 private static function isDisable(): bool
73 {
74 return Option::get('im', 'promo_disabled', 'N') === 'Y';
75 }
76}
$type
Определения options.php:106
const USER_TYPE_OLD
Определения promotion.php:21
const DEVICE_TYPE_DESKTOP
Определения promotion.php:17
const DEVICE_TYPE_WEB
Определения promotion.php:15
static read($id)
Определения promotion.php:53
const USER_TYPE_ALL
Определения promotion.php:23
const DEVICE_TYPE_MOBILE
Определения promotion.php:18
const DEVICE_TYPE_BROWSER
Определения promotion.php:16
static getDeviceTypes()
Определения promotion.php:61
const DEVICE_TYPE_ALL
Определения promotion.php:19
static getActive($type=self::DEVICE_TYPE_ALL)
Определения promotion.php:28
const USER_TYPE_NEW
Определения promotion.php:22
$result
Определения get_property_values.php:14