AntonLV пре 6 година
родитељ
комит
c0efcece1b

+ 8 - 9
studio/classes/BxDolStudioInstallerUtils.php

@@ -470,7 +470,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
         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_FAILED, 'message' => _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'));
         }
@@ -485,7 +485,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
             if($bTransient)
                 $this->emailNotify($mixedResult);
 
-            return $mixedResult;
+            return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $mixedResult);
         }
 
         //--- Copy unarchived package.
@@ -498,7 +498,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
             if($bTransient)
                 $this->emailNotify($mixedResult);
 
-            return $mixedResult;
+            return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $mixedResult);
         }
 
         if(!$bAutoAction)
@@ -506,14 +506,13 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 
         //--- 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']);
+        if((int)$aResult['code'] == 0) 
+            return true;
 
-            return $aResult['message'];
-        }
+        if($bTransient)
+            $this->emailNotify($aResult['message']);
 
-        return true;
+        return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $aResult['message']);
     }
 
     protected function performWrite($aItem, &$sFilePath)

+ 1 - 1
studio/classes/BxDolStudioStore.php

@@ -194,7 +194,7 @@ class BxDolStudioStore extends BxTemplStudioPage
                 ));
             }
 
-            echo json_encode($aResult);
+            echoJson($aResult);
             exit;
         }
     }

+ 6 - 6
studio/classes/BxDolStudioStoreQuery.php

