AntonLV 8 gadi atpakaļ
vecāks
revīzija
5fde09790b

+ 4 - 4
studio/classes/BxDolStudioOAuth.php

@@ -60,12 +60,12 @@ class BxDolStudioOAuth extends BxDolFactory
 
     public function doAuthorize()
     {
-    	if(empty($this->sKey) || empty($this->sSecret))
+        if(empty($this->sKey) || empty($this->sSecret))
             return _t('_adm_err_oauth_empty_key_secret');
 
-		$mixedResult = $this->authorize();
-		if($mixedResult !== true)
-		    return $this->onAuthorizeFailed($mixedResult);
+        $mixedResult = $this->authorize();
+        if($mixedResult !== true)
+            return $this->onAuthorizeFailed($mixedResult);
 
         BxDolStudioInstallerUtils::getInstance()->checkModules(true);
         return $mixedResult;

+ 17 - 3
studio/classes/BxDolStudioStore.php

@@ -38,9 +38,7 @@ class BxDolStudioStore extends BxTemplStudioPage
         if(is_string($sPage) && !empty($sPage))
             $this->sPage = $sPage;
 
-        $this->iClient = BxDolStudioOAuth::getAuthorizedClient();
-        if(!empty($this->iClient))
-        	$this->sClientKey = $this->oDb->getParam('sys_oauth_key');
+        $this->initClient();
 
         //--- Check actions ---//
         if(($sAction = bx_get('str_action')) !== false) {
@@ -197,6 +195,22 @@ class BxDolStudioStore extends BxTemplStudioPage
         }
     }
 
+    protected function initClient()
+    {
+        $this->iClient = BxDolStudioOAuth::getAuthorizedClient();
+        if(!empty($this->iClient))
+            $this->sClientKey = $this->oDb->getParam('sys_oauth_key');
+    }
+
+    protected function authorizeClient()
+    {
+        $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
+        if($mixedResult === true)
+            $this->initClient();
+
+        return $mixedResult;
+    }
+
     protected function loadGoodies()
     {
         $iPerPage = 3;

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

@@ -98,7 +98,7 @@ class BxBaseStudioStore extends BxDolStudioStore
         $sJsObject = $this->getPageJsObject();
         $oTemplate = BxDolStudioTemplate::getInstance();
 
-        $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
+        $mixedResult = $this->authorizeClient();
         if($mixedResult === true) {
 	        $aProducts = $this->loadGoodies();
 
@@ -157,7 +157,7 @@ class BxBaseStudioStore extends BxDolStudioStore
         $sJsObject = $this->getPageJsObject();
         $oTemplate = BxDolStudioTemplate::getInstance();
 
-        $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
+        $mixedResult = $this->authorizeClient();
         if($mixedResult === true) {
 	        $iStart = (int)bx_get('str_start');
 	        $iPerPage = (int)bx_get('str_per_page');
@@ -228,7 +228,7 @@ class BxBaseStudioStore extends BxDolStudioStore
 
     protected function getLabelsList($sType, $bWrapInBlock = true)
     {
-        $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
+        $mixedResult = $this->authorizeClient();
         if($mixedResult === true) {
             $aLabels = $this->{'load' . bx_gen_method_name($sType)}();
             $sContent = $this->{'display' . bx_gen_method_name($sType)}($aLabels);
@@ -294,7 +294,7 @@ class BxBaseStudioStore extends BxDolStudioStore
         $sJsObject = $this->getPageJsObject();
         $oTemplate = BxDolStudioTemplate::getInstance();
 
-        $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
+        $mixedResult = $this->authorizeClient();
         if($mixedResult === true) {
             //--- Search form
             $aForm = array(