From 6f4f617d6af4c3a106c3df541d4139b4951f10c6 Mon Sep 17 00:00:00 2001
From: Grisha Pomadchin <gr.pomadchin@gmail.com>
Date: Thu, 18 Jul 2013 23:03:08 +0400
Subject: [PATCH] host url fix.

---
 intaro.intarocrm/install/index.php | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php
index 4b4a9286..b049cf2d 100755
--- a/intaro.intarocrm/install/index.php
+++ b/intaro.intarocrm/install/index.php
@@ -75,6 +75,10 @@ class intaro_intarocrm extends CModule
             $api_host = htmlspecialchars(trim($_POST[$this->CRM_API_HOST_OPTION]));
             $api_key = htmlspecialchars(trim($_POST[$this->CRM_API_KEY_OPTION]));
             
+            // form correct url
+            $api_host = parse_url($api_host);
+            $api_host = $api_host['scheme'] . '://' . $api_host['host'];
+            
             if(!$api_host || !$api_key) { 
                 $arResult['errCode'] = 'ERR_FIELDS_API_HOST';
                 $APPLICATION->IncludeAdminFile(
@@ -100,10 +104,6 @@ class intaro_intarocrm extends CModule
                 return;
             }
             
-            // form correct url
-            $api_host = parse_url($api_host);
-            $api_host = $api_host['scheme'] . '://' . $api_host['host'];
-            
             COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host);
             COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key);
             
@@ -348,6 +348,7 @@ class intaro_intarocrm extends CModule
             GetMessage('MODULE_UNINSTALL_TITLE'), 
             $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/unstep1.php'
         );	
+        
     }
 
     function CopyFiles() {