@@ -18,13 +18,13 @@ class BxDolStudioStoreQuery extends BxDolStudioModulesQuery
     {
     	$sJobName = '';
     	switch($sAction) {
-    		case 'download':
-    			$sJobName = BxDolStudioInstallerUtils::getNameDownloadFile($sName);
-    			break;
+            case 'download':
+                $sJobName = BxDolStudioInstallerUtils::getNameDownloadFile($sName);
+                break;
 
-    		case 'action':
-    			$sJobName = BxDolStudioInstallerUtils::getNamePerformAction($sName);
-    			break;
+            case 'action':
+                $sJobName = BxDolStudioInstallerUtils::getNamePerformAction($sName);
+                break;
     	}
 
     	$sSql = $this->prepare("SELECT `id` FROM `sys_cron_jobs` WHERE `name`=? LIMIT 1", $sJobName);

+ 38 - 24
studio/js/store.js

@@ -161,20 +161,20 @@ BxDolStudioStore.prototype.getUpdate = function(sModuleName, oButton) {
 };
 
 BxDolStudioStore.prototype.getUpdateAndInstall = function(sModuleName, oButton) {
-	var $this = this;
+    var $this = this;
 
-	var onResult = function(oData, oButton) {
-		if(oData.code != 0) {
-			$this._onGetFile(oData, oButton);
-			return;
-		}
+    var onResult = function(oData, oButton) {
+        if(oData.code != 0) {
+            $this._onGetFile(oData, oButton);
+            return;
+        }
 
-		bx_loading($this.sIdPageContent, false);
+        bx_loading($this.sIdPageContent, false);
 
-		$(oButton).parents('.bx-std-product:first').hide();
-	};
+        $(oButton).parents('.bx-std-product:first').hide();
+    };
 
-	this._getFile('get-update-and-install', sModuleName, onResult, oButton);
+    this._getFile('get-update-and-install', sModuleName, onResult, oButton);
 };
 
 BxDolStudioStore.prototype._getFile = function(sAction, mixedId, onResult, oButton) {
@@ -202,19 +202,33 @@ BxDolStudioStore.prototype._getFile = function(sAction, mixedId, onResult, oButt
 };
 
 BxDolStudioStore.prototype._onGetFile = function(oData, oButton) {
-	bx_loading_btn(oButton, false);
-
-	switch(parseInt(oData.code)) {
-		case 1:
-			$(oButton).removeClass('bx-btn-disabled');
-			break;
-		case 2:
-			$(oButton).val(_t('_adm_btn_queued_submit'));
-			break;
-	}
-
-	if(oData.message)
-		this.showNotification(oData.message);
+    bx_loading_btn(oButton, false);
+
+    oButton = $(oButton);
+    switch(parseInt(oData.code)) {
+        case 1:
+            oButton.removeClass('bx-btn-disabled');
+            break;
+        case 2:
+            if(oButton.is("input[type = 'button']"))
+                oButton.val(_t('_adm_btn_queued_submit'));
+            else
+                oButton.html(_t('_adm_btn_queued_submit'));
+            break;
+    }
+
+    if(oData.message)
+        this.showNotification(oData.message);
+
+    if(oData.reload != undefined) {
+        var iReload = parseInt(Number(oData.reload));
+        if(iReload != oData.reload)
+            document.location = document.location;
+        else
+            setTimeout(function() {
+                document.location = document.location;
+            }, iReload);
+    }   
 };
 
 BxDolStudioStore.prototype.info = function(sModuleName, oLink) {
@@ -455,4 +469,4 @@ BxDolStudioStore.prototype.showPopup = function(sId, sContent, mixedPointer) {
 
     $('#' + sId).dolPopup(oParams);
 };
-/** @} */
+/** @} */

+ 20 - 12
studio/template/scripts/BxBaseStudioStore.php

@@ -760,15 +760,18 @@ class BxBaseStudioStore extends BxDolStudioStore
 
     protected function getUpdate($sModuleName, $bApplyUpdate = false)
     {
+        $aResult = array();
+
         $mixedResult = $this->loadUpdate($sModuleName, $bApplyUpdate);
         if($mixedResult === true)
-            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_array($mixedResult))
-            return array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
+            $aResult = array('code' => BX_DOL_STUDIO_IU_RC_SUCCESS, 'message' => _t('_adm_str_msg_download' . ($bApplyUpdate ? '_and_install' : '') . '_successfully'));
+        else if(is_string($mixedResult))
+            $aResult = array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => (!empty($mixedResult) ? $mixedResult : _t('_adm_str_err_download_failed')));
+        else if(is_array($mixedResult))
+            $aResult = array_merge(array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_str_err_download_failed')), $mixedResult);
+
+        $aResult['reload'] = 3000;
+        return $aResult;
     }
 
     protected function displayProducts($mixedItems, $aParams = array())
@@ -963,12 +966,13 @@ class BxBaseStudioStore extends BxDolStudioStore
         $sResult = '';
         foreach($mixedItems as $aItem) {
             $bDownloadable = (int)$aItem['is_file'] == 1;
+            $bQueued = $this->oDb->isQueued('download', $aItem['name']);
 
             $sIcon = !empty($aItem['thumbnail']['big']) ? $aItem['thumbnail']['big'] : BxDolStudioUtils::getIconDefault(BX_DOL_MODULE_TYPE_MODULE);
-			$bIcon = strpos($sIcon, '.') !== false;
+            $bIcon = strpos($sIcon, '.') !== false;
 
             $sImage = !empty($aItem['cover']['big']) ? $aItem['cover']['big'] : '';
-			$bImage = strpos($sImage, '.') !== false;
+            $bImage = strpos($sImage, '.') !== false;
 
             $sResult .= $oTemplate->parseHtmlByName('str_update_v2.html', array(
                 'js_object' => $sJsObject,
@@ -1005,11 +1009,15 @@ class BxBaseStudioStore extends BxDolStudioStore
                 'vendor' => $aItem['author_name'],
                 'versions' => _t('_adm_str_txt_update_from_to', $aItem['file_version'], $aItem['file_version_to']),
                 'bx_if:show_download' => array(
-                    'condition' => $bDownloadable,
+                    'condition' => $bDownloadable && !$bQueued,
                     'content' => array(
-	            		'caption' => _t($this->bAuthAccessUpdates ? '_adm_btn_download_submit' : '_adm_btn_install_submit'),
-	            		'on_click' => $sJsObject . "." . ($this->bAuthAccessUpdates ? "getFile(" . $aItem['file_id'] . ", this)" : "getUpdateAndInstall('" . $aItem['name'] . "', this)")
+                        'caption' => _t($this->bAuthAccessUpdates ? '_adm_btn_download_submit' : '_adm_btn_install_submit'),
+                        'on_click' => $sJsObject . "." . ($this->bAuthAccessUpdates ? "getFile(" . $aItem['file_id'] . ", this)" : "getUpdateAndInstall('" . $aItem['name'] . "', this)")
                     )
+                ),
+                'bx_if:show_queued_disabled' => array(
+                    'condition' => $bDownloadable && $bQueued,
+                    'content' => array()
                 )
             ));
         }

+ 17 - 13
studio/template/str_update_v2.html

@@ -33,23 +33,27 @@
                 </div>
                 <div class="bx-std-pt-content bx-def-thumb-size-min-height">
                     <div class="bx-std-pt-content-cnt">
-	                    <div class="bx-std-pt-title bx-def-font-h3">
-	                        <a class="bx-def-margin-sec-topbottom bx-def-font-color" href="javascript:void(0)" onclick="javascript:__js_object__.info('__name__', this)">__title__</a>
-	                    </div>
-	                    <div class="bx-std-pt-info bx-def-font-small bx-def-font-grayed">
-			                <span class="bx-std-pt-vendor">__vendor__</span> <span class="bx-std-pt-bullet">&bull;</span> <span class="bx-std-pt-versions">__versions__</span>
-			            </div>
+                        <div class="bx-std-pt-title bx-def-font-h3">
+                            <a class="bx-def-margin-sec-topbottom bx-def-font-color" href="javascript:void(0)" onclick="javascript:__js_object__.info('__name__', this)">__title__</a>
+                        </div>
+                        <div class="bx-std-pt-info bx-def-font-small bx-def-font-grayed">
+                            <span class="bx-std-pt-vendor">__vendor__</span> <span class="bx-std-pt-bullet">&bull;</span> <span class="bx-std-pt-versions">__versions__</span>
+                        </div>
                     </div>
                 </div>
             </div>
         </div>
-	    <!-- Actions section -->
+
+        <!-- Actions section -->
         <div class="bx-std-product-actions bx-def-padding-sec-leftright bx-def-padding-sec-bottom">
-	        <div class="bx-std-pa-actions">
-	        	<bx_if:show_download>
-	            	<a class="bx-btn bx-std-pc-download" onclick="javascript:__on_click__">__caption__</a>
-	            </bx_if:show_download>
-			</div>
-	    </div>
+            <div class="bx-std-pa-actions">
+                <bx_if:show_download>
+                    <a class="bx-btn bx-std-pc-download" onclick="javascript:__on_click__">__caption__</a>
+                </bx_if:show_download>
+                <bx_if:show_queued_disabled>
+                    <a class="bx-btn bx-btn-disabled bx-std-pc-queued"><bx_text:_adm_btn_queued_submit /></a>
+                </bx_if:show_queued_disabled>
+            </div>
+        </div>
     </div>
 </div>