1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
rest_provider.php
См. документацию.
1<?php
2
16use Bitrix\OAuth;
18
20{
21 const ERROR_BATCH_LENGTH_EXCEEDED = 'ERROR_BATCH_LENGTH_EXCEEDED';
22 const ERROR_BATCH_METHOD_NOT_ALLOWED = 'ERROR_BATCH_METHOD_NOT_ALLOWED';
23
24 // default license shown instead of absent or unknown
25 const LICENSE_DEFAULT = "project";
26
27 // controller group id => rest license id
28 protected static $licenseList = array(
29 "project" => "project",
30 "corporation" => "corporation",
31 "company" => "company",
32 "company2" => "company2",
33 "company3" => "company3",
34 "team" => "team",
35 "demo" => "demo",
36 "nfr" => "nfr",
37 "tf" => "tf",
38 "crm" => "crm",
39 "tasks" => "tasks",
40 "basic" => "basic",
41 "start" => "start",
42 "std" => "std",
43 "pro" => "pro",
44 "ent" => "ent",
45 "pro100" => "pro100",
46 "ent250" => "ent250",
47 "ent500" => "ent500",
48 "ent1000" => "ent1000",
49 "ent2000" => "ent2000",
50 "ent3000" => "ent3000",
51 "ent4000" => "ent4000",
52 "ent5000" => "ent5000",
53 "ent6000" => "ent6000",
54 "ent7000" => "ent7000",
55 "ent8000" => "ent8000",
56 "ent9000" => "ent9000",
57 "ent10000" => "ent10000",
58 );
59
60 protected static $arApp = null;
61 protected static $arScope = null;
62 protected static $arMethodsList = null;
63
64 public function getDescription()
65 {
66 if(!is_array(self::$arMethodsList))
67 {
68 $globalMethods = array(
69 CRestUtil::GLOBAL_SCOPE => array(
70 'batch' => array(__CLASS__, 'methodsBatch'),
71
72 'scope' => array(__CLASS__, 'scopeList'),
73 'methods' => array(__CLASS__, 'methodsList'),
74 'method.get' => array(__CLASS__, 'getMethod'),
75
76 'server.time' => array(__CLASS__, 'getServerTime'),
77 ),
78 );
79
80 $ownMethods = array(
81 CRestUtil::GLOBAL_SCOPE => array(
82 'app.option.get' => array(__CLASS__, 'appOptionGet'),
83 'app.option.set' => array(__CLASS__, 'appOptionSet'),
84 'user.option.get' => array(__CLASS__, 'userOptionGet'),
85 'user.option.set' => array(__CLASS__, 'userOptionSet'),
86
87 CRestUtil::EVENTS => array(
88 'OnAppUninstall' => array(
89 'rest',
90 'OnRestAppDelete',
91 array(__CLASS__, 'OnAppEvent'),
92 array(
93 "sendAuth" => false,
94 "category" => \Bitrix\Rest\Sqs::CATEGORY_IMPORTANT,
95 )
96 ),
97 'OnAppInstall' => array(
98 'rest',
99 'OnRestAppInstall',
100 array(__CLASS__, 'OnAppEvent'),
101 array(
102 "sendRefreshToken" => true,
103 "category" => \Bitrix\Rest\Sqs::CATEGORY_IMPORTANT,
104 )
105 ),
106 'OnAppUpdate' => array(
107 'rest',
108 'OnRestAppUpdate',
109 array(__CLASS__, 'OnAppEvent'),
110 array(
111 "sendRefreshToken" => true,
112 "category" => \Bitrix\Rest\Sqs::CATEGORY_IMPORTANT,
113 )
114 ),
115 'OnAppPayment' => array(
116 'bitrix24',
117 'OnAfterAppPaid',
118 array(__CLASS__, 'OnAppPayment'),
119 array(
120 "category" => \Bitrix\Rest\Sqs::CATEGORY_IMPORTANT,
121 )
122 ),
123 'OnSubscriptionRenew' => [
124 'rest',
125 'onAfterSubscriptionRenew',
126 [
127 __CLASS__,
128 'onSubscriptionRenew',
129 ],
130 [
131 'sendRefreshToken' => true,
132 ],
133 ],
134 'OnAppTest' => array(
135 'rest',
136 'OnRestAppTest',
137 array(__CLASS__, 'OnAppEvent'),
138 array(
139 "sendRefreshToken" => true,
140 )
141 ),
142 'OnAppMethodConfirm' => array(
143 'rest',
144 'OnRestAppMethodConfirm',
145 array(__CLASS__, 'OnAppEvent'),
146 array(
147 "sendAuth" => false,
148 "category" => \Bitrix\Rest\Sqs::CATEGORY_IMPORTANT,
149 )
150 ),
151 ),
152 CRestUtil::PLACEMENTS => array(
153 CRestUtil::PLACEMENT_APP_URI => array(
154 'max_count' => 1
155 )
156 )
157 ),
158 );
159
160 if(!\Bitrix\Rest\Integration\OAuthModule::isSupported())
161 {
162 $ownMethods[CRestUtil::GLOBAL_SCOPE]['app.info'] = array(__CLASS__, 'appInfo');
163 $ownMethods[CRestUtil::GLOBAL_SCOPE]['feature.get'] = array(__CLASS__, 'getFeature');
164 }
165
166 $arDescription = array();
167
168 foreach(GetModuleEvents("rest", "OnRestServiceBuildDescription", true) as $arEvent)
169 {
170 $res = ExecuteModuleEventEx($arEvent);
171 if(is_array($res))
172 {
173 $arDescription = array_merge_recursive($res, $arDescription);
174 }
175 }
176
177 self::$arMethodsList = array_merge_recursive(
178 $globalMethods,
179 $ownMethods,
180 $arDescription
181 );
182
183 if(!array_key_exists('profile', self::$arMethodsList[CRestUtil::GLOBAL_SCOPE]))
184 {
185 self::$arMethodsList[CRestUtil::GLOBAL_SCOPE]['profile'] = array(
186 'callback' => array(__CLASS__, 'getProfile'),
187 'options' => array(),
188 );
189 }
190
191 foreach(self::$arMethodsList as $scope => $arScopeMethods)
192 {
193 self::$arMethodsList[$scope] = array_change_key_case(self::$arMethodsList[$scope], CASE_LOWER);
194 if(
195 array_key_exists(CRestUtil::EVENTS, self::$arMethodsList[$scope])
196 && is_array(self::$arMethodsList[$scope][CRestUtil::EVENTS])
197 )
198 {
199 self::$arMethodsList[$scope][CRestUtil::EVENTS] = array_change_key_case(self::$arMethodsList[$scope][CRestUtil::EVENTS], CASE_UPPER);
200 }
201 if(
202 array_key_exists(CRestUtil::PLACEMENTS, self::$arMethodsList[$scope])
203 && is_array(self::$arMethodsList[$scope][CRestUtil::PLACEMENTS])
204 )
205 {
206 self::$arMethodsList[$scope][CRestUtil::PLACEMENTS] = array_change_key_case(self::$arMethodsList[$scope][CRestUtil::PLACEMENTS], CASE_UPPER);
207 }
208 }
209 }
210
211 return self::$arMethodsList;
212 }
213
214 public static function getProfile($params, $n, CRestServer $server)
215 {
216 global $USER;
217
218 if(!$USER->isAuthorized())
219 {
220 throw new AccessException("User authorization required");
221 }
222
223 $dbRes = CUser::getById($USER->getId());
224 $userInfo = $dbRes->fetch();
225
226 $result = array();
227
228 if($userInfo['ACTIVE'] == 'Y')
229 {
230 $result = array(
231 'ID' => $userInfo['ID'],
232 'ADMIN' => CRestUtil::isAdmin(),
233 'NAME' => $userInfo['NAME'],
234 'LAST_NAME' => $userInfo['LAST_NAME'],
235 'PERSONAL_GENDER' => $userInfo['PERSONAL_GENDER'],
236 'TIME_ZONE' => $userInfo['TIME_ZONE'],
237 );
238
239 if($userInfo['PERSONAL_PHOTO'] > 0)
240 {
241 $result['PERSONAL_PHOTO'] = CRestUtil::GetFile($userInfo["PERSONAL_PHOTO"]);
242 }
243
244 $securityState = array(
245 "ID" => $result['ID'],
246 "NAME" => $result['NAME'],
247 "LAST_NAME" => $result['LAST_NAME'],
248 );
249
250 $server->setSecurityState($securityState);
251 }
252
253 return $result;
254 }
255
256
257 public static function methodsBatch($arQuery, $start, CRestServer $server)
258 {
259 $arQuery = array_change_key_case($arQuery, CASE_UPPER);
260
261 $bHalt = isset($arQuery['HALT']) && $arQuery['HALT'];
262
263 $arResult = [
264 'result' => [],
265 'next' => [],
266 'total' => [],
267 'time' => [],
268 'error' => [],
269 ];
270 if (isset($arQuery['CMD']))
271 {
272 $cnt = 0;
273
274 $authData = $server->getAuth();
275 foreach ($arQuery['CMD'] as $key => $call)
276 {
277 if (($cnt++) < CRestUtil::BATCH_MAX_LENGTH)
278 {
279 if (!is_string($call))
280 {
281 continue;
282 }
283 $queryData = parse_url($call);
284
285 $method = $queryData['path'];
286 $query = $queryData['query'];
287
288 $arParams = CRestUtil::ParseBatchQuery($query, $arResult);
289 if (method_exists('CSecurityFilter', 'processVar'))
290 {
291 $arParams = CSecurityFilter::processVar($arParams);
292 }
293
294 if (
295 $method === CRestUtil::METHOD_DOWNLOAD
296 || $method === CRestUtil::METHOD_UPLOAD
297 || $method === Client::METHOD_BATCH
298 )
299 {
300 $res = [
301 'error' => self::ERROR_BATCH_METHOD_NOT_ALLOWED,
302 'error_description' => 'Method is not allowed for batch usage',
303 ];
304 }
305 else
306 {
307 if (is_array($authData))
308 {
309 foreach($authData as $authParam => $authValue)
310 {
311 $arParams[$authParam] = $authValue;
312 }
313 }
314
315 $methods = [mb_strtolower($method), $method];
316
317 // try lowercase first, then original
318 foreach ($methods as $restMethod)
319 {
320 $pseudoServer = new CRestServerBatchItem([
321 'CLASS' => __CLASS__,
322 'METHOD' => $restMethod,
323 'QUERY' => $arParams
324 ], false);
325 $pseudoServer->setApplicationId($server->getClientId());
326 $pseudoServer->setAuthKeys(array_keys($authData));
327 $pseudoServer->setAuthData($server->getAuthData());
328 $pseudoServer->setAuthType($server->getAuthType());
329 $res = $pseudoServer->process();
330
331 unset($pseudoServer);
332
333 // try original controller name if lower is not found
334 if (
335 is_array($res)
336 && !empty($res['error'])
337 && $res['error'] === 'ERROR_METHOD_NOT_FOUND'
338 )
339 {
340 continue;
341 }
342
343 // output result
344 break;
345 }
346 }
347 }
348 else
349 {
350 $res = [
351 'error' => self::ERROR_BATCH_LENGTH_EXCEEDED,
352 'error_description' => 'Max batch length exceeded',
353 ];
354 }
355
356 if (is_array($res))
357 {
358 if (isset($res['error']))
359 {
360 $res['error'] = $res;
361 }
362
363 foreach ($res as $k=>$v)
364 {
365 $arResult[$k][$key] = $v;
366 }
367 }
368
369 if (isset($res['error']) && $res['error'] && $bHalt)
370 {
371 break;
372 }
373 }
374 }
375
376 return [
377 'result' => $arResult['result'],
378 'result_error' => $arResult['error'],
379 'result_total' => $arResult['total'],
380 'result_next' => $arResult['next'],
381 'result_time' => $arResult['time'],
382 ];
383 }
384
385 public static function scopeList($arQuery, $n, CRestServer $server)
386 {
387 $arQuery = array_change_key_case($arQuery, CASE_UPPER);
388
389 if(isset($arQuery['FULL']) && $arQuery['FULL'])
390 {
391 $arScope = ScopeManager::getInstance()->listScope();
392 }
393 else
394 {
395 $arScope = self::getScope($server);
396 }
397
398 return $arScope;
399 }
400
401 public static function methodsList($arQuery, $n, CRestServer $server)
402 {
403 $arMethods = $server->getServiceDescription();
404
405 $arScope = array(CRestUtil::GLOBAL_SCOPE);
406 $arResult = array();
407
408 $arQuery = array_change_key_case($arQuery, CASE_UPPER);
409
410 if(isset($arQuery['SCOPE']))
411 {
412 if($arQuery['SCOPE'] != '')
413 $arScope = array($arQuery['SCOPE']);
414 }
415 elseif(isset($arQuery['FULL']) && $arQuery['FULL'])
416 {
417 $arScope = array_keys($arMethods);
418 }
419 else
420 {
421 $arScope = self::getScope($server);
422 $arScope[] = CRestUtil::GLOBAL_SCOPE;
423 }
424
425 foreach ($arMethods as $scope => $arScopeMethods)
426 {
427 if(in_array($scope, $arScope))
428 {
429 unset($arScopeMethods[CRestUtil::METHOD_DOWNLOAD]);
430 unset($arScopeMethods[CRestUtil::METHOD_UPLOAD]);
431 unset($arScopeMethods[CRestUtil::EVENTS]);
432 unset($arScopeMethods[CRestUtil::PLACEMENTS]);
433
434 foreach($arScopeMethods as $method => $methodDesc)
435 {
436 if(isset($methodDesc["options"]["private"]) && $methodDesc["options"]["private"] === true)
437 {
438 unset($arScopeMethods[$method]);
439 }
440 }
441
442 $arResult = array_merge($arResult, array_keys($arScopeMethods));
443 }
444 }
445
446 return $arResult;
447 }
448
449 public static function getMethod($query, $n, CRestServer $server): array
450 {
451 $result = [
452 'isExisting' => false,
453 'isAvailable' => false,
454 ];
455 $name = $query['name'] ?? '';
456 if (!empty($name))
457 {
458 $currentScope = self::getScope($server);
459 $currentScope[] = CRestUtil::GLOBAL_SCOPE;
460 $cache = Cache::createInstance();
461 if ($cache->initCache(
462 ScopeManager::CACHE_TIME,
463 'info' . md5($name . implode('|', $currentScope)),
464 ScopeManager::CACHE_DIR . 'method/'
465 ))
466 {
467 $result = $cache->getVars();
468 }
469 elseif ($cache->startDataCache())
470 {
471 $method = ScopeManager::getInstance()->getMethodInfo($name);
472
473 $arMethods = $server->getServiceDescription();
474 foreach ($arMethods as $scope => $methodList)
475 {
476 if (!empty($methodList[$name]))
477 {
478 if (in_array($scope, $currentScope, true))
479 {
480 $result['isAvailable'] = true;
481 }
482 $result['isExisting'] = true;
483 }
484 }
485
486 if (!$result['isExisting'])
487 {
488 $request = new HttpRequest(
489 Context::getCurrent()->getServer(),
490 [
491 'action' => $method['method'],
492 ],
493 [],
494 [],
495 []
496 );
497 $router = new Router($request);
498
500 [$controller, $action] = Resolver::getControllerAndAction(
501 $router->getVendor(),
502 $router->getModule(),
503 $router->getAction(),
504 Controller::SCOPE_REST
505 );
506 if ($controller)
507 {
508 if (in_array($method['scope'], $currentScope, true))
509 {
510 $result['isAvailable'] = true;
511 }
512 $result['isExisting'] = true;
513 }
514 }
515
516 $cache->endDataCache($result);
517 }
518 }
519
520 return $result;
521 }
522
523 public static function appInfo($params, $n, CRestServer $server)
524 {
525 $licensePrevious = '';
527 {
528 $result = self::getBitrix24LicenseName();
529 $license = $result['LICENSE'];
530
531 if ($result['TYPE'] == 'demo')
532 {
533 $result = self::getBitrix24LicenseName(CBitrix24::LICENSE_TYPE_PREVIOUS);
534 $licensePrevious = $result['LICENSE'];
535 }
536 }
537 else
538 {
539 $license = LANGUAGE_ID.'_selfhosted';
540 }
541
542 if($server->getClientId())
543 {
544 $arApp = self::getApp($server);
545
547
548 $res = array(
549 'ID' => $arApp['ID'],
550 'CODE' => $arApp['CODE'],
551 'VERSION' => intval($arApp['VERSION']),
552 'STATUS' => $info['STATUS'],
553 'INSTALLED' => $arApp['INSTALLED'] == \Bitrix\Rest\AppTable::INSTALLED,
554 'PAYMENT_EXPIRED' => $info['PAYMENT_EXPIRED'],
555 'DAYS' => $info['DAYS_LEFT'],
556 'LANGUAGE_ID' => CRestUtil::getLanguage(),
557 'LICENSE' => $license,
558 );
559 if ($licensePrevious)
560 {
561 $res['LICENSE_PREVIOUS'] = $licensePrevious;
562 }
563 if (CModule::IncludeModule('bitrix24'))
564 {
565 $res['LICENSE_TYPE'] = CBitrix24::getLicenseType();
566 $res['LICENSE_FAMILY'] = CBitrix24::getLicenseFamily();
567 }
568
569 $server->setSecurityState($res);
570 }
571 elseif($server->getPasswordId())
572 {
573 $res = array(
574 'SCOPE' => static::getScope($server),
575 'LICENSE' => $license,
576 );
577 }
578 else
579 {
580 throw new AccessException("Application context required");
581 }
582
583 foreach(GetModuleEvents('rest', 'OnRestAppInfo', true) as $event)
584 {
585 $eventData = ExecuteModuleEventEx($event, array($server, &$res));
586 if(is_array($eventData))
587 {
588 if(!isset($res['ADDITIONAL']))
589 {
590 $res['ADDITIONAL'] = array();
591 }
592
593 $res['ADDITIONAL'] = array_merge($res['ADDITIONAL'], $eventData);
594 }
595 }
596
597 return $res;
598 }
599
612 public static function getFeature($params, $n, CRestServer $server)
613 {
614 $params = array_change_key_case($params, CASE_UPPER);
615 $result = [
616 'value' => '',
617 ];
618 if (empty($params['CODE']))
619 {
620 throw new RestException(
621 'CODE can\'t be empty',
622 'CODE_EMPTY',
623 CRestServer::STATUS_WRONG_REQUEST
624 );
625 }
626
628 {
629 $result['value'] = \Bitrix\Bitrix24\Feature::isFeatureEnabled($params['CODE']) ? 'Y' : 'N';
630 }
631 else
632 {
633 foreach (GetModuleEvents('rest', 'onRestGetFeature', true) as $event)
634 {
635 $eventData = ExecuteModuleEventEx(
636 $event,
637 [
638 $params['CODE'],
639 ]
640 );
641 if (is_array($eventData))
642 {
643 if ($eventData['value'] === true || $eventData['value'] === 'Y')
644 {
645 $result['value'] = 'Y';
646 }
647 else
648 {
649 $result['value'] = 'N';
650 }
651 }
652 }
653
654 if (empty($result['value']))
655 {
656 $result['value'] = LANGUAGE_ID . '_selfhosted';
657 }
658 }
659
660 return $result;
661 }
662
674 public static function appOptionGet($params, $n, CRestServer $server)
675 {
676 global $USER;
677
678 if(!$server->getClientId())
679 {
680 throw new AccessException("Application context required");
681 }
682
683 if(!$USER->IsAuthorized())
684 {
685 throw new AccessException("User authorization required");
686 }
687
688 $appOptions = Option::get("rest", "options_".$server->getClientId());
689
690 if($appOptions <> '')
691 {
692 $appOptions = unserialize($appOptions, ['allowed_classes' => false]);
693 }
694 else
695 {
696 $appOptions = array();
697 }
698
699 if(isset($params['option']))
700 {
701 return $appOptions[$params['option']] ?? null;
702 }
703 else
704 {
705 return $appOptions;
706 }
707 }
708
721 public static function appOptionSet($params, $n, CRestServer $server)
722 {
723 if(!$server->getClientId())
724 {
725 throw new AccessException("Application context required");
726 }
727
728 if(!isset($params["options"]))
729 {
730 $params['options'] = $params;
731 }
732
733 if(count($params['options']) <= 0)
734 {
735 throw new Exceptions\ArgumentNullException('options');
736 }
737
738 if(CRestUtil::isAdmin())
739 {
740 $appOptions = Option::get("rest", "options_".$server->getClientId());
741 if($appOptions <> '')
742 {
743 $appOptions = unserialize($appOptions, ['allowed_classes' => false]);
744 }
745 else
746 {
747 $appOptions = array();
748 }
749
750 foreach($params['options'] as $key => $value)
751 {
752 $appOptions[$key] = $value;
753 }
754
755 Option::set('rest', "options_".$server->getClientId(), serialize($appOptions));
756 }
757 else
758 {
759 throw new AccessException("Administrator authorization required");
760 }
761
762 return true;
763 }
764
776 public static function userOptionGet($params, $n, CRestServer $server)
777 {
778 global $USER;
779
780 if(!$server->getClientId())
781 {
782 throw new AccessException("Application context required");
783 }
784
785 if(!$USER->IsAuthorized())
786 {
787 throw new AccessException("User authorization required");
788 }
789
790 $userOptions = CUserOptions::GetOption("app_options", "options_".$server->getClientId(), array());
791
792 if(isset($params['option']))
793 {
794 return $userOptions[$params['option']] ?? null;
795 }
796 else
797 {
798 return $userOptions;
799 }
800 }
801
814 public static function userOptionSet($params, $n, CRestServer $server)
815 {
816 global $USER;
817
818 if(!$server->getClientId())
819 {
820 throw new AccessException("Application context required");
821 }
822
823 if(!$USER->IsAuthorized())
824 {
825 throw new AccessException("User authorization required");
826 }
827
828 if(!isset($params["options"]))
829 {
830 $params['options'] = $params;
831 }
832
833 if(count($params['options']) <= 0)
834 {
835 throw new ArgumentNullException('options');
836 }
837
838 $userOptions = CUserOptions::GetOption("app_options", "options_".$server->getClientId(), array());
839
840 foreach($params['options'] as $key => $value)
841 {
842 $userOptions[$key] = $value;
843 }
844
845 CUserOptions::SetOption("app_options", "options_".$server->getClientId(), $userOptions);
846
847 return true;
848 }
849
850 public static function getServerTime($params)
851 {
852 return date('c', time());
853 }
854
855 public static function OnAppEvent($arParams, $arHandler)
856 {
857 $arEventFields = $arParams[0];
858 if($arEventFields['APP_ID'] == $arHandler['APP_ID'] || $arEventFields['APP_ID'] == $arHandler['APP_CODE'])
859 {
860 $arEventFields["LANGUAGE_ID"] = CRestUtil::getLanguage();
861
862 unset($arEventFields['APP_ID']);
863 return $arEventFields;
864 }
865 else
866 {
867 throw new Exception('Wrong app!');
868 }
869 }
870
871 public static function OnAppPayment($arParams, $arHandler)
872 {
873 if($arParams[0] == $arHandler['APP_ID'])
874 {
875 $app = \Bitrix\Rest\AppTable::getByClientId($arHandler['APP_ID']);
876 if($app)
877 {
879
880 return array(
881 'CODE' => $app['CODE'],
882 'VERSION' => intval($app['VERSION']),
883 'STATUS' => $info['STATUS'],
884 'PAYMENT_EXPIRED' => $info['PAYMENT_EXPIRED'],
885 'DAYS' => $info['DAYS_LEFT']
886 );
887 }
888 }
889
890 throw new Exception('Wrong app!');
891 }
892
893 private static function getBitrix24LicenseName($licenseType = CBitrix24::LICENSE_TYPE_CURRENT)
894 {
895 if (!\Bitrix\Main\ModuleManager::isModuleInstalled('bitrix24'))
896 {
897 return null;
898 }
899
900 $licenseOption = ($licenseType == CBitrix24::LICENSE_TYPE_CURRENT? "~controller_group_name": "~prev_controller_group_name");
901
902 $licenseInfo = COption::GetOptionString("main", $licenseOption);
903
904 [$lang, $licenseName, $additional] = explode("_", $licenseInfo, 3);
905
906 if(!array_key_exists($licenseName, static::$licenseList))
907 {
908 $licenseName = static::LICENSE_DEFAULT;
909 }
910
911 if(!$lang)
912 {
913 $lang = LANGUAGE_ID;
914 }
915
916 return [
917 'LANG' => $lang,
918 'TYPE' => static::$licenseList[$licenseName],
919 'LICENSE' => $lang."_".static::$licenseList[$licenseName]
920 ];
921 }
922
923 protected static function getApp(CRestServer $server)
924 {
925 if(self::$arApp == null)
926 {
927 if (
928 \Bitrix\Rest\Integration\OAuthModule::isSupported()
929 && CModule::IncludeModule('oauth')
930 )
931 {
932 $client = OAuth\Base::instance($server->getClientId());
933
934 if($client)
935 {
936 self::$arApp = $client->getClient();
937
938 if(is_array(self::$arApp) && is_array(self::$arApp['SCOPE']))
939 {
940 self::$arApp['SCOPE'] = implode(',', self::$arApp['SCOPE']);
941 }
942 }
943 }
944 elseif($server->getClientId())
945 {
946 self::$arApp = \Bitrix\Rest\AppTable::getByClientId($server->getClientId());
947 }
948 else
949 {
950 throw new AccessException("Application context required");
951 }
952 }
953
954 return self::$arApp;
955 }
956
957 protected static function getScope(CRestServer $server)
958 {
959 return $server->getAuthScope();
960 }
961}
$arParams
Определения access_dialog.php:21
$arResult
Определения generate_coupon.php:16
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
static set($moduleId, $name, $value="", $siteId="")
Определения option.php:261
Определения loader.php:13
static includeModule($moduleName)
Определения loader.php:67
static isModuleInstalled($moduleName)
Определения modulemanager.php:125
static getAppStatusInfo($app, $detailUrl)
Определения app.php:713
const INSTALLED
Определения app.php:71
static getByClientId($clientId)
Определения app.php:967
const CATEGORY_IMPORTANT
Определения sqs.php:12
static GetOptionString($module_id, $name, $def="", $site=false, $bExactSite=false)
Определения option.php:8
Определения rest_provider.php:20
static getServerTime($params)
Определения rest_provider.php:850
static getApp(CRestServer $server)
Определения rest_provider.php:923
getDescription()
Определения rest_provider.php:64
const ERROR_BATCH_LENGTH_EXCEEDED
Определения rest_provider.php:21
static getFeature($params, $n, CRestServer $server)
Определения rest_provider.php:612
static getProfile($params, $n, CRestServer $server)
Определения rest_provider.php:214
static $arScope
Определения rest_provider.php:61
static getScope(CRestServer $server)
Определения rest_provider.php:957
static appOptionSet($params, $n, CRestServer $server)
Определения rest_provider.php:721
static userOptionSet($params, $n, CRestServer $server)
Определения rest_provider.php:814
const ERROR_BATCH_METHOD_NOT_ALLOWED
Определения rest_provider.php:22
static OnAppPayment($arParams, $arHandler)
Определения rest_provider.php:871
static methodsList($arQuery, $n, CRestServer $server)
Определения rest_provider.php:401
static $arApp
Определения rest_provider.php:60
static $arMethodsList
Определения rest_provider.php:62
static OnAppEvent($arParams, $arHandler)
Определения rest_provider.php:855
const LICENSE_DEFAULT
Определения rest_provider.php:25
static scopeList($arQuery, $n, CRestServer $server)
Определения rest_provider.php:385
static $licenseList
Определения rest_provider.php:28
static userOptionGet($params, $n, CRestServer $server)
Определения rest_provider.php:776
static appInfo($params, $n, CRestServer $server)
Определения rest_provider.php:523
static methodsBatch($arQuery, $start, CRestServer $server)
Определения rest_provider.php:257
static appOptionGet($params, $n, CRestServer $server)
Определения rest_provider.php:674
Определения rest.php:847
Определения rest.php:24
getServiceDescription()
Определения rest.php:397
getAuthData()
Определения rest.php:324
getAuth()
Определения rest.php:319
getAuthScope()
Определения rest.php:329
getPasswordId()
Определения rest.php:367
getAuthType()
Определения rest.php:347
setSecurityState($state=null)
Определения rest.php:382
getClientId()
Определения rest.php:362
Определения rest.php:896
</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
$start
Определения get_search.php:9
$query
Определения get_search.php:11
$app
Определения proxy.php:8
global $USER
Определения csv_new_run.php:40
if(!defined('SITE_ID')) $lang
Определения include.php:91
if(file_exists(( $_fname=__DIR__ . "/classes/general/update_db_updater.php"))) if(($_fname=getLocalPath("init.php")) !==false) if(( $_fname=getLocalPath("php_interface/init.php", BX_PERSONAL_ROOT)) !==false) if(($_fname=getLocalPath("php_interface/" . SITE_ID . "/init.php", BX_PERSONAL_ROOT)) !==false) if((!(defined("STATISTIC_ONLY") &&STATISTIC_ONLY &&!str_starts_with( $GLOBALS["APPLICATION"]->GetCurPage(), BX_ROOT . "/admin/"))) &&COption::GetOptionString("main", "include_charset", "Y")=="Y" &&LANG_CHARSET !='') if(COption::GetOptionString("main", "set_p3p_header", "Y")=="Y") $license
Определения include.php:158
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения backup.php:924
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
$name
Определения menu_edit.php:35
Определения culture.php:9
Определения handlers.php:8
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$router
Определения routing_index.php:31
</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
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$method
Определения index.php:27
$k
Определения template_pdf.php:567
$action
Определения file_dialog.php:21
$n
Определения update_log.php:107
$dbRes
Определения yandex_detail.php:168