AntonLV 6 лет назад
Родитель
Сommit
3c79fa2d50

+ 5 - 1
inc/classes/BxDolCronUpgradeModulesCheck.php

@@ -14,7 +14,11 @@ class BxDolCronUpgradeModulesCheck extends BxDolCron
         if('on' != getParam('sys_autoupdate'))
             return;
 
-		BxDolStudioInstallerUtils::getInstance()->performModulesUpgrade();
+        BxDolStudioInstallerUtils::getInstance()->performModulesUpgrade(array(
+            'directly' => true,
+            'transient' => true,
+            'autoupdate' => true
+        ));
     }
 }
 

+ 40 - 24
studio/classes/BxDolStudioInstaller.php

@@ -106,7 +106,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
             'update_relations_for_all' => array(
                 'title' => _t('_adm_txt_modules_update_relations_for_all'),
             ),
-			'process_connections' => array(
+            'process_connections' => array(
                 'title' => _t('_adm_txt_modules_process_connections'),
             ),
             'process_deleted_profiles' => array(
@@ -159,6 +159,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check whether the module was already installed ---//
         if($this->oDb->isModule($this->_aConfig['home_uri']))
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_ALREADY_PERFORMED,
                 'message' => _t('_adm_err_modules_already_installed'),
                 'result' => false
             );
@@ -171,6 +172,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check mandatory settings ---//
         if($this->oDb->isModuleParamsUsed($this->_aConfig['home_uri'], $this->_aConfig['home_dir'], $this->_aConfig['db_prefix'], $this->_aConfig['class_prefix']))
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_UNIQUE_PARAMS_USED,
                 'message' => _t('_adm_txt_modules_params_used'),
                 'result' => false
             );
@@ -178,6 +180,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check version compatibility ---//
         if(!$this->_isCompatibleWith())
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_WSV_MI,
                 'message' => $this->_displayResult('check_script_version', false, '_adm_err_modules_wrong_version_script', $bHtmlResponce),
                 'result' => false
             );
@@ -191,9 +194,9 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
             if($aLanguage['uri'] == 'en')
                 continue;
 
-			$aLanguageConfig = self::getModuleConfig(BX_DIRECTORY_PATH_MODULES . $aLanguage['path'] . '/install/config.php');
-			if(empty($aLanguageConfig))
-				continue;
+            $aLanguageConfig = self::getModuleConfig(BX_DIRECTORY_PATH_MODULES . $aLanguage['path'] . '/install/config.php');
+            if(empty($aLanguageConfig))
+                    continue;
 
             if(!isset($aLanguageConfig['includes'][$sModuleUri]) || empty($aLanguageConfig['includes'][$sModuleUri]))
                 continue;
@@ -261,11 +264,12 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check whether the module was already uninstalled ---//
         if(!$this->oDb->isModule($this->_aConfig['home_uri']))
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_ALREADY_PERFORMED,
                 'message' => _t('_adm_err_modules_already_uninstalled'),
                 'result' => false
             );
 
-		if($bAutoDisable) {
+        if($bAutoDisable) {
             $aResultDisable = $this->disable($aParams);
             if(!$aResultDisable['result'])
             	return $aResultDisable;
@@ -362,6 +366,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check whether the module is installed ---//
         if(empty($aModule) || !is_array($aModule))
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_NOT_FOUND,
                 'message' => _t('_adm_err_modules_module_not_installed'),
                 'result' => false
             );
@@ -369,18 +374,19 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check whether the module is already enabled ---//
         if((int)$aModule['enabled'] != 0)
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_ALREADY_PERFORMED,
                 'message' => _t('_adm_err_modules_already_enabled'),
                 'result' => false
             );
 
-		$aResult = array();
-		if(!empty($this->_aConfig['before_enable'])) {
-        	$aResult = $this->_perform('before_enable', $aParams);
-        	if($aResult && !$aResult['result'])
-        		return $aResult;
-		}
+        $aResult = array();
+        if(!empty($this->_aConfig['before_enable'])) {
+            $aResult = $this->_perform('before_enable', $aParams);
+            if($aResult && !$aResult['result'])
+                return $aResult;
+        }
 
-		$aResult = array();
+        $aResult = array();
         bx_alert('system', 'before_enable', 0, false, array ('config' => $this->_aConfig, 'result' => &$aResult));
         if ($aResult && !$aResult['result'])
             return $aResult;
@@ -398,13 +404,13 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
 
             $this->cleanupMemoryAfterAction($aModule['uri'], $aModule['id']);
 
-		    $this->_onEnableAfter();
+            $this->_onEnableAfter();
 
             if(!empty($this->_aConfig['enable_success']))
             	$this->_perform('enable_success', $aParams);
         }
         else {
-        	if(!empty($this->_aConfig['enable_failed']))
+            if(!empty($this->_aConfig['enable_failed']))
             	$this->_perform('enable_failed', $aParams);
         }
 
@@ -423,6 +429,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check whether the module is installed ---//
         if(empty($aModule) || !is_array($aModule))
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_NOT_FOUND,
                 'message' => _t('_adm_err_modules_module_not_installed'),
                 'result' => false
             );
@@ -430,18 +437,19 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         //--- Check whether the module is already disabled ---//
         if((int)$aModule['enabled'] == 0)
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_ALREADY_PERFORMED,
                 'message' => _t('_adm_err_modules_already_disabled'),
                 'result' => false
             );
 
-		$aResult = array();
-		if(!empty($this->_aConfig['before_disable'])) {
-        	$aResult = $this->_perform('before_disable', $aParams);
-        	if($aResult && !$aResult['result'])
-        		return $aResult;
-		}
+        $aResult = array();
+        if(!empty($this->_aConfig['before_disable'])) {
+            $aResult = $this->_perform('before_disable', $aParams);
+            if($aResult && !$aResult['result'])
+                return $aResult;
+        }
 
