1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
promotion.php
См. документацию.
1
<?php
2
namespace
Bitrix\Im;
3
4
use Bitrix\Im\V2\Promotion\Entity;
5
use Bitrix\Im\V2\Promotion\Internals\DeviceType;
6
use Bitrix\Im\V2\Promotion\Service\UIPromotionService;
7
use Bitrix\Main\Config\Option;
8
13
class
Promotion
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
$type
Определения
options.php:106
Bitrix\Im\Promotion
Определения
promotion.php:14
Bitrix\Im\Promotion\USER_TYPE_OLD
const USER_TYPE_OLD
Определения
promotion.php:21
Bitrix\Im\Promotion\DEVICE_TYPE_DESKTOP
const DEVICE_TYPE_DESKTOP
Определения
promotion.php:17
Bitrix\Im\Promotion\DEVICE_TYPE_WEB
const DEVICE_TYPE_WEB
Определения
promotion.php:15
Bitrix\Im\Promotion\read
static read($id)
Определения
promotion.php:53
Bitrix\Im\Promotion\USER_TYPE_ALL
const USER_TYPE_ALL
Определения
promotion.php:23
Bitrix\Im\Promotion\DEVICE_TYPE_MOBILE
const DEVICE_TYPE_MOBILE
Определения
promotion.php:18
Bitrix\Im\Promotion\DEVICE_TYPE_BROWSER
const DEVICE_TYPE_BROWSER
Определения
promotion.php:16
Bitrix\Im\Promotion\getDeviceTypes
static getDeviceTypes()
Определения
promotion.php:61
Bitrix\Im\Promotion\DEVICE_TYPE_ALL
const DEVICE_TYPE_ALL
Определения
promotion.php:19
Bitrix\Im\Promotion\getActive
static getActive($type=self::DEVICE_TYPE_ALL)
Определения
promotion.php:28
Bitrix\Im\Promotion\USER_TYPE_NEW
const USER_TYPE_NEW
Определения
promotion.php:22
$result
$result
Определения
get_property_values.php:14
bitrix
modules
im
lib
promotion.php
Создано системой
1.14.0