1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
feature.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Helper;
4
5use Bitrix\Bitrix24;
6use Bitrix\Main\Config\Option;
7use Bitrix\Main\Loader;
8use Bitrix\Socialnetwork\Collab\CollabFeature;
9use Bitrix\Socialnetwork\Collab\Registry\CollabRegistry;
10use Bitrix\Tasks\Flow\FlowFeature;
11
13{
14 const PROJECTS_GROUPS = 'socialnetwork_projects_groups';
15 const SCRUM_CREATE = 'socialnetwork_scrum_create';
16 const PROJECTS_ACCESS_PERMISSIONS = 'socialnetwork_projects_access_permissions';
17 const PROJECTS_COPY = 'socialnetwork_copy_project';
18
19 const FIRST_ERA = 'socialnetwork_first_era';
20
21 public static function isFeatureEnabled(string $featureName, int $groupId = 0): bool
22 {
23 if (!Loader::includeModule('bitrix24'))
24 {
25 return true;
26 }
27
28 if (
29 $featureName === self::PROJECTS_GROUPS
30 && Loader::includeModule('tasks')
31 && FlowFeature::isFeatureEnabled()
32 )
33 {
34 return true;
35 }
36
37 if ($groupId)
38 {
39 $isCollab = (CollabRegistry::getInstance()->get($groupId) !== null);
40 if ($isCollab && CollabFeature::isFeatureEnabled())
41 {
42 return true;
43 }
44 }
45
46 return Bitrix24\Feature::isFeatureEnabled($featureName);
47 }
48
49 public static function isFeatureEnabledByTrial(string $featureName): bool
50 {
51 if (!Loader::includeModule('bitrix24'))
52 {
53 return true;
54 }
55
56 return (
58 && array_key_exists($featureName, Bitrix24\Feature::getTrialFeatureList())
59 );
60 }
61
62 public static function isFeaturePromo(string $featureName): bool
63 {
64 return (
65 Loader::includeModule('bitrix24')
66 && Bitrix24\Feature::isPromoEditionAvailableByFeature($featureName)
67 );
68 }
69
70 public static function canTurnOnTrial(string $featureName): bool
71 {
72 if (
73 self::isFeatureEnabled(self::FIRST_ERA)
74 || self::isFeatureEnabled($featureName)
75 )
76 {
77 return false;
78 }
79
80 return !self::isDemoFeatureWasEnabled($featureName);
81 }
82
83 public static function turnOnTrial($featureName, int $trialDays = 15): void
84 {
85 Bitrix24\Feature::setFeatureTrialable($featureName, [
86 'days' => $trialDays,
87 ]);
88
89 Bitrix24\Feature::trialFeature($featureName);
90
91 self::setDemoOption($featureName);
92 }
93
94 private static function setDemoOption(string $featureName): void
95 {
96 Option::set('socialnetwork', $featureName . '_trialable', true);
97 }
98
99 private static function isDemoFeatureWasEnabled(string $featureName): bool
100 {
101 return (bool) Option::get('socialnetwork', $featureName . '_trialable', false);
102 }
103}
const PROJECTS_ACCESS_PERMISSIONS
Определения feature.php:16
static canTurnOnTrial(string $featureName)
Определения feature.php:70
static isFeatureEnabled(string $featureName, int $groupId=0)
Определения feature.php:21
const PROJECTS_COPY
Определения feature.php:17
static isFeaturePromo(string $featureName)
Определения feature.php:62
static turnOnTrial($featureName, int $trialDays=15)
Определения feature.php:83
static isFeatureEnabledByTrial(string $featureName)
Определения feature.php:49
const PROJECTS_GROUPS
Определения feature.php:14