Exemplo n.º 1
0
 public function DoInstall()
 {
     if ($GLOBALS['APPLICATION']->GetGroupRight('main') < 'W') {
         return;
     }
     if (is_array($this->NEED_MODULES) && !empty($this->NEED_MODULES)) {
         foreach ($this->NEED_MODULES as $module) {
             if (!IsModuleInstalled($module)) {
                 $this->ShowForm('ERROR', $this->GetMessage('DDELIVERY_NEED_MODULES', array('#MODULE#' => $module, '#NEED#' => $this->NEED_MODULES)));
                 return;
             }
             include $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $module . '/install/version.php';
             if (!CheckVersion($arModuleVersion['VERSION'], $this->NEED_MAIN_VERSION)) {
                 $this->ShowForm('ERROR', $this->GetMessage('DDELIVERY_NEED_MODULES', array('#MODULE#' => $module, '#NEED#' => $this->NEED_MAIN_VERSION)));
                 return;
             }
         }
     }
     if (!function_exists('curl_init')) {
         $this->ShowForm('ERROR', $this->GetMessage('DDELIVERY_NEED_MODULES_CURL', array('#MODULE#' => 'cURL')));
         return;
     }
     if (CheckVersion(SM_VERSION, $this->NEED_MAIN_VERSION)) {
         RegisterModuleDependences('sale', 'onSaleDeliveryHandlersBuildList', self::MODULE_ID, 'DDeliveryEvents', 'Init');
         RegisterModuleDependences('sale', 'OnOrderNewSendEmail', self::MODULE_ID, 'DDeliveryEvents', 'OnOrderNewSendEmail');
         RegisterModuleDependences('sale', 'OnSaleBeforeStatusOrder', self::MODULE_ID, 'DDeliveryEvents', 'OnSaleBeforeStatusOrder');
         if (!symlink(__DIR__ . "/components/ddelivery", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components/ddelivery")) {
             CopyDirFiles(__DIR__ . "/components", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components", true, true);
         }
         RegisterModule(self::MODULE_ID);
         CModule::IncludeModule("sale");
         $ddeliveryConfig = CSaleDeliveryHandler::GetBySID('ddelivery')->Fetch();
         $ddeliveryConfig['ACTIVE'] = 'N';
         CSaleDeliveryHandler::Set('ddelivery', $ddeliveryConfig, false);
         include_once __DIR__ . '/../include.php';
         include_once __DIR__ . '/../DDeliveryEvents.php';
         include_once __DIR__ . '/../DDeliveryShop.php';
         // Добавляем свойства в бд
         CSaleOrderProps::add(array('PERSON_TYPE_ID' => '1', 'NAME' => 'DDelivery LocalID', 'TYPE' => 'TEXT', 'REQUIED' => 'N', 'DEFAULT_VALUE' => '', 'SORT' => '10000', 'USER_PROPS' => 'N', 'IS_LOCATION' => 'N', 'PROPS_GROUP_ID' => '2', 'IS_EMAIL' => 'N', 'IS_PROFILE_NAME' => 'N', 'IS_PAYER' => 'N', 'IS_LOCATION4TAX' => 'N', 'IS_ZIP' => 'N', 'CODE' => 'DDELIVERY_ID', 'IS_FILTERED' => 'Y', 'ACTIVE' => 'Y', 'UTIL' => 'Y', 'INPUT_FIELD_LOCATION' => '0', 'MULTIPLE' => 'N'));
         $IntegratorShop = new DDeliveryShop($ddeliveryConfig['CONFIG']['CONFIG'], array(), array());
         $ddeliveryUI = new DDeliveryUI($IntegratorShop, true);
         $ddeliveryUI->createTables();
         $this->ShowForm('OK', GetMessage('MOD_INST_OK'), true);
     } else {
         $this->ShowForm('ERROR', $this->GetMessage('DDELIVERY_NEED_RIGHT_VER', array('#NEED#' => $this->NEED_MAIN_VERSION)));
     }
 }