-		$aResult = array();
+        $aResult = array();
         bx_alert('system', 'before_disable', 0, false, array ('config' => $this->_aConfig, 'result' => &$aResult));
         if ($aResult && !$aResult['result'])
             return $aResult;
@@ -948,12 +956,16 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         return BX_DOL_STUDIO_INSTALLER_SUCCESS;
     }
 
-	protected function _perform($sOperationName, $aParams = array())
+    protected function _perform($sOperationName, $aParams = array())
     {
     	$bHtmlResponce = isset($aParams['html_response']) && (bool)$aParams['html_response'];
 
         if(!defined('BX_SKIP_INSTALL_CHECK') && !defined('BX_DOL_CRON_EXECUTE') && !$GLOBALS['logged']['admin'])
-            return array('message' => '_adm_mod_err_only_admin_can_perform_operations_with_modules', 'result' => false);
+            return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_NOT_AUTHORIZED,
+                'message' => '_adm_mod_err_only_admin_can_perform_operations_with_modules', 
+                'result' => false
+            );
 
         $sMessage = '';
         foreach($this->_aConfig[$sOperationName] as $sAction => $iEnabled) {
@@ -971,7 +983,11 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
 
             //--- On Failed ---//
             $sMethodFailed = $sMethod . 'Failed';
-            return array('message' => $this->_displayResult($sAction, false, method_exists($this, $sMethodFailed) ? $this->$sMethodFailed($mixedResult) : $this->actionOperationFailed($mixedResult), $bHtmlResponce), 'result' => false);
+            return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_SUBACTION_FAILED,
+                'message' => $this->_displayResult($sAction, false, method_exists($this, $sMethodFailed) ? $this->$sMethodFailed($mixedResult) : $this->actionOperationFailed($mixedResult), $bHtmlResponce), 
+                'result' => false
+            );
         }
 
         if($this->_bShowOnSuccess)

+ 261 - 203
studio/classes/BxDolStudioInstallerUtils.php

@@ -16,12 +16,32 @@ define('BX_DOL_STUDIO_IU_RC_SUCCESS', 0);
 define('BX_DOL_STUDIO_IU_RC_FAILED', 1);
 define('BX_DOL_STUDIO_IU_RC_SCHEDULED', 2);
 
+/*
+ * Errors list.
+ * It can be broaden later.
+ */
+define('BX_DOL_STUDIO_IU_RCE_NOT_FOUND', 100);
+define('BX_DOL_STUDIO_IU_RCE_NOT_AVAILABLE', 101);
+define('BX_DOL_STUDIO_IU_RCE_NOT_AUTHORIZED', 102);
+define('BX_DOL_STUDIO_IU_RCE_ALREADY_PERFORMED', 103);
+define('BX_DOL_STUDIO_IU_RCE_UNIQUE_PARAMS_USED', 104);
+define('BX_DOL_STUDIO_IU_RCE_WSV_MI', 105); //--- Wrong script version during module install
+define('BX_DOL_STUDIO_IU_RCE_WSV_MU', 106); //--- Wrong script version during module update
+define('BX_DOL_STUDIO_IU_RCE_WMV', 107); //--- Wrong module version during module update
+define('BX_DOL_STUDIO_IU_RCE_MODIFIED', 108);
+define('BX_DOL_STUDIO_IU_RCE_CHECKSUM_FAILED', 109);
+
+define('BX_DOL_STUDIO_IU_RCE_SUBACTION_FAILED', 200); //--- Error appeared in some subaction
+
+
 class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSingleton
 {
-	protected $bUseFtp;
+    protected $bUseFtp;
+
+    protected $sAuthorizedAccessClass;
+    protected $sStoreDataUrlPublic;
 
-	protected $sAuthorizedAccessClass;
-	protected $sStoreDataUrlPublic;
+    protected $_oLog;
 
     public function __construct()
     {
@@ -32,8 +52,11 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
         $this->bUseFtp = BX_FORCE_USE_FTP_FILE_TRANSFER;
 
-		$this->sAuthorizedAccessClass = 'BxDolStudioOAuthOAuth2';
-		$this->sStoreDataUrlPublic = BX_DOL_MARKET_URL_INTEGRATION;
+        $this->sAuthorizedAccessClass = 'BxDolStudioOAuthOAuth2';
+        $this->sStoreDataUrlPublic = BX_DOL_MARKET_URL_INTEGRATION;
+
+        $this->_oLog = BxDolLog::getInstance();
+        $this->_oLog->setName('upgrade_modules');
     }
 
     /**
@@ -66,7 +89,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
     	return 'sys_download_file_complete_' . $sParam;
     }
 
-	public static function getNamePerformModulesUpgrade()
+    public static function getNamePerformModulesUpgrade()
     {
     	return 'sys_upgrade_modules_transient';
     }
@@ -82,17 +105,17 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
     /*
      * Is used to perform action inside Transient Cron Job.
      */
-	public function servicePerformAction($sDirectory, $sOperation, $aParams)
+    public function servicePerformAction($sDirectory, $sOperation, $aParams)
     {
     	return $this->perform($sDirectory, $sOperation, array_merge($aParams, array('transient' => true)));
     }
 
-	/*
+    /*
      * Is used to perform modules upgrade inside Transient Cron Job.
      */
-	public function servicePerformModulesUpgrade($bEmailNotify)
+    public function servicePerformModulesUpgrade($aParams = array())
     {
-    	return $this->performModulesUpgrade(true, $bEmailNotify);
+        return $this->performModulesUpgrade(array_merge($aParams, array('directly' => true, 'transient' => true)));
     }
 
     public function getStoreDataUrl($sType = 'public')
@@ -102,10 +125,10 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
     public function getAccessObject($bAuthorizedAccess)
     {
-    	$sClass = $bAuthorizedAccess ? $this->sAuthorizedAccessClass : 'BxDolStudioJson';
+        $sClass = $bAuthorizedAccess ? $this->sAuthorizedAccessClass : 'BxDolStudioJson';
 
-		bx_import($sClass);
-		return $sClass::getInstance();
+        bx_import($sClass);
+        return $sClass::getInstance();
     }
 
     public function getModules($bTitleAsKey = true)
@@ -126,7 +149,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
                         if(!is_dir($sPath . $sVendor . '/' . $sModule) || substr($sModule, 0, 1) == '.')
                             continue;
 
-						$sModulePath = $sVendor . '/' . $sModule . '/';
+                        $sModulePath = $sVendor . '/' . $sModule . '/';
                         $aModule = $this->getConfigModule($sPath . $sModulePath . 'install/config.php', !empty($aInstalledInfo[$sModulePath]) ? $aInstalledInfo[$sModulePath] : array());
                         if(empty($aModule))
                             continue;
@@ -162,13 +185,13 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
                         if(!is_dir($sPath . $sVendor . '/' . $sModule) || substr($sModule, 0, 1) == '.')
                             continue;
 
-						$sModulePath = $sVendor . '/' . $sModule . '/';
-						if(empty($aInstalledInfo[$sModulePath]))
-							continue;
+                        $sModulePath = $sVendor . '/' . $sModule . '/';
+                        if(empty($aInstalledInfo[$sModulePath]))
+                            continue;
 
-						$aUpdate = $this->getUpdate($aInstalledInfo[$sModulePath]);
-						if(!empty($aUpdate))
-							$aUpdates[$aUpdate['title']] = $aUpdate;
+                        $aUpdate = $this->getUpdate($aInstalledInfo[$sModulePath]);
+                        if(!empty($aUpdate))
+                            $aUpdates[$aUpdate['title']] = $aUpdate;
                     }
                     closedir($rHandleModule);
                 }
