21Loc::loadMessages(__FILE__);
33 self::$contextUserId = $id;
36 public static function install(
$code, $version =
false, $checkHash =
false, $installHash =
false, $from =
null) :
array
50 'error' => $e->getCode(),
51 'errorDescription' => $e->getMessage(),
58 $version = !empty($version) ? $version :
false;
61 'error' =>
'INSTALL_ERROR',
62 'errorDescription' => Loc::getMessage(
'RMP_INSTALL_ERROR'),
65 $appDetailInfo =
false;
68 if (!empty($checkHash) && !empty($installHash))
79 $appDetailInfo = $appDetailInfo[
'ITEMS'];
85 && !Access::canInstallApp($appDetailInfo)
89 'error' =>
'ACTION_ACCESS_DENIED',
90 'errorDescription' => Loc::getMessage(
'RMP_ERROR_ACCESS_DENIED'),
91 'helperCode' => Access::getHelperCode(Access::ACTION_INSTALL, Access::ENTITY_TYPE_APP, $appDetailInfo)
96 if (CRestUtil::canInstallApplication($appDetailInfo, self::$contextUserId))
99 'CLIENT_ID' => $appDetailInfo[
'APP_CODE'],
100 'VERSION' => $appDetailInfo[
'VER'],
101 'BY_SUBSCRIPTION' => $appDetailInfo[
'BY_SUBSCRIPTION'] ??
'N',
104 if (!empty($checkHash) && !empty($installHash))
106 $queryFields[
'CHECK_HASH'] = $checkHash;
107 $queryFields[
'INSTALL_HASH'] = $installHash;
111 if (isset($installResult[
'error']) && $installResult[
'error'] ===
'verification_needed')
119 defined(
'ADMIN_SECTION')
120 && $appDetailInfo[
'TYPE'] ===
'C'
121 && $appDetailInfo[
'MODE'] ===
'S'
122 && mb_strpos($appDetailInfo[
'CODE'],
'bitrix.') === 0
127 'client_id' => $appDetailInfo[
'APP_CODE'],
128 'version' => (int)$appDetailInfo[
'VER'],
130 'scope' => array_keys($appDetailInfo[
'RIGHTS']),
136 if (isset($installResult[
'error']) && $installResult[
'error'])
138 $result[
'error'] = $installResult[
'error'];
139 $result[
'errorDescription'] = $installResult[
'error_description'];
141 elseif ($installResult[
'result'])
144 'CLIENT_ID' => $installResult[
'result'][
'client_id'],
145 'CODE' => $appDetailInfo[
'CODE'],
147 'INSTALLED' => ($appDetailInfo[
'OPEN_API'] ===
'Y' || empty($appDetailInfo[
'INSTALL_URL']))
150 'URL' => $appDetailInfo[
'URL'],
151 'URL_DEMO' => $appDetailInfo[
'DEMO_URL'],
152 'URL_INSTALL' => $appDetailInfo[
'INSTALL_URL'],
153 'URL_SETTINGS' => $appDetailInfo[
'SETTINGS_URL'],
154 'VERSION' => $installResult[
'result'][
'version'],
155 'SCOPE' => implode(
',', $installResult[
'result'][
'scope']),
156 'STATUS' => $installResult[
'result'][
'status'],
157 'SHARED_KEY' => $appDetailInfo[
'SHARED_KEY'],
158 'CLIENT_SECRET' =>
'',
159 'APP_NAME' => $appDetailInfo[
'NAME'],
169 $appFields[
'DATE_FINISH'] = DateTime::createFromTimestamp($installResult[
'result'][
'date_finish']);
173 $appFields[
'DATE_FINISH'] =
'';
191 $addResult = AppTable::update($existingApp[
'ID'], $appFields);
195 $addResult = AppTable::add($appFields);
198 if ($addResult->isSuccess())
200 $appId = $addResult->getId();
216 if (!CRestUtil::isAdmin(self::$contextUserId))
218 CRestUtil::notifyInstall($appFields);
221 if (isset($appDetailInfo[
'MENU_TITLE']) && is_array($appDetailInfo[
'MENU_TITLE']))
223 foreach ($appDetailInfo[
'MENU_TITLE'] as
$lang => $langName)
225 $appLangFields =
array(
227 'LANGUAGE_ID' =>
$lang,
228 'MENU_NAME' => $langName
231 $appLangUpdateFields =
array(
232 'MENU_NAME' => $langName
236 $queries =
$connection->getSqlHelper()->prepareMerge(
246 foreach($queries as
$query)
253 if ($appDetailInfo[
'OPEN_API'] ===
'Y' && !empty($appFields[
'URL_INSTALL']))
259 'EVENT_NAME' =>
'ONAPPINSTALL',
260 'EVENT_HANDLER' => $appFields[
'URL_INSTALL'],
265 Sender::bind(
'rest',
'OnRestAppInstall');
279 $uriString = CRestUtil::getApplicationPage($appId);
281 $ver = (int) $version;
285 'check_hash' => $checkHash,
286 'install_hash' => $installHash
289 $redirect =
$uri->getUri();
290 $open = $appDetailInfo[
'OPEN_API'] !==
'Y';
294 if ((
int)$appDetailInfo[
'IMPORT_ZIP_ID'] > 0)
304 if (!empty($checkHash) && !empty($installHash))
308 'check_hash' => $checkHash,
309 'install_hash' => $installHash,
313 $sliderUrl =
$uri->getUri();
321 'redirect' => $redirect,
322 'openSlider' => $sliderUrl,
323 'canShowForm' => $appDetailInfo[
'OPEN_API'] ===
'Y' && !empty($appFields[
'URL_SETTINGS'])
334 $result[
'errorDescription'] = implode(
'<br />', $addResult->getErrorMessages());
339 !empty($appInfo[
'HOLD_INSTALL_BY_TRIAL'])
340 && $appInfo[
'HOLD_INSTALL_BY_TRIAL'] ===
'Y'
344 $result = [
'error' => Loc::getMessage(
'RMP_TRIAL_HOLD_INSTALL')];
349 'error' =>
'ACCESS_DENIED',
350 'errorDescription' => Loc::getMessage(
'RMP_ACCESS_DENIED'),
357 'error' =>
'APPLICATION_NOT_FOUND',
358 'errorDescription' => Loc::getMessage(
'RMP_NOT_FOUND'),
365 'error' =>
'OAUTH_REGISTER',
366 'errorDescription' => Loc::getMessage(
'RMP_INSTALL_ERROR'),
372 if (
$result[
'error'] ===
'SUBSCRIPTION_REQUIRED')
374 $result[
'errorDescription'] = Loc::getMessage(
'RMP_ERROR_SUBSCRIPTION_REQUIRED');
378 $result[
'errorDescription'] = Loc::getMessage(
'RMP_ERROR_VERIFICATION_NEEDED');
387 if (CRestUtil::isAdmin(self::$contextUserId))
389 $res = AppTable::getList(
398 $appInfo =
$res->fetch();
401 $checkResult = AppTable::checkUninstallAvailability($appInfo[
'ID'], $clean);
403 $checkResult->isEmpty()
414 AppTable::update($appInfo[
'ID'], $appFields);
429 foreach ($checkResult as
$error)
437 $checkResult->isEmpty()
451 $result = [
'error' => Loc::getMessage(
'RMP_NOT_FOUND')];
456 $result = [
'error' => Loc::getMessage(
'RMP_ACCESS_DENIED')];
465 if (CRestUtil::isAdmin(self::$contextUserId))
469 !Access::isAvailable($id)
470 || !Access::isAvailableCount(Access::ENTITY_TYPE_APP, $id)
474 'error' => Loc::getMessage(
'RMP_ERROR_ACCESS_DENIED'),
475 'helperCode' => Access::getHelperCode(Access::ACTION_INSTALL, Access::ENTITY_TYPE_APP, $appInfo)
481 \CUserOptions::DeleteOption(
'app_options',
'params_' . $appInfo[
'CLIENT_ID'] .
'_' . $appInfo[
'VERSION']);
483 if (empty($appInfo[
'MENU_NAME']) && empty($appInfo[
'MENU_NAME_DEFAULT']))
488 elseif (!empty($appInfo[
'URL_INSTALL']))
494 AppTable::update($appInfo[
'ID'], $appFields);
498 'redirect' => CRestUtil::getApplicationPage($appInfo[
'ID']),
504 $result = [
'error' => Loc::getMessage(
'RMP_NOT_FOUND')];
509 $result = [
'error' => Loc::getMessage(
'RMP_ACCESS_DENIED')];
519 if (CRestUtil::isAdmin())
524 if ($appInfo[
'CODE'])
539 $result = [
'error' => Loc::getMessage(
'RMP_ACCESS_DENIED')];
548 if (CRestUtil::isAdmin())
561 $result = [
'error' => Loc::getMessage(
'RMP_ACCESS_DENIED')];
static getConnection($name="")
static isModuleInstalled($moduleName)
static logToFile($action, $tag='', $label='', $actionType='')
const ACTION_TYPE_UNINSTALL
static log($appId, $action)
const ACTION_TYPE_INSTALL
static isInstalled(int $appId)
static canUninstallByType($code, $version=false)
static getAppType($code, $version=false)
static getByClientId($clientId)
static uninstall($appId, $clean=0)
static setAccess($appId, $newRights=array())
static install($code, $version=false, $checkHash=false, $installHash=false, $from=null)
static setRights($appId, $rights)
static setContextUserId(int $id)
static uninstall($code, bool $clean=false, $from=null)
static int $contextUserId
static isSubscriptionDemo()
static getInstall($code, $version=false, $checkHash=false, $installHash=false)
static getConfigurationImportAppUrl($code=null)
static getConfigurationImportRollbackUrl($appCode)
static getConfigurationImportZipUrl($zipId, $from='')
static clearHandlerCache()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
if(!defined('SITE_ID')) $lang
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)