AntonLV 9 роки тому
батько
коміт
faf5a2d437

+ 6 - 5
install/sql/system.sql

@@ -2702,16 +2702,17 @@ CREATE TABLE `sys_form_pre_lists` (
   `key` varchar(255) NOT NULL default '',
   `title` varchar(255) NOT NULL default '',
   `use_for_sets` tinyint(4) unsigned NOT NULL default '1',
+  `extendable` tinyint(4) unsigned NOT NULL default '1',
   PRIMARY KEY (`id`),
   UNIQUE KEY `key` (`key`),
   FULLTEXT KEY `ModuleAndKey` (`module`, `key`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
-INSERT INTO `sys_form_pre_lists`(`key`, `title`, `module`, `use_for_sets`) VALUES
-('Country', '_adm_form_txt_pre_lists_country', 'system', '0'),
-('Sex', '_adm_form_txt_pre_lists_sex', 'system', '1'),
-('Language', '_adm_form_txt_pre_lists_language', 'system', '0'),
-('sys_report_types', '_sys_pre_lists_report_types', 'system', '0');
+INSERT INTO `sys_form_pre_lists`(`key`, `title`, `module`, `use_for_sets`, `extendable`) VALUES
+('Country', '_adm_form_txt_pre_lists_country', 'system', '0', '0'),
+('Sex', '_adm_form_txt_pre_lists_sex', 'system', '1', '1'),
+('Language', '_adm_form_txt_pre_lists_language', 'system', '0', '1'),
+('sys_report_types', '_sys_pre_lists_report_types', 'system', '0', '0');
 
 
 CREATE TABLE `sys_form_pre_values` (

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

@@ -103,6 +103,11 @@ class BxDevFormsPreValues extends BxTemplStudioFormsPreValues
         }
     }
 
+    protected function canAdd()
+    {
+        return $this->sList != '';
+    }
+
     private function onLoad(&$aInputs)
     {
         $aLists = array();

+ 1 - 1
modules/boonex/developer/install/sql/install.sql

@@ -229,7 +229,7 @@ INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `c
 ('bx_developer_forms_prevalue', @sName, 'id', '0', '', 0, 'hidden', '_bx_dev_frm_txt_sys_prevalues_id', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 0, 0),
 ('bx_developer_forms_prevalue', @sName, 'Key', '', '', 0, 'select', '_bx_dev_frm_txt_sys_prevalues_key', '_bx_dev_frm_txt_prevalues_key', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_dev_frm_err_prevalues_key', 'Xss', '', 0, 0),
 ('bx_developer_forms_prevalue', @sName, 'Value', '', '', 0, 'text', '_bx_dev_frm_txt_sys_prevalues_value', '_bx_dev_frm_txt_prevalues_value', '', 1, 0, 0, '', '', '', 'Length', 'a:2:{s:3:"min";i:1;s:3:"max";i:255;}', '_bx_dev_frm_err_prevalues_value', 'Xss', '', 0, 0),
-('bx_developer_forms_prevalue', @sName, 'LKey', '', '', 0, 'text', '_bx_dev_frm_txt_sys_prevalues_lkey', '_bx_dev_frm_txt_prevalues_lkey', '', 1, 0, 0, '', '', '', 'Length', 'a:2:{s:3:"min";i:6;s:3:"max";i:100;}', '_bx_dev_frm_err_prevalues_lkey', 'Xss', '', 0, 0),
+('bx_developer_forms_prevalue', @sName, 'LKey', '', '', 0, 'text', '_bx_dev_frm_txt_sys_prevalues_lkey', '_bx_dev_frm_txt_prevalues_lkey', '', 1, 0, 0, '', '', '', 'Length', 'a:2:{s:3:"min";i:1;s:3:"max";i:100;}', '_bx_dev_frm_err_prevalues_lkey', 'Xss', '', 0, 0),
 ('bx_developer_forms_prevalue', @sName, 'LKey2', '', '', 0, 'text', '_bx_dev_frm_txt_sys_prevalues_lkey2', '_bx_dev_frm_txt_prevalues_lkey2', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
 ('bx_developer_forms_prevalue', @sName, 'controls', '', 'do_submit,cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
 ('bx_developer_forms_prevalue', @sName, 'do_submit', '_bx_dev_frm_btn_prevalues_add', '', 0, 'submit', '_bx_dev_frm_btn_sys_prevalues_add', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),

+ 2 - 2
modules/boonex/payment/install/sql/install.sql

@@ -387,8 +387,8 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 
 
 -- PRE-VALUES
-INSERT INTO `sys_form_pre_lists`(`key`, `title`, `module`, `use_for_sets`) VALUES
-('bx_payment_currencies', '_bx_payment_pre_lists_currencies', 'bx_payment', '0');
+INSERT INTO `sys_form_pre_lists`(`key`, `title`, `module`, `use_for_sets`, `extendable`) VALUES
+('bx_payment_currencies', '_bx_payment_pre_lists_currencies', 'bx_payment', '0', '0');
 
 INSERT INTO `sys_form_pre_values`(`Key`, `Value`, `Order`, `LKey`, `LKey2`) VALUES
 ('bx_payment_currencies', 'AUD', 1, 'AUD', 'A$'),

+ 5 - 0
studio/classes/BxDolStudioFormsPreValues.php

@@ -12,7 +12,9 @@ define('BX_DOL_STUDIO_FIELD_PRE_VALUE_INT_MAX', round(log(BX_DOL_INT_MAX, 2)));
 class BxDolStudioFormsPreValues extends BxTemplStudioGrid
 {
     protected $sModule;
+
     protected $sList;
+    protected $aList;
 
     public function __construct ($aOptions, $oTemplate = false)
     {
@@ -30,6 +32,9 @@ class BxDolStudioFormsPreValues extends BxTemplStudioGrid
         if(!empty($sList)) {
             $this->sList = bx_process_input($sList);
             $this->_aQueryAppend['list'] = $this->sList;
+
+            $this->aList = array();
+            $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $this->aList, false);
         }
     }
 

+ 2 - 1
studio/classes/BxDolStudioFormsQuery.php

@@ -440,7 +440,8 @@ class BxDolStudioFormsQuery extends BxDolDb
                 `tl`.`module` AS `module`,
                 `tl`.`key` AS `key`,
                 `tl`.`title` AS `title`,
-                `tl`.`use_for_sets` AS `use_for_sets`" . $sSelectClause . "
+                `tl`.`use_for_sets` AS `use_for_sets`,
+                `tl`.`extendable` AS `extendable`" . $sSelectClause . "
             FROM `sys_form_pre_lists` AS `tl` " . $sJoinClause . "
             WHERE 1 " . $sWhereClause . " " . $sGroupClause . " " . $sOrderClause . " " . $sLimitClause;
         $aItems = call_user_func_array(array($this, $aMethod['name']), $aMethod['params']);

+ 17 - 15
studio/template/scripts/BxBaseStudioFormsPreValues.php

@@ -26,10 +26,12 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
     {
         $sAction = 'add';
 
-        $aList = array();
-        $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $aList, false);
+        if(!$this->canAdd()) {
+            echoJson(array());
+            exit;
+        }
 
-        $bUseInSets = (int)$aList['use_for_sets'] == 1;
+        $bUseInSets = (int)$this->aList['use_for_sets'] == 1;
 
         bx_import('BxTemplStudioFormView');
 
@@ -77,7 +79,7 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
                     ),
                     'checker' => array (
                         'func' => 'LengthTranslatable',
-                        'params' => array(3,100, 'LKey'),
+                        'params' => array(1,100, 'LKey'),
                         'error' => _t('_adm_form_err_pre_values_lkey'),
                     ),
                 ),
@@ -125,7 +127,7 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
                         return;
                     }
 
-                    $this->oDb->updateList($aList['id'], array('use_for_sets' => '0'));
+                    $this->oDb->updateList($this->aList['id'], array('use_for_sets' => '0'));
                 }
             }
 
@@ -159,9 +161,7 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
             exit;
         }
 
-        $aList = array();
-        $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $aList, false);
-        $bUseInSets = (int)$aList['use_for_sets'] == 1;
+        $bUseInSets = (int)$this->aList['use_for_sets'] == 1;
 
         bx_import('BxTemplStudioFormView');
 
@@ -255,7 +255,7 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
                         return;
                     }
 
-                    $this->oDb->updateList($aList['id'], array('use_for_sets' => '0'));
+                    $this->oDb->updateList($this->aList['id'], array('use_for_sets' => '0'));
                 }
             }
 
@@ -291,9 +291,6 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
 
         $oLanguage = BxDolStudioLanguagesUtils::getInstance();
 
-        $aList = array();
-        $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $aList, false);
-
         $aIdsAffected = array ();
         foreach($aIds as $iId) {
             $aValue = array();
@@ -307,7 +304,7 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
             $oLanguage->deleteLanguageString($aValue['lkey']);
             $oLanguage->deleteLanguageString($aValue['lkey2']);
 
-            if((int)$aList['use_for_sets'] != 1) {
+            if((int)$this->aList['use_for_sets'] != 1) {
                 $bUseInSets = 1;
                 $aValues = BxDolForm::getDataItems($this->sList);
                 foreach($aValues as $mixedValue => $sTitle)
@@ -317,7 +314,7 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
                     }
 
                 if($bUseInSets == 1)
-                    $this->oDb->updateList($aList['id'], array('use_for_sets' => $bUseInSets));
+                    $this->oDb->updateList($this->aList['id'], array('use_for_sets' => $bUseInSets));
             }
 
             $aIdsAffected[] = $iId;
@@ -389,7 +386,7 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
 
     protected function _getActionAdd($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
-        if($this->sList == '')
+        if(!$this->canAdd())
             $isDisabled = true;
 
         return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
@@ -438,6 +435,11 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
         return $iValue;
     }
 
+    protected function canAdd()
+    {
+        return $this->sList != '' && (int)$this->aList['extendable'] != 0;
+    }
+
     protected function canUseForSet($mixedValue)
     {
         return is_numeric($mixedValue) && (int)$mixedValue >= 1 && (int)$mixedValue <= BX_DOL_STUDIO_FIELD_PRE_VALUE_INT_MAX;