diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index d9e30282..801774e1 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -1089,7 +1089,14 @@ class ICrmOrderActions */ public static function orderAgent() { - if(self::isForkable()) { + $rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y')); + $defaultSite = array(); + while ($ar = $rsSites->Fetch()) { + $defaultSite = $ar; + break; + } + + if(self::isForkable($defaultSite)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ($_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/retailcrm/agent.php'); @@ -1529,14 +1536,21 @@ class ICrmOrderActions * Returns true if a not a crontab * or if $dir exists */ - public static function isForkable() { - $fork = COption::GetOptionString('main', 'agents_use_crontab', 'N'); - if($fork === 'N') { - $file = $_SERVER['DOCUMENT_ROOT'] . '/retailcrm/agent.php'; - return file_exists($file) && is_callable('curl_init') && - isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']; + public static function isForkable($defaultSite = array()) { + $docRoot = !empty($defaultSite) ? $defaultSite['ABS_DOC_ROOT'] : $_SERVER['DOCUMENT_ROOT']; + if(!empty($defaultSite)) { + $serverName = $defaultSite['SERVER_NAME']; + } else { + if(isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']) + $serverName = $_SERVER['SERVER_NAME']; + else + $serverName = ''; } + $fork = COption::GetOptionString('main', 'agents_use_crontab', 'N'); + if($fork === 'N') + return file_exists($docRoot . '/retailcrm/agent.php') && is_callable('curl_init') && $serverName; + return false; } } diff --git a/intaro.intarocrm/classes/general/agent.php b/intaro.intarocrm/classes/general/agent.php index 20c01898..48f78fd9 100755 --- a/intaro.intarocrm/classes/general/agent.php +++ b/intaro.intarocrm/classes/general/agent.php @@ -1,4 +1,5 @@ MODULE_ID . '/install/export/', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/', true, true ); - if(mkdir($_SERVER['DOCUMENT_ROOT'] . '/retailcrm/')) { + $rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y')); + $defaultSite = array(); + while ($ar = $rsSites->Fetch()) { + $defaultSite = $ar; + break; + } + + if(mkdir($defaultSite['ABS_DOC_ROOT'] . '/retailcrm/')) { CopyDirFiles( - $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/retailcrm/', $_SERVER['DOCUMENT_ROOT'] . '/retailcrm/', true, true + $defaultSite['ABS_DOC_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/retailcrm/', $defaultSite['ABS_DOC_ROOT'] . '/retailcrm/', true, true ); } } function DeleteFiles() { + $rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y')); + $defaultSite = array(); + while ($ar = $rsSites->Fetch()) { + $defaultSite = $ar; + break; + } + unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_run.php'); unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/intarocrm_setup.php'); - unlink($_SERVER['DOCUMENT_ROOT'] . '/retailcrm/agent.php'); - rmdir($_SERVER['DOCUMENT_ROOT'] . '/retailcrm/'); + unlink($defaultSite['ABS_DOC_ROOT'] . '/retailcrm/agent.php'); + rmdir($defaultSite['ABS_DOC_ROOT'] . '/retailcrm/'); } function GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesUnitProduct, $propertiesSKU, $propertiesUnitSKU, $filename) {