瀏覽代碼

Ticket #4515 - Export/Import tools: Disable before import.

AntonLV 3 年之前
父節點
當前提交
28aa37c4ca

+ 5 - 0
modules/boonex/developer/classes/BxDevFormsForms.php

@@ -221,6 +221,11 @@ class BxDevFormsForms extends BxTemplStudioFormsForms
         foreach($aContent['meta']['masks'] as $sMask => $aMask)
             ${'aMf' . bx_gen_method_name($sMask)} = array_flip($aMask);
 
+        if($aResult['disable'] != 0) {
+            $this->oDb->updateForms(['active' => 0]);
+            $this->oDb->updateDisplayInputs(['active' => 0]);
+        }
+
         $iData = 0;
         foreach($aContent['data'] as $aData) {
             $iData += 1;

+ 17 - 3
modules/boonex/developer/classes/BxDevModule.php

@@ -171,7 +171,7 @@ class BxDevModule extends BxDolModule
         if(!method_exists($this, $sMethod))
             return echoJson([]);
 
-        echoJson($this->$sMethod($aResult['content']));
+        echoJson($this->$sMethod($aResult['content'], $aResult['disable'] != 0));
     }
 
     public function getPopupCodeImport($aParams)
@@ -199,6 +199,17 @@ class BxDevModule extends BxDolModule
                     'caption' => '',
                     'value' => '',
                 ],
