18 private static function getConfig()
22 if (!\
Bitrix\Main\Loader::includeModule(
'ui'))
27 if (self::isDisable())
63 "ID" =>
'im:ai:15062023:all',
69 "ID" =>
'im:group-chat-create:20062023:all',
75 "ID" =>
'im:conference-create:24082023:all',
83 "ID" =>
'immobile:chat-v2:16112023:mobile',
89 $settings = \Bitrix\Main\Config\Configuration::getValue(
'im');
90 if (isset($settings[
'promotion']) && is_array($settings[
'promotion']))
92 $result = array_merge($result, $settings[
'promotion']);
98 public static function getActive($type = self::DEVICE_TYPE_ALL)
102 if (!\
Bitrix\Main\Loader::includeModule(
'ui'))
107 foreach (self::getConfig() as $config)
109 $tour = self::getTour($config, $type);
110 if (!$tour || !$tour->isAvailable())
115 $result[] = $tour->getId();
121 public static function read($id)
123 $tour = self::getTourById($id);
124 if (!$tour || !$tour->isAvailable())
131 $tour->setViewDate($userId);
133 if (\
Bitrix\Main\Loader::includeModule(
'pull'))
135 \Bitrix\Pull\Event::add($userId, [
137 'command' =>
'promotionRead',
138 'params' => [
'id' => $id],
157 private static function getTour($config, $type = self::DEVICE_TYPE_ALL)
159 if (!\
Bitrix\Main\Loader::includeModule(
'ui'))
164 if ($type === self::DEVICE_TYPE_WEB)
167 $config[
'DEVICE_TYPE'] === self::DEVICE_TYPE_ALL
168 || $config[
'DEVICE_TYPE'] === self::DEVICE_TYPE_BROWSER
169 || $config[
'DEVICE_TYPE'] === self::DEVICE_TYPE_DESKTOP
175 else if ($type === self::DEVICE_TYPE_MOBILE)
178 $config[
'DEVICE_TYPE'] !== self::DEVICE_TYPE_MOBILE
179 && $config[
'DEVICE_TYPE'] !== self::DEVICE_TYPE_ALL
185 else if ($type !== self::DEVICE_TYPE_ALL)
188 $config[
'DEVICE_TYPE'] !== self::DEVICE_TYPE_ALL
189 && $config[
'DEVICE_TYPE'] !== self::DEVICE_TYPE_WEB
190 && $config[
'DEVICE_TYPE'] !== $type
197 $tour = new \Bitrix\Main\UI\Tour($config[
"ID"]);
200 "USER_TYPE" =>
"setUserType",
201 "USER_TIMESPAN" =>
"setUserTimeSpan",
202 "LIFETIME" =>
"setLifetime",
203 "START_DATE" =>
"setStartDate",
204 "END_DATE" =>
"setEndDate",
207 foreach ($params as $param => $setter)
209 if (isset($config[$param]))
211 $tour->$setter($config[$param]);
218 private static function getTourById($id)
220 foreach (self::getConfig() as $config)
222 if ($config[
'ID'] === $id)
224 return self::getTour($config);
231 private static function isDisable(): bool
233 return Option::get(
'im',
'promo_disabled',
'N') ===
'Y';