@@ -182,55 +205,55 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
     public function getUpdate($mixedModule)
     {
-    	$aResult = array();
+        $aResult = array();
 
-    	if(!is_array($mixedModule))
-			$mixedModule = BxDolModuleQuery::getInstance()->{is_numeric($mixedModule) ? 'getModuleById' : 'getModuleByName'}($mixedModule); 
+        if(!is_array($mixedModule))
+            $mixedModule = BxDolModuleQuery::getInstance()->{is_numeric($mixedModule) ? 'getModuleById' : 'getModuleByName'}($mixedModule); 
 
-    	if(empty($mixedModule) || !is_array($mixedModule))
-    		return $aResult;
+        if(empty($mixedModule) || !is_array($mixedModule))
+            return $aResult;
 
-    	$sPathModule = BX_DIRECTORY_PATH_MODULES . $mixedModule['path'];
-    	$sPathUpdates = $sPathModule . 'updates/';
+        $sPathModule = BX_DIRECTORY_PATH_MODULES . $mixedModule['path'];
+        $sPathUpdates = $sPathModule . 'updates/';
 
-    	$rHandleUpdate = @opendir($sPathUpdates);
-		if($rHandleUpdate === false)
-			return $aResult; 
+        $rHandleUpdate = @opendir($sPathUpdates);
+        if($rHandleUpdate === false)
+            return $aResult; 
 
-		while(($sUpdate = readdir($rHandleUpdate)) !== false) {
-			$sPathUpdate = $sPathUpdates . $sUpdate . '/';
-			if(substr($sUpdate, 0, 1) == '.' || !is_dir($sPathUpdate))
-            	continue;
+        while(($sUpdate = readdir($rHandleUpdate)) !== false) {
+            $sPathUpdate = $sPathUpdates . $sUpdate . '/';
+            if(substr($sUpdate, 0, 1) == '.' || !is_dir($sPathUpdate))
+                continue;
 
-			$aUpdate = $this->getConfigUpdate($sPathModule . 'install/config.php', $sPathUpdate . 'install/config.php', $mixedModule);
-			if(empty($aUpdate) || !is_array($aUpdate) || version_compare($aUpdate['module_version'], $aUpdate['version_from']) != 0)
-            	continue;
+            $aUpdate = $this->getConfigUpdate($sPathModule . 'install/config.php', $sPathUpdate . 'install/config.php', $mixedModule);
+            if(empty($aUpdate) || !is_array($aUpdate) || version_compare($aUpdate['module_version'], $aUpdate['version_from']) != 0)
+                continue;
 
-			$aResult = $aUpdate;
-			break;
-		}
+            $aResult = $aUpdate;
+            break;
+        }
 
-		closedir($rHandleUpdate);
+        closedir($rHandleUpdate);
 
         return $aResult;
     }
 
     public function perform($sDirectory, $sOperation, $aParams = array())
     {
-	    $bTransient = false;
-    	if(isset($aParams['transient']) && $aParams['transient'] === true) {
-    		$bTransient = true;
-    		unset($aParams['transient']);
-    	}
+        $bTransient = false;
+        if(isset($aParams['transient'])) {
+            $bTransient = (bool)$aParams['transient'];
+            unset($aParams['transient']);
+        }
 
-    	if(!defined('BX_DOL_CRON_EXECUTE') && !self::isRealOwner() && !in_array($sOperation, array('install', 'uninstall', 'enable', 'disable'))) {
-    		if($this->addTransientJob(self::getNamePerformAction($sDirectory), 'perform_action', array($sDirectory, $sOperation, $aParams)))
-    			return array('code' => BX_DOL_STUDIO_IU_RC_SCHEDULED, 'message' => _t('_adm_mod_msg_process_operation_scheduled'));
-    		else 
-    			return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_mod_err_process_operation_failed', $sOperation, $sDirectory));
-    	}
+        if(!defined('BX_DOL_CRON_EXECUTE') && !self::isRealOwner() && !in_array($sOperation, array('install', 'uninstall', 'enable', 'disable'))) {
+            if($this->addTransientJob(self::getNamePerformAction($sDirectory), 'perform_action', array($sDirectory, $sOperation, $aParams)))
+                return array('code' => BX_DOL_STUDIO_IU_RC_SCHEDULED, 'message' => _t('_adm_mod_msg_process_operation_scheduled'));
+            else 
+                return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_mod_err_process_operation_failed', $sOperation, $sDirectory));
+        }
 
-    	$sConfigFile = 'install/config.php';
+        $sConfigFile = 'install/config.php';
         $sInstallerFile = 'install/installer.php';
         $sInstallerClass = $sOperation == 'update' ? 'Updater' : 'Installer';
 
@@ -238,37 +261,59 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
         $sPathInstaller = BX_DIRECTORY_PATH_MODULES . $sDirectory . $sInstallerFile;
         if(empty($aConfig) || !file_exists($sPathInstaller)) {
-        	$sMessage = _t('_adm_mod_err_process_operation_failed', $sOperation, $sDirectory);
-        	if($bTransient)
-        		$this->emailNotify($sMessage);
+            $sMessage = _t('_adm_mod_err_process_operation_failed', $sOperation, $sDirectory);
 
-        	return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $sMessage);
+            $this->_oLog->write('Operation failed:', $sMessage);
+            if($bTransient)
+                $this->emailNotify($sMessage);
+
+            return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $sMessage);
         } 
 
