Просмотр исходного кода

Ticket #2573 - Related changes in Market and Paid Levels modules.

AntonLV 6 лет назад
Родитель
Сommit
c6b5fc1306

+ 18 - 7
modules/boonex/acl/classes/BxAclDb.php

@@ -104,16 +104,16 @@ class BxAclDb extends BxDolModuleDb
             case 'by_id':
                 $aMethod['name'] = 'getRow';
                 $aMethod['params'][1] = array(
-                	'id' => $aParams['value']
+                    'id' => $aParams['value']
                 );
 
                 $sWhereClause .= "AND `tap`.`id`=:id";
                 break;
 
-			case 'by_id_full':
+            case 'by_id_full':
                 $aMethod['name'] = 'getRow';
                 $aMethod['params'][1] = array(
-                	'id' => $aParams['value']
+                    'id' => $aParams['value']
                 );
 
                 $sSelectClause .= ", `tal`.`Name` AS `level_name`, `tal`.`Description` AS `level_description`";
@@ -121,9 +121,20 @@ class BxAclDb extends BxDolModuleDb
                 $sWhereClause .= "AND `tap`.`id`=:id";
                 break;
 
+            case 'by_name_full':
+                $aMethod['name'] = 'getRow';
+                $aMethod['params'][1] = array(
+                    'name' => $aParams['value']
+                );
+
+                $sSelectClause .= ", `tal`.`Name` AS `level_name`, `tal`.`Description` AS `level_description`";
+                $sJoinClause .= "LEFT JOIN `sys_acl_levels` AS `tal` ON `tap`.`level_id`=`tal`.`ID`";
+                $sWhereClause .= "AND `tap`.`name`=:name";
+                break;
+
             case 'by_level_id':
             	$aMethod['params'][1] = array(
-                	'level_id' => $aParams['value']
+                    'level_id' => $aParams['value']
                 );
 
                 $sWhereClause .= "AND `tap`.`level_id`=:level_id";
@@ -132,9 +143,9 @@ class BxAclDb extends BxDolModuleDb
             case 'by_level_id_duration':
                 $aMethod['name'] = 'getRow';
                 $aMethod['params'][1] = array(
-                	'level_id' => $aParams['level_id'],
-                	'period' => $aParams['period'],
-                	'period_unit' => $aParams['period_unit'],
+                    'level_id' => $aParams['level_id'],
+                    'period' => $aParams['period'],
+                    'period_unit' => $aParams['period_unit'],
                 );
 
                 $sWhereClause .= "AND `tap`.`level_id`=:level_id AND `tap`.`period`=:period AND `tap`.`period_unit`=:period_unit";

+ 12 - 8
modules/boonex/acl/classes/BxAclModule.php

@@ -156,7 +156,7 @@ class BxAclModule extends BxDolModule
      * 
      * Get an array with level's description. Is used in Shopping Cart in payments processing module.
      * 
-     * @param $iItemId level's ID.
+     * @param $mixedItemId level's ID or Unique Name.
      * @return an array with level's description. Empty array is returned if something is wrong.
      * 
      * @see BxAclModule::serviceGetCartItem
@@ -164,18 +164,22 @@ class BxAclModule extends BxDolModule
     /** 
      * @ref bx_acl-get_cart_item "get_cart_item"
      */
-    public function serviceGetCartItem($iItemId)
+    public function serviceGetCartItem($mixedItemId)
     {
-    	$CNF = &$this->_oConfig->CNF;
+        $CNF = &$this->_oConfig->CNF;
 
-        if(!$iItemId)
-			return array();
+        if(!$mixedItemId)
+            return array();
+
+        if(is_numeric($mixedItemId))
+            $aItem = $this->_oDb->getPrices(array('type' => 'by_id_full', 'value' => (int)$mixedItemId));
+        else 
+            $aItem = $this->_oDb->getPrices(array('type' => 'by_name_full', 'value' => $mixedItemId));
 
-		$aItem = $this->_oDb->getPrices(array('type' => 'by_id_full', 'value' => $iItemId));
         if(empty($aItem) || !is_array($aItem))
-			return array();
+            return array();
 
-		return array (
+        return array (
             'id' => $aItem['id'],
             'author_id' => $this->_oConfig->getOwner(),
             'name' => $aItem['name'],

+ 8 - 4
modules/boonex/market/classes/BxMarketModule.php

@@ -711,7 +711,7 @@ class BxMarketModule extends BxBaseModTextModule
      * 
      * Get an array with prodict's description. Is used in Shopping Cart in payments processing module.
      * 
-     * @param $iItemId product's ID.
+     * @param $mixedItemId product's ID or Unique Name.
      * @return an array with prodict's description. Empty array is returned if something is wrong.
      * 
      * @see BxMarketModule::serviceGetCartItem
@@ -719,14 +719,18 @@ class BxMarketModule extends BxBaseModTextModule
     /** 
      * @ref bx_market-get_cart_item "get_cart_item"
      */
-    public function serviceGetCartItem($iItemId)
+    public function serviceGetCartItem($mixedItemId)
     {
     	$CNF = &$this->_oConfig->CNF;
 
-        if(!$iItemId)
+        if(!$mixedItemId)
             return array();
 
-        $aItem = $this->_oDb->getContentInfoById($iItemId);
+        if(is_numeric($mixedItemId))
+            $aItem = $this->_oDb->getContentInfoById((int)$mixedItemId);
+        else
+            $aItem = $this->_oDb->getContentInfoByName($mixedItemId);
+
         if(empty($aItem) || !is_array($aItem))
             return array();