1
0
mirror of synced 2024-11-25 14:56:09 +03:00

multiple site fix

This commit is contained in:
Grigory Pomadchin 2014-11-27 18:37:59 +03:00
parent 37634e19a4
commit fa612ab5a4
3 changed files with 40 additions and 11 deletions

View File

@ -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;
}
}

View File

@ -1,4 +1,5 @@
<?php
define('NO_AGENT_CHECK', true);
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');
if ($_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR']) die('You are not allowed to access this file.');
if (!CModule::IncludeModule('intaro.intarocrm')) die('retailCRM not installed.');

View File

@ -1320,18 +1320,32 @@ class intaro_intarocrm extends CModule {
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->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) {