-		require_once($sPathInstaller);
+        require_once($sPathInstaller);
+
+        $sClassName = $aConfig['class_prefix'] . $sInstallerClass;
+        $oInstaller = new $sClassName($aConfig);
+        $aResult = $oInstaller->$sOperation($aParams);
 
-		$sClassName = $aConfig['class_prefix'] . $sInstallerClass;
-		$oInstaller = new $sClassName($aConfig);
-		$aResult = $oInstaller->$sOperation($aParams);
+        if(!$aResult['result']) {
+            $this->_oLog->write('Operation failed:', $aResult['message']);
 
-		if(!$aResult['result'] && $bTransient)
-			$this->emailNotify($aResult['message']);
+            if($bTransient)
+                $this->emailNotify($aResult['message']);
+        }
 
-        return array('code' => $aResult['result'] ? BX_DOL_STUDIO_IU_RC_SUCCESS : BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $aResult['message']);
+        return array(
+            'code' => isset($aResult['code']) ? $aResult['code'] : ($aResult['result'] ? BX_DOL_STUDIO_IU_RC_SUCCESS : BX_DOL_STUDIO_IU_RC_FAILED), 
+            'message' => $aResult['message']
+        );
     }
 
-    public function performModulesUpgrade($bDirectly = true, $bEmailNotify = true)
+    /**
+     * Update modules using cron based auto updates.
+     * @see BxDolCronUpgradeModulesCheck
+     */
+    public function performModulesUpgrade($aParams = array())
     {
-        if(!defined('BX_DOL_CRON_EXECUTE') && !$bDirectly)
-            return $this->addTransientJob(self::getNamePerformModulesUpgrade(), 'perform_modules_upgrade', array($bEmailNotify));   	
+        $bDirectly = true;
+        if(isset($aParams['directly'])) {
+            $bDirectly = (bool)$aParams['directly'];
+            unset($aParams['directly']);
+        }
+
+        $bTransient = true;
+        if(isset($aParams['transient'])) {
+            $bTransient = (bool)$aParams['transient'];
+            unset($aParams['transient']);
+        }
 
-        $oLog = BxDolLog::getInstance();
-        $oLog->setName('upgrade_modules');
+        if(!defined('BX_DOL_CRON_EXECUTE') && !$bDirectly)
+            return $this->addTransientJob(self::getNamePerformModulesUpgrade(), 'perform_modules_upgrade', array($aParams));
 
         $aFailed = array();
         $aUpdates = $this->checkUpdates();
         if(empty($aUpdates) || !is_array($aUpdates)) {
-            $oLog->write('Cannot get a list of modules which require to be updated.');
+            $this->_oLog->write('Cannot get a list of modules which require to be updated.');
             return true;
         }
 
@@ -283,31 +328,37 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
         $aSuccess = array();
         $aUpdates = $this->getUpdates();
         if(empty($aUpdates) || !is_array($aUpdates)) {
-            $oLog->write('Cannot find update scripts for modules. They are damaged or were not downloaded.');
+            $this->_oLog->write('Cannot find update scripts for modules. They are damaged or were not downloaded.');
             return true;
         }
 
         foreach($aUpdates as $aUpdate) {
-            $aResult = $this->perform($aUpdate['dir'], 'update');
-            if((int)$aResult['code'] != 0) {
-                $aFailed[$aUpdate['module_name']] = $aResult['message'];
-                continue;
+            $aResult = $this->perform($aUpdate['dir'], 'update', $aParams);
+            switch((int)$aResult['code']) {
+                case BX_DOL_STUDIO_IU_RC_SUCCESS:
+                    $aSuccess[$aUpdate['module_name']] = $aUpdate['version_to'];
+                    break;
+
+                case BX_DOL_STUDIO_IU_RCE_WSV_MU:
+                    if(isset($aParams['autoupdate']) && (bool)$aParams['autoupdate'] === true)
+                        break;
+
+                default:
+                    $aFailed[$aUpdate['module_name']] = $aResult['message'];
             }
-
-            $aSuccess[$aUpdate['module_name']] = $aUpdate['version_to'];
         }
 
         if(!empty($aFailed)) {
-            $oLog->write('Failed to update modules:', $aFailed);
+            $this->_oLog->write('Failed to update modules:', $aFailed);
 
-            if($bEmailNotify)
+            if($bTransient)
                 $this->emailNotifyModulesUpgrade('failed', $aFailed);
         }
 
         if(!empty($aSuccess)) {
-            $oLog->write('Successfully updated modules:', $aSuccess);
+            $this->_oLog->write('Successfully updated modules:', $aSuccess);
 
-            if($bEmailNotify)
+            if($bTransient)
                 $this->emailNotifyModulesUpgrade('success', $aSuccess);
         }
 
@@ -318,28 +369,28 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
     {
         $iPerPage = 9999; //--- Note. It's essential to load all purchased products at the same time.
 
-    	if($bAuthorizedAccess)
-        	$aProducts = $this->getAccessObject(true)->loadItems(array(
-        		'method' => 'browse_purchased', 
-        		'domain' => BX_DOL_URL_ROOT, 
-        		'products' => $this->getInstalledInfoShort(),
-        	    'per_page' => $iPerPage
-        	));
-    	else
-			$aProducts = $this->getAccessObject(false)->load($this->sStoreDataUrlPublic . 'json_browse_purchased', array('key' => getParam('sys_oauth_key'), 'per_page' => $iPerPage));
+        if($bAuthorizedAccess)
+            $aProducts = $this->getAccessObject(true)->loadItems(array(
+                'method' => 'browse_purchased', 
+                'domain' => BX_DOL_URL_ROOT, 
+                'products' => $this->getInstalledInfoShort(),
+                'per_page' => $iPerPage
+            ));
+        else
+            $aProducts = $this->getAccessObject(false)->load($this->sStoreDataUrlPublic . 'json_browse_purchased', array('key' => getParam('sys_oauth_key'), 'per_page' => $iPerPage));
 
-		if(empty($aProducts) || !is_array($aProducts))
-			return $aProducts;
+        if(empty($aProducts) || !is_array($aProducts))
+            return $aProducts;
 
-    	$oModuleDb = BxDolModuleQuery::getInstance();
+        $oModuleDb = BxDolModuleQuery::getInstance();
 
-    	$oModuleDb->updateModule(array('hash' => ''));
+        $oModuleDb->updateModule(array('hash' => ''));
         if(!empty($aProducts) && is_array($aProducts))
-	        foreach ($aProducts as $aProduct)
-	        	if(!empty($aProduct['hash']))
-	        		$oModuleDb->updateModule(array('hash' => $aProduct['hash']), array('name' => $aProduct['name']));
+            foreach ($aProducts as $aProduct)
+                if(!empty($aProduct['hash']))
+                    $oModuleDb->updateModule(array('hash' => $aProduct['hash']), array('name' => $aProduct['name']));
 
-		return $aProducts;
+        return $aProducts;
     }
 
     public function checkUpdates($bAuthorizedAccess = false)
@@ -347,77 +398,82 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
         $sProducts = $this->getInstalledInfoShort();
 
         if($bAuthorizedAccess)
-	        return $this->getAccessObject(true)->loadItems(array(
-	        	'method' => 'browse_updates', 
-	        	'products' => $sProducts
-	        ));
+            return $this->getAccessObject(true)->loadItems(array(
+                'method' => 'browse_updates', 
+                'products' => $sProducts
+            ));
 
-		return $this->getAccessObject(false)->load($this->sStoreDataUrlPublic . 'json_browse_updates', array(
-			'key' => getParam('sys_oauth_key'),
-			'products' => $sProducts
-		));
+        return $this->getAccessObject(false)->load($this->sStoreDataUrlPublic . 'json_browse_updates', array(
+            'key' => getParam('sys_oauth_key'),
+            'products' => $sProducts
+        ));
     }
 
     public function downloadFileAuthorized($iFileId)
     {
-		$aItem = $this->getAccessObject(true)->loadItems(array(
-			'method' => 'download_file', 
-			'file_id' => $iFileId
-		));
+        $aItem = $this->getAccessObject(true)->loadItems(array(
+            'method' => 'download_file', 
+            'file_id' => $iFileId
+        ));
 
-		if(empty($aItem) || !is_array($aItem))
-			return $aItem;
+        if(empty($aItem) || !is_array($aItem))
+            return $aItem;
 
-		return $this->downloadFileInit($aItem, array('module_name' => $aItem['module_name']));
+        return $this->downloadFileInit($aItem, array('module_name' => $aItem['module_name']));
     }
 
-    public function downloadUpdatePublic($sModuleName, $bAutoUpdate = false)
+    public function downloadUpdatePublic($sModuleName, $bApplyUpdate = false)
     {
-		$aModule = BxDolModuleQuery::getInstance()->getModuleByName($sModuleName);
+        $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sModuleName);
 
-		$aItem = $this->getAccessObject(false)->load($this->sStoreDataUrlPublic . 'json_download_update', array(
-			'key' => getParam('sys_oauth_key'),
-			'product' => base64_encode(serialize(array(
-				'name' => $aModule['name'],
-	            'version' => $aModule['version'],
-	            'hash' => $aModule['hash'],
-			))),
-		));
+        $aItem = $this->getAccessObject(false)->load($this->sStoreDataUrlPublic . 'json_download_update', array(
+            'key' => getParam('sys_oauth_key'),
+            'product' => base64_encode(serialize(array(
+                'name' => $aModule['name'],
+                'version' => $aModule['version'],
+                'hash' => $aModule['hash'],
+            ))),
+        ));
 
-		return $this->downloadFileInit($aItem, array('module_name' => $sModuleName, 'auto_action' => $bAutoUpdate ? 'update' : ''));
+        return $this->downloadFileInit($aItem, array('module_name' => $sModuleName, 'auto_action' => $bApplyUpdate ? 'update' : ''));
     }
 
     protected function downloadFileInit($aItem, $aParams = array())
     {
-    	if(empty($aItem) || !is_array($aItem))
-			return $aItem;
+        if(empty($aItem) || !is_array($aItem))
+            return $aItem;
 
-    	//--- write ZIP archive.
+        //--- write ZIP archive.
         $sFilePath = '';
         $mixedResult = $this->performWrite($aItem, $sFilePath);
         if($mixedResult !== true)
-        	return $mixedResult;
+            return $mixedResult;
 
-		return $this->downloadFileComplete($sFilePath, $aParams);
+        return $this->downloadFileComplete($sFilePath, $aParams);
     }
 
     protected function downloadFileComplete($sFilePath, $aParams = array())
     {
-		$bTransient = false;
-    	if(isset($aParams['transient']) && $aParams['transient'] === true) {
-    		$bTransient = true;
-    		unset($aParams['transient']);
+        $bTransient = false;
+    	if(isset($aParams['transient'])) {
+            $bTransient = (bool)$aParams['transient'];
+            unset($aParams['transient']);
     	}
 
-    	$sAutoAction = isset($aParams['auto_action']) ? $aParams['auto_action'] : '';
-    	$bAutoAction = !empty($sAutoAction);
+        $sAutoAction = '';
+        $bAutoAction = false;
+        if(isset($aParams['auto_action'])) {
+            $sAutoAction = $aParams['auto_action'];
+            $bAutoAction = !empty($sAutoAction);
+            unset($aParams['auto_action']);
+        }
 
-		if(!defined('BX_DOL_CRON_EXECUTE') && !self::isRealOwner()) {
-			if(!$this->addTransientJob(self::getNameDownloadFile($aParams['module_name']), 'download_file_complete', array($sFilePath, $aParams)))
-				return _t('_adm_str_err_download_failed');
+        if(!defined('BX_DOL_CRON_EXECUTE') && !self::isRealOwner()) {
+            if(!$this->addTransientJob(self::getNameDownloadFile($aParams['module_name']), 'download_file_complete', array($sFilePath, array_merge($aParams, array('auto_action' => $sAutoAction)))))
+                return _t('_adm_str_err_download_failed');
 
-			return array('code' => BX_DOL_STUDIO_IU_RC_SCHEDULED, 'message' => _t('_adm_str_msg_download' . ($bAutoAction ? '_and_install' : '') . '_scheduled'));
-		}
+            return array('code' => BX_DOL_STUDIO_IU_RC_SCHEDULED, 'message' => _t('_adm_str_msg_download' . ($bAutoAction ? '_and_install' : '') . '_scheduled'));
+        }
 
         //--- Unarchive package.
         $sPackagePath = '';
@@ -425,10 +481,11 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
         @unlink($sFilePath);
         if($mixedResult !== true) {
-        	if($bTransient)
-        		$this->emailNotify($mixedResult);
+            $this->_oLog->write('Operation failed:', $mixedResult);
+            if($bTransient)
+                $this->emailNotify($mixedResult);
 
-        	return $mixedResult;
+            return $mixedResult;
         }
 
         //--- Copy unarchived package.
@@ -437,80 +494,81 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
         @bx_rrmdir($sPackagePath);
         if($mixedResult !== true) {
-        	if($bTransient)
-        		$this->emailNotify($mixedResult);
+            $this->_oLog->write('Operation failed:', $mixedResult);
+            if($bTransient)
+                $this->emailNotify($mixedResult);
 
-        	return $mixedResult;
+            return $mixedResult;
         }
 
-		if(!$bAutoAction)
-			 return true;
+        if(!$bAutoAction)
+            return true;
 
-		//--- Autoinstall the downloaded package if it's needed.
-		$aResult = $this->perform($sHomePath, $sAutoAction, $aParams);
-		if((int)$aResult['code'] != 0) {
-			if($bTransient)
-        		$this->emailNotify($aResult['message']);
+        //--- Autoinstall the downloaded package if it's needed.
+        $aResult = $this->perform($sHomePath, $sAutoAction, $aParams);
+        if((int)$aResult['code'] != 0) {
+            if($bTransient)
+                $this->emailNotify($aResult['message']);
 
-			return $aResult['message'];
-		}
+            return $aResult['message'];
+        }
 
         return true;
     }
 
     protected function performWrite($aItem, &$sFilePath)
     {
-    	$sFilePath = BX_DIRECTORY_PATH_TMP . $aItem['name'];
-    	if(file_exists($sFilePath))
-        	@unlink($sFilePath);
+        $sFilePath = BX_DIRECTORY_PATH_TMP . $aItem['name'];
+        if(file_exists($sFilePath))
+            @unlink($sFilePath);
 
-		$iUmaskSave = umask(0);
+        $iUmaskSave = umask(0);
 
         if(!$rHandler = fopen($sFilePath, 'w')) {
-        	umask($iUmaskSave);
+            umask($iUmaskSave);
             return _t('_adm_str_err_cannot_write');
         }
 
         $sContent = urldecode($aItem['content']);
         if(!fwrite($rHandler, $sContent, strlen($sContent))) {
-        	umask($iUmaskSave);
+            umask($iUmaskSave);
             return _t('_adm_str_err_cannot_write');
         }
 
         fclose($rHandler);
-        
+
         umask($iUmaskSave);
         return true;
     }
 
     protected function performUnarchive($sFilePath, &$sPackagePath)
     {
-    	if(!class_exists('ZipArchive'))
+        if(!class_exists('ZipArchive'))
             return _t('_adm_str_err_zip_not_available');
 
-		$iUmaskSave = umask(0);
+        $iUmaskSave = umask(0);
 
         $oZip = new ZipArchive();
         if($oZip->open($sFilePath) !== true) {
-        	umask($iUmaskSave);
+            umask($iUmaskSave);
             return _t('_adm_str_err_cannot_unzip_package');
         }
 
         $sPackageFolder = '';
         if($oZip->numFiles > 0)
-        	$sPackageFolder = $oZip->getNameIndex(0);
+            $sPackageFolder = $oZip->getNameIndex(0);
 
         if(empty($sPackageFolder)) {
-        	umask($iUmaskSave);
-        	return _t('_adm_str_err_cannot_unzip_package');
+            umask($iUmaskSave);
+            return _t('_adm_str_err_cannot_unzip_package');
         }
-        
-		$sPackagePath = BX_DIRECTORY_PATH_TMP . $sPackageFolder;
+
+        $sPackagePath = BX_DIRECTORY_PATH_TMP . $sPackageFolder;
         if(file_exists($sPackagePath)) // remove existing tmp folder with the same name
             @bx_rrmdir($sPackagePath);
 
         if(!$oZip->extractTo(BX_DIRECTORY_PATH_TMP)) {
-        	umask($iUmaskSave);
+            umask($iUmaskSave);
             return _t('_adm_str_err_cannot_unzip_package');
         }
 
@@ -522,33 +580,33 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
     protected function performCopy($sPackagePath, &$sHomePath)
     {
-    	if($this->bUseFtp) {
-	        $sLogin = getParam('sys_ftp_login');
-	        $sPassword = getParam('sys_ftp_password');
-	        $sPath = getParam('sys_ftp_dir');
-	        if(empty($sLogin) || empty($sPassword) || empty($sPath))
-	            return _t('_adm_str_err_no_ftp_info');
-	
-	        $oFile = new BxDolFtp($_SERVER['HTTP_HOST'], $sLogin, $sPassword, $sPath);
-	
-	        if(!$oFile->connect())
-	            return _t('_adm_str_err_cannot_connect_to_ftp');
-	
-	        if(!$oFile->isUna())
-	            return _t('_adm_str_err_destination_not_valid');
+        if($this->bUseFtp) {
+            $sLogin = getParam('sys_ftp_login');
+            $sPassword = getParam('sys_ftp_password');
+            $sPath = getParam('sys_ftp_dir');
+            if(empty($sLogin) || empty($sPassword) || empty($sPath))
+                return _t('_adm_str_err_no_ftp_info');
+
+            $oFile = new BxDolFtp($_SERVER['HTTP_HOST'], $sLogin, $sPassword, $sPath);
+
+            if(!$oFile->connect())
+                return _t('_adm_str_err_cannot_connect_to_ftp');
+
+            if(!$oFile->isUna())
+                return _t('_adm_str_err_destination_not_valid');
         }
         else
-        	$oFile = BxDolFile::getInstance();
+            $oFile = BxDolFile::getInstance();
 
         $aConfig = self::getModuleConfig($sPackagePath . 'install/config.php');
         if(empty($aConfig) || !is_array($aConfig) || empty($aConfig['home_dir']))
             return _t('_adm_str_err_wrong_package_format');
 
-		$sHomePath = $aConfig['home_dir'];
+        $sHomePath = $aConfig['home_dir'];
         if(!$oFile->copy($sPackagePath, 'modules/' . $sHomePath))
             return _t('_adm_str_err_files_copy_failed');
 
-		return true;
+        return true;
     }
 
     protected function getConfigModule($sConfigPath, $aInstalled = array())
@@ -562,7 +620,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
         $sVersion = $bInstalled ? $aInstalled['version'] : $aConfig['version'];
 
         return array(
-        	'type' => $aConfig['type'],
+            'type' => $aConfig['type'],
             'name' => isset($aConfig['name']) ? $aConfig['name'] : $aConfig['home_uri'],
             'title' => bx_process_output($aConfig['title']),
             'vendor' => $aConfig['vendor'],
@@ -609,7 +667,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
         return $aInstalledInfo;
     }
 
-	private function getInstalledInfoShort()
+    private function getInstalledInfoShort()
     {
     	$aModules = BxDolModuleQuery::getInstance()->getModules();
 
@@ -630,34 +688,34 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
     private function addTransientJob($sName, $sAction, $aParams)
     {
-		if(BxDolCronQuery::getInstance()->addTransientJobService($sName, array('system', $sAction, $aParams, 'DolStudioInstallerUtils')))
-			return true;
+        if(BxDolCronQuery::getInstance()->addTransientJobService($sName, array('system', $sAction, $aParams, 'DolStudioInstallerUtils')))
+            return true;
 
-		return false;
+        return false;
     }
 
     private function emailNotify($sMessage)
     {
     	sendMailTemplateSystem('t_BgOperationFailed', array (
-			'conclusion' => strip_tags($sMessage),
-		));
+            'conclusion' => strip_tags($sMessage),
+        ));
     }
 
     private function emailNotifyModulesUpgrade($sResult, $aData)
     {
-		$oModuleQuery = BxDolModuleQuery::getInstance();
+        $oModuleQuery = BxDolModuleQuery::getInstance();
 
     	$sConclusion = '';
     	if(!empty($aData))
-			foreach($aData as $sModule => $sMessage) {
-				$aModule = $oModuleQuery->getModuleByName($sModule);
+            foreach($aData as $sModule => $sMessage) {
+                $aModule = $oModuleQuery->getModuleByName($sModule);
 
-				$sConclusion .= _t('_sys_et_txt_body_modules_upgrade_' . $sResult, $aModule['title'], $sMessage);
-			}
+                $sConclusion .= _t('_sys_et_txt_body_modules_upgrade_' . $sResult, $aModule['title'], $sMessage);
+            }
 
-		sendMailTemplateSystem('t_UpgradeModules' . ucfirst($sResult), array (
-			'conclusion' => $sConclusion,
-		));
+        sendMailTemplateSystem('t_UpgradeModules' . ucfirst($sResult), array (
+            'conclusion' => $sConclusion,
+        ));
     }
 }
 

+ 3 - 3
studio/classes/BxDolStudioStore.php

@@ -65,7 +65,7 @@ class BxDolStudioStore extends BxTemplStudioPage
                     $aResult = $this->getUpdate($sModuleName);
                     break;
 
-				case 'get-update-and-install':
+                case 'get-update-and-install':
                     $sModuleName = bx_process_input(bx_get('str_id'));
                     $aResult = $this->getUpdate($sModuleName, true);
                     break;
@@ -356,9 +356,9 @@ class BxDolStudioStore extends BxTemplStudioPage
     /*
      * Load update's package publicly.
      */
-	protected function loadUpdate($sModuleName, $bAutoUpdate = false)
+    protected function loadUpdate($sModuleName, $bApplyUpdate = false)
     {
-        return BxDolStudioInstallerUtils::getInstance()->downloadUpdatePublic($sModuleName, $bAutoUpdate);
+        return BxDolStudioInstallerUtils::getInstance()->downloadUpdatePublic($sModuleName, $bApplyUpdate);
     }
 
     protected function getBaseUrl($mixedParams = array())

+ 13 - 6
studio/classes/BxDolStudioUpdater.php

@@ -42,6 +42,7 @@ class BxDolStudioUpdater extends BxDolStudioInstaller
 
     public function update($aParams)
     {
+        $bAutoUpdate = isset($aParams['autoupdate']) && (bool)$aParams['autoupdate'];
     	$bHtmlResponce = isset($aParams['html_response']) && (bool)$aParams['html_response'];
 
         $aResult = array(
@@ -52,19 +53,22 @@ class BxDolStudioUpdater extends BxDolStudioInstaller
         $aModuleInfo = $this->oDb->getModulesBy(array('type' => 'path_and_uri', 'path' => $this->_aConfig['module_dir'], 'uri' => $this->_aConfig['module_uri']));
         if(!$aModuleInfo)
             return array_merge($aResult, array(
+                'code' => BX_DOL_STUDIO_IU_RCE_NOT_FOUND,
                 'message' => $this->_displayResult('check_module_exists', false, '_adm_err_modules_module_not_found', $bHtmlResponce),
                 'result' => false
             ));
 
-		if(isset($aParams['module_name']) && strcmp($aParams['module_name'], $aModuleInfo['name']) !== 0)
-			return array_merge($aResult, array(
+        if(isset($aParams['module_name']) && strcmp($aParams['module_name'], $aModuleInfo['name']) !== 0)
+            return array_merge($aResult, array(
+                'code' => BX_DOL_STUDIO_IU_RCE_NOT_AVAILABLE,
                 'message' => $this->_displayResult('check_module_matches', false, '_adm_err_modules_module_not_match', $bHtmlResponce),
                 'result' => false
             ));
 
-		//--- Check version compatibility ---//
+        //--- Check version compatibility ---//
         if(!$this->_isCompatibleWith())
             return array(
+                'code' => BX_DOL_STUDIO_IU_RCE_WSV_MU,
                 'message' => $this->_displayResult('check_script_version', false, _t('_adm_err_modules_wrong_version_script_update', $aModuleInfo['title']), $bHtmlResponce),
                 'result' => false
             );
@@ -72,6 +76,7 @@ class BxDolStudioUpdater extends BxDolStudioInstaller
         //--- Check version ---//
         if(version_compare($aModuleInfo['version'], $this->_aConfig['version_from']) != 0)
             return array_merge($aResult, array(
+                'code' => BX_DOL_STUDIO_IU_RCE_WMV,
                 'message' => $this->_displayResult('check_module_version', false, '_adm_err_modules_wrong_version', $bHtmlResponce),
                 'result' => false
             ));
@@ -84,12 +89,14 @@ class BxDolStudioUpdater extends BxDolStudioInstaller
         $bAutoupdateForceModifiedFiles = getParam('sys_autoupdate_force_modified_files') == 'on';
 
     	if(!empty($aFilesChanged) && !$bAutoupdateForceModifiedFiles) 
-    		return array_merge($aResult, array(
+            return array_merge($aResult, array(
+                'code' => BX_DOL_STUDIO_IU_RCE_MODIFIED,
                 'message' => $this->_displayResult('check_module_hash', false, '_adm_err_modules_module_was_modified', $bHtmlResponce),
                 'result' => false
             ));
-		else if($fChangedPercent > BX_FORCE_AUTOUPDATE_MAX_CHANGED_FILES_PERCENT && $bAutoupdateForceModifiedFiles) 
-			return array_merge($aResult, array(
+        else if($fChangedPercent > BX_FORCE_AUTOUPDATE_MAX_CHANGED_FILES_PERCENT && $bAutoupdateForceModifiedFiles) 
+            return array_merge($aResult, array(
+                'code' => BX_DOL_STUDIO_IU_RCE_CHECKSUM_FAILED,
                 'message' => $this->_displayResult('check_module_hash', false, _t('_sys_upgrade_files_checksum_failed_too_many_module', round($fChangedPercent * 100), $aModuleInfo['title']), $bHtmlResponce),
                 'result' => false
             ));

+ 7 - 7
studio/template/scripts/BxBaseStudioStore.php

@@ -758,17 +758,17 @@ class BxBaseStudioStore extends BxDolStudioStore
 			return array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
     }
 
-	protected function getUpdate($sModuleName, $bAutoUpdate = false)
+    protected function getUpdate($sModuleName, $bApplyUpdate = false)
     {
-        $mixedResult = $this->loadUpdate($sModuleName, $bAutoUpdate);
+        $mixedResult = $this->loadUpdate($sModuleName, $bApplyUpdate);
         if($mixedResult === true)
-        	return array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => _t('_adm_str_msg_download' . ($bAutoUpdate ? '_and_install' : '') . '_successfully'));
+            return array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => _t('_adm_str_msg_download' . ($bApplyUpdate ? '_and_install' : '') . '_successfully'));
 
-		if(is_string($mixedResult))
-			return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
+        if(is_string($mixedResult))
+                return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
 
-		if(is_array($mixedResult))
-        	return array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
+        if(is_array($mixedResult))
+            return array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
     }
 
     protected function displayProducts($mixedItems, $aParams = array())