1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
holdentity.php
См. документацию.
1<?php
2
4
11
17{
18 public const TYPE_APP = 'A';
19 public const TYPE_WEBHOOK = 'W';
20 private const NOTIFICATION_CODE = 'HOLD_REST_OVERLOAD';
21 private const OPTION_CODE = 'hold_access_entity';
22 private const MODULE_ID = 'rest';
23
31 public static function add(string $type, string $code) : array
32 {
33 $result = [
34 'success' => false
35 ];
36
37 $data = static::get();
38 if (!is_array($data[$type]) || !in_array($code, $data[$type]))
39 {
40 $data[$type][] = $code;
41 $result['success'] = static::set($data);
42 if ($result['success'])
43 {
44 $url = static::getUrl($type, $code);
45 Notification::set(static::NOTIFICATION_CODE, $url);
46 }
47 }
48
49 return $result;
50 }
51
52 public static function checkBlockCode(string $type): void
53 {
54 $data = static::get();
55 if (is_array($data[$type]))
56 {
57 $key = array_keys($data[$type])[0];
59 $url = static::getUrl($type, $code);
60 if (!empty($url))
61 {
62 Notification::set(static::NOTIFICATION_CODE, $url);
63 }
64 else
65 {
67 }
68 }
69 }
70
71 private static function getUrl(string $type, string $code) : string
72 {
73 $url = '';
74 $filter = [];
75 if ($type === static::TYPE_APP)
76 {
78 if ($app)
79 {
80 if ($app['STATUS'] !== AppTable::STATUS_LOCAL)
81 {
83 }
84 else
85 {
86 $filter['=APP_ID'] = $app['ID'];
87 }
88 }
89 }
90 elseif ($type === static::TYPE_WEBHOOK)
91 {
93 [
94 'filter' => [
95 '=PASSWORD' => $code,
96 ],
97 'select' => [
98 'ID',
99 ],
100 'limit' => 1,
101 ]
102 );
103 if ($password = $res->fetch())
104 {
105 $filter['=PASSWORD_ID'] = $password['ID'];
106 }
107 }
108 if (!empty($filter))
109 {
110 $res = IntegrationTable::getList(
111 [
112 'filter' => $filter,
113 'select' => [
114 'ID',
115 'ELEMENT_CODE',
116 ],
117 'limit' => 1,
118 ]
119 );
120 if ($item = $res->fetch())
121 {
122 $url = \Bitrix\Rest\Url\DevOps::getInstance()->getIntegrationEditUrl($item['ID'], $item['ELEMENT_CODE']);
123 }
124 }
125
126 return $url;
127 }
128
136 public static function delete(string $type, string $code) : array
137 {
138 $result = [
139 'success' => false
140 ];
141 $data = static::get();
142 if (is_array($data[$type]))
143 {
144 $key = array_search($code, $data[$type]);
145 if ($key !== false)
146 {
147 if (count($data[$type]) === 1)
148 {
149 unset($data[$type]);
150 }
151 else
152 {
153 unset($data[$type][$key]);
154 }
155 $result['success'] = static::set($data);
156 }
157 }
158
159 return $result;
160 }
161
169 public static function is(string $type, string $code) : bool
170 {
171 $list = static::get();
172 return isset($list[$type]) && in_array($code, $list[$type]);
173 }
174
179 public static function reset() : bool
180 {
181 return static::set([]);
182 }
183
188 public static function get() : array
189 {
190 $option = Option::get(static::MODULE_ID, static::OPTION_CODE, false);
191
192 return $option ? Json::decode($option) : [];
193 }
194
200 private static function set(array $data) : bool
201 {
202 if (!empty($data))
203 {
204 Option::set(static::MODULE_ID, static::OPTION_CODE, Json::encode($data));
205 }
206 else
207 {
208 Option::delete(static::MODULE_ID, ['name' => static::OPTION_CODE]);
210 }
211
212 return true;
213 }
214}
$type
Определения options.php:106
static getList(array $parameters=array())
Определения datamanager.php:431
Определения json.php:9
Определения app.php:68
static getByClientId($clientId)
Определения app.php:967
const STATUS_LOCAL
Определения app.php:84
static add(string $type, string $code)
Определения holdentity.php:31
static checkBlockCode(string $type)
Определения holdentity.php:52
static is(string $type, string $code)
Определения holdentity.php:169
static set(string $code, string $url='')
Определения notification.php:192
static getApplicationDetailUrl($id=null, $from='')
Определения url.php:472
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$filter
Определения iblock_catalog_list.php:54
$app
Определения proxy.php:8
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$option
Определения options.php:1711
$password
Определения result.php:7
$url
Определения iframe.php:7