+                'disable' => [
+                    'type' => 'switcher',
+                    'name' => 'disable',
+                    'caption' => _t('_bx_dev_txt_disable_before_import'),
+                    'info' => '',
+                    'value' => '1',
+                    'checked' => 0,
+                    'db' => [
+                        'pass' => 'Int',
+                    ],
+                ],
                 'controls' => [
                     'type' => 'input_set', [
                         'type' => 'submit',
@@ -239,7 +250,7 @@ class BxDevModule extends BxDolModule
             if(!is_array($aContent) || empty($aContent['meta']) || empty($aContent['data']))
                 return ['code' => 3, 'message' => $sError];
 
-            return ['code' => 0, 'content' => $aContent];
+            return ['code' => 0, 'content' => $aContent, 'disable' => $oForm->getCleanValue('disable')];
         }
 
         return [
@@ -437,7 +448,7 @@ class BxDevModule extends BxDolModule
         return [$aMeta, $aData];
     }
 
-    protected function _eiImportPages($aContent)
+    protected function _eiImportPages($aContent, $bDisable = false)
     {
         bx_import('BuilderPage', $this->_aModule);
         $oBuilderPage = new BxDevBuilderPage(['type' => '', 'page' => '', 'url' => '']);
@@ -452,6 +463,9 @@ class BxDevModule extends BxDolModule
         foreach($aContent['meta']['masks'] as $sMask => $aMask)
             ${'aMf' . bx_gen_method_name($sMask)} = array_flip($aMask);
 
+        if($bDisable)
+            $oBpDb->updateBlocks(['active' => 0, 'active_api' => 0]);
+
         $iData = 0;
         foreach($aContent['data'] as $aData) {
             $iData += 1;

+ 5 - 0
modules/boonex/developer/classes/BxDevNavigationMenus.php

@@ -184,6 +184,11 @@ class BxDevNavigationMenus extends BxTemplStudioNavigationMenus
         foreach($aContent['meta']['masks'] as $sMask => $aMask)
             ${'aMf' . bx_gen_method_name($sMask)} = array_flip($aMask);
 
+        if($aResult['disable'] != 0) {
+            $this->oDb->updateMenus(['active' => 0]);
+            $this->oDb->updateItems(['active' => 0, 'active_api' => 0]);
+        }
+            
         $iData = 0;
         foreach($aContent['data'] as $aData) {
             $iData += 1;

+ 1 - 0
modules/boonex/developer/install/langs/en.xml

@@ -533,6 +533,7 @@
     <string name="_bx_dev_btn_import_full"><![CDATA[Import]]></string>
     <string name="_bx_dev_btn_export_full"><![CDATA[Export]]></string>
     <string name="_bx_dev_btn_cancel"><![CDATA[Cancel]]></string>
+    <string name="_bx_dev_txt_disable_before_import"><![CDATA[Deactivate before import]]></string>
     <string name="_bx_dev_txt_import_full_popup"><![CDATA[Import]]></string>
     <string name="_bx_dev_txt_export_type"><![CDATA[What type of export do you need?]]></string>
     <string name="_bx_dev_err_cannot_perform"><![CDATA[Cannot perform the action.]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/bx_developer/ru.xml

@@ -534,6 +534,7 @@
     <string name="_bx_dev_btn_export"><![CDATA[Экспортировать]]></string>
     <string name="_bx_dev_btn_cancel"><![CDATA[Отмена]]></string>
     <string name="_bx_dev_txt_import_popup"><![CDATA[Импортировать]]></string>
+    <string name="_bx_dev_txt_disable_before_import"><![CDATA[Деактивировать перед импортом]]></string>
     <string name="_bx_dev_txt_export_type"><![CDATA[Какой вид экспорта вам нужен?]]></string>
     <string name="_bx_dev_err_cannot_perform"><![CDATA[Не могу выполнить действие.]]></string>
     <string name="_bx_dev_msg_imported"><![CDATA[Импорт завершен. Обработано {0} элементов.]]></string>

+ 12 - 0
studio/classes/BxDolStudioBuilderPageQuery.php

@@ -514,6 +514,18 @@ class BxDolStudioBuilderPageQuery extends BxDolStudioPageQuery
     {
         return $this->query("UPDATE `sys_pages_blocks` SET " . $this->arrayToSQL($aData) . " WHERE " . $this->arrayToSQL($aFields, ' AND ')) ? true : false;
     }
+    
+    function updateBlocks($aParamsSet, $aParamsWhere = [])
+    {
+        if(empty($aParamsSet))
+            return false;
+
+        $sWhereClause = "1";
+        if(!empty($aParamsWhere))
+            $sWhereClause = $this->arrayToSQL($aParamsWhere, " AND ");
+
+        return $this->query("UPDATE `sys_pages_blocks` SET " . $this->arrayToSQL($aParamsSet) . " WHERE " . $sWhereClause);
+    }
 
     function deleteBlocks($aParams)
     {

+ 24 - 0
studio/classes/BxDolStudioFormsQuery.php

@@ -131,6 +131,18 @@ class BxDolStudioFormsQuery extends BxDolDb
         return $this->query("INSERT INTO `sys_objects_form` SET " . $this->arrayToSQL($aFields));
     }
 
+    function updateForms($aParamsSet, $aParamsWhere = [])
+    {
+        if(empty($aParamsSet))
+            return false;
+
+        $sWhereClause = "1";
+        if(!empty($aParamsWhere))
+            $sWhereClause = $this->arrayToSQL($aParamsWhere, " AND ");
+
+        return $this->query("UPDATE `sys_objects_form` SET " . $this->arrayToSQL($aParamsSet) . " WHERE " . $sWhereClause);
+    }
+
     function updateFormByObject($sObject, $aFields)
     {
         return $this->query("UPDATE `sys_objects_form` SET " . $this->arrayToSQL($aFields) . " WHERE `object`=:object", [
@@ -446,6 +458,18 @@ class BxDolStudioFormsQuery extends BxDolDb
         ]);
     }
 
+    public function updateDisplayInputs($aParamsSet, $aParamsWhere = [])
+    {
+        if(empty($aParamsSet))
+            return false;
+
+        $sWhereClause = "1";
+        if(!empty($aParamsWhere))
+            $sWhereClause = $this->arrayToSQL($aParamsWhere, " AND ");
+
+        return $this->query("UPDATE `sys_form_display_inputs` SET " . $this->arrayToSQL($aParamsSet) . " WHERE " . $sWhereClause);
+    }
+
     function updateDisplayInputByDisplayAndInput($sDisplay, $sInput, $aFields)
     {
         return $this->query("UPDATE `sys_form_display_inputs` SET " . $this->arrayToSQL($aFields) . " WHERE `display_name`=:display_name AND `input_name`=:input_name ", [

+ 24 - 0
studio/classes/BxDolStudioNavigationQuery.php

@@ -100,6 +100,18 @@ class BxDolStudioNavigationQuery extends BxDolDb
         return $this->query("INSERT INTO `sys_objects_menu` SET " . $this->arrayToSQL($aFields));
     }
 
+    function updateMenus($aParamsSet, $aParamsWhere = [])
+    {
+        if(empty($aParamsSet))
+            return false;
+
+        $sWhereClause = "1";
+        if(!empty($aParamsWhere))
+            $sWhereClause = $this->arrayToSQL($aParamsWhere, " AND ");
+
+        return $this->query("UPDATE `sys_objects_menu` SET " . $this->arrayToSQL($aParamsSet) . " WHERE " . $sWhereClause);
+    }
+    
     function updateMenuByObject($sObject, $aFields)
     {
         return $this->query("UPDATE `sys_objects_menu` SET " . $this->arrayToSQL($aFields) . " WHERE `object`=:object", [
@@ -411,6 +423,18 @@ class BxDolStudioNavigationQuery extends BxDolDb
         return $this->query($sSql, ['id' => $iId]);
     }
 
+    function updateItems($aParamsSet, $aParamsWhere = [])
+    {
+        if(empty($aParamsSet))
+            return false;
+
+        $sWhereClause = "1";
+        if(!empty($aParamsWhere))
+            $sWhereClause = $this->arrayToSQL($aParamsWhere, " AND ");
+
+        return $this->query("UPDATE `sys_menu_items` SET " . $this->arrayToSQL($aParamsSet) . " WHERE " . $sWhereClause);
+    }
+
     function updateItemBySetAndName($sSetName, $sName, $aFields)
     {
         return $this->query("UPDATE `sys_menu_items` SET " . $this->arrayToSQL($aFields) . " WHERE `set_name`=:set_name AND `name`=:name", [