Selaa lähdekoodia

Ticket #5487 - Paid Levels: Add possibility to show Standard level in select Membership block.

AntonLV 5 kuukautta sitten
vanhempi
sitoutus
9bb7a2b0ee

+ 3 - 0
modules/boonex/acl/classes/BxAclConfig.php

@@ -38,6 +38,9 @@ class BxAclConfig extends BxBaseModGeneralConfig
             'FIELD_ID' => 'id',
             'FIELD_LEVEL_ID' => 'level_id',
             'FIELD_NAME' => 'name',
+            'FIELD_PRICE' => 'price',
+            'FIELD_TRIAL' => 'trial',
+            'FIELD_IMMEDIATE' => 'immediate',
 
             // page URIs
             'URL_ADMINISTRATION' => 'page.php?i=acl-administration',

+ 1 - 1
modules/boonex/acl/classes/BxAclDb.php

@@ -60,7 +60,7 @@ class BxAclDb extends BxDolModuleDb
                 $aMethod['name'] = 'getPairs';
                 $aMethod['params'][1] = 'id';
                 $aMethod['params'][2] = 'name';
-                $sWhereClause .= "AND `tal`.`Active`='yes' AND (`tal`.`Purchasable`='yes' OR `tal`.`Removable`='yes')";
+                $sWhereClause .= "AND `tal`.`Active`='yes' AND (`tal`.`ID`='3' OR `tal`.`Purchasable`='yes' OR `tal`.`Removable`='yes')";
                 break;
         }
 

+ 21 - 17
modules/boonex/acl/classes/BxAclFormPrice.php

@@ -14,6 +14,8 @@ class BxAclFormPrice extends BxTemplStudioFormView
     protected $_sModule;
     protected $_oModule;
 
+    protected $_bDisplayEdit;
+
     public function __construct($aInfo, $oTemplate = false)
     {
         $this->_sModule = 'bx_acl';
@@ -23,15 +25,18 @@ class BxAclFormPrice extends BxTemplStudioFormView
 
         $CNF = &$this->_oModule->_oConfig->CNF;
 
+        $this->_bDisplayEdit = $this->aParams['display'] == $CNF['OBJECT_FORM_PRICE_DISPLAY_EDIT'];
+
         if(isset($this->aInputs[$CNF['FIELD_LEVEL_ID']])) {
             $aLevels = $this->_oModule->_oDb->getLevels(['type' => 'for_selector']);
 
             $this->aInputs[$CNF['FIELD_LEVEL_ID']]['values'][] = ['key' => 0, 'value' => _t('_sys_please_select')];
             foreach($aLevels as $iId => $sTitle)
-                $this->aInputs[$CNF['FIELD_LEVEL_ID']]['values'][] = [
-                    'key' => $iId, 
-                    'value' => _t($sTitle)
-                ];
+                if($iId != MEMBERSHIP_ID_STANDARD)
+                    $this->aInputs[$CNF['FIELD_LEVEL_ID']]['values'][] = [
+                        'key' => $iId, 
+                        'value' => _t($sTitle)
+                    ];
         }
 
         if(isset($this->aInputs[$CNF['FIELD_NAME']])) {
@@ -39,7 +44,7 @@ class BxAclFormPrice extends BxTemplStudioFormView
 
             $iId = $this->getId();
             $aMask = array('mask' => "javascript:%s.checkName('%s');", $sJsObject, $CNF['FIELD_NAME']);
-            if(!empty($iId) && $this->aParams['display'] == $CNF['OBJECT_FORM_PRICE_DISPLAY_EDIT']) {
+            if(!empty($iId) && $this->_bDisplayEdit) {
                 $aMask['mask'] = "javascript:%s.checkName('%s', %d);";
                 $aMask[] = $iId;
             }
@@ -79,22 +84,21 @@ class BxAclFormPrice extends BxTemplStudioFormView
         return $sCode;
     }
 
-    /*
-    public function initChecker ($aValues = array (), $aSpecificValues = array())
+    public function initChecker($aValues = [], $aSpecificValues = [])
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
-        
-        $bValues = $aValues && !empty($aValues[$CNF['FIELD_ID']]);
 
-        if(isset($this->aInputs[$CNF['FIELD_NAME']])) {
-            if ($bValues)
-                $this->aInputs[$CNF['FIELD_POLL']]['content_id'] = $aValues['id'];
+        parent::initChecker($aValues, $aSpecificValues);
+
+        if($this->_bDisplayEdit) {
+            if(($aValues['level_id'] ?? 0) == MEMBERSHIP_ID_STANDARD) {
+                foreach([$CNF['FIELD_LEVEL_ID'], $CNF['FIELD_NAME'], $CNF['FIELD_PRICE'], $CNF['FIELD_TRIAL'], $CNF['FIELD_IMMEDIATE']] as $sField)
+                    if(isset($this->aInputs[$sField]))
+                        $this->aInputs[$sField]['type'] = 'hidden';
+            }
         }
-        
-        parent::initChecker ($aValues, $aSpecificValues);
     }
-*/
-    
+
     public function insert ($aValsToAdd = array(), $isIgnore = false)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
@@ -108,7 +112,7 @@ class BxAclFormPrice extends BxTemplStudioFormView
         return parent::insert ($aValsToAdd, $isIgnore);
     }
 
-    function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
+    public function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
 

+ 1 - 1
modules/boonex/acl/classes/BxAclGridAdministration.php

@@ -168,7 +168,7 @@ class BxAclGridAdministration extends BxAclGridLevels
 
     protected function _getCellLevelId($mixedValue, $sKey, $aField, $aRow)
     {
-        $mixedValue = _t(isset($this->_aLevels[$mixedValue]) ? $this->_aLevels[$mixedValue] : '_undefined');
+        $mixedValue = _t($this->_aLevels[$mixedValue] ?? '_undefined');
 
     	return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
     }

+ 3 - 0
modules/boonex/acl/install/langs/en.xml

@@ -118,6 +118,9 @@
     <string name="_bx_acl_err_cannot_perform"><![CDATA[An error appeared. Please report.]]></string>
 
     <string name="_bx_acl_txt_all_level"><![CDATA[All levels]]></string>
+    <string name="_bx_acl_txt_level_caption_standard"><![CDATA[Free]]></string>
+    <string name="_bx_acl_txt_level_description_standard"><![CDATA[Try basic features for free.]]></string>
+    <string name="_bx_acl_txt_level_details_standard"><![CDATA[More info may be here.]]></string>
     <string name="_bx_acl_txt_cart_item_title"><![CDATA[{0} ({1} {2})]]></string>
     <string name="_bx_acl_txt_cart_item_title_lifetime"><![CDATA[{0} (lifetime)]]></string>
     <string name="_bx_acl_txt_cart_item_description"><![CDATA[Membership level on {0} site.]]></string>

+ 4 - 1
modules/boonex/acl/install/sql/install.sql

@@ -21,6 +21,9 @@ CREATE TABLE `bx_acl_level_prices` (
   UNIQUE KEY `name` (`name`)
 );
 
+INSERT INTO `bx_acl_level_prices` (`level_id`, `name`, `caption`, `description`, `details`, `period`, `period_unit`, `trial`, `price`, `immediate`, `added`, `active`, `order`) VALUES
+(3, 'standard', '_bx_acl_txt_level_caption_standard', '_bx_acl_txt_level_description_standard', '_bx_acl_txt_level_details_standard', 0, '', 0, 0, 1, UNIX_TIMESTAMP(), 0, 1);
+
 -- TABLE: licenses
 CREATE TABLE IF NOT EXISTS `bx_acl_licenses` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -107,7 +110,7 @@ INSERT INTO `sys_form_pre_values`(`Key`, `Value`, `Order`, `LKey`, `LKey2`) VALU
 -- GRIDS
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
 ('bx_acl_administration', 'Sql', 'SELECT * FROM `bx_acl_level_prices` WHERE 1 ', 'bx_acl_level_prices', 'id', 'order', 'active', '', 100, NULL, 'start', '', 'period,period_unit,price', 'caption', 'like', '', '', 192, 'BxAclGridAdministration', 'modules/boonex/acl/classes/BxAclGridAdministration.php'),
-('bx_acl_view', 'Sql', 'SELECT `tlp`.*, `tl`.`Name` AS `level_name`, `tl`.`Icon` AS `level_icon` FROM `bx_acl_level_prices` AS `tlp` LEFT JOIN `sys_acl_levels` AS `tl` ON `tlp`.`level_id`=`tl`.`ID` WHERE `tlp`.`active`<>''0'' && `tl`.`Active`=''yes'' AND `tl`.`Purchasable`=''yes'' ', 'bx_acl_level_prices', 'id', 'order', '', '', 100, NULL, 'start', '', 'period,period_unit,price', 'tl`.`Name', 'like', '', '', 2147483647, 'BxAclGridView', 'modules/boonex/acl/classes/BxAclGridView.php');
+('bx_acl_view', 'Sql', 'SELECT `tlp`.*, `tl`.`Name` AS `level_name`, `tl`.`Icon` AS `level_icon` FROM `bx_acl_level_prices` AS `tlp` LEFT JOIN `sys_acl_levels` AS `tl` ON `tlp`.`level_id`=`tl`.`ID` WHERE `tlp`.`active`<>''0'' && `tl`.`Active`=''yes'' ', 'bx_acl_level_prices', 'id', 'order', '', '', 100, NULL, 'start', '', 'period,period_unit,price', 'tl`.`Name', 'like', '', '', 2147483647, 'BxAclGridView', 'modules/boonex/acl/classes/BxAclGridView.php');
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
 ('bx_acl_administration', 'checkbox', '_sys_select', '2%', 0, '', '', 1),

+ 3 - 0
modules/boonex/russian/data/langs/bx_acl/ru.xml

@@ -118,6 +118,9 @@
     <string name="_bx_acl_err_cannot_perform"><![CDATA[Невозможно выполнить действие. Пожалуйста, оповестите нас об этой проблеме.]]></string>
 
     <string name="_bx_acl_txt_all_level"><![CDATA[Все уровни]]></string>
+    <string name="_bx_acl_txt_level_caption_standard"><![CDATA[Бесплатно]]></string>
+    <string name="_bx_acl_txt_level_description_standard"><![CDATA[Попробуйте базовые функции бесплатно.]]></string>
+    <string name="_bx_acl_txt_level_details_standard"><![CDATA[Более подробная информация может быть здесь.]]></string>
     <string name="_bx_acl_txt_cart_item_title"><![CDATA[{0} ({1} {2})]]></string>
     <string name="_bx_acl_txt_cart_item_title_lifetime"><![CDATA[{0} (пожизненно)]]></string>
     <string name="_bx_acl_txt_cart_item_description"><![CDATA[Членство на сайте {0}.]]></string>