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

#5254 API endpoints do not return post labels field

Aleksandr T 8 месяцев назад
Родитель
Сommit
93722fc01c

+ 13 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -4389,6 +4389,19 @@ class BxBaseModGeneralModule extends BxDolModule
         return $aData;
     }
 
+    protected function decodeDataAPICommonFields(&$aResult, $aData, $aParams) 
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        if (!empty($CNF['FIELD_LABELS'])) {
+            $aResult[$CNF['FIELD_LABELS']] = empty($aData[$CNF['FIELD_LABELS']]) ? [] : unserialize($aData[$CNF['FIELD_LABELS']]);
+        }
+
+        if (!empty($CNF['FIELD_LOCATION'])) {
+            $aResult[$CNF['FIELD_LOCATION']] = empty($aData[$CNF['FIELD_LOCATION']]) ? [] : unserialize($aData[$CNF['FIELD_LOCATION']]);
+        }
+    }
+
     // ====== PROTECTED METHODS
 
     protected function _serviceEntityForm ($sFormMethod, $iContentId = 0, $sDisplay = false, $sCheckFunction = false, $bErrorMsg = true)

+ 2 - 0
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -2532,6 +2532,8 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             $aResult['meta'] = $oMetaMenu->getCodeAPI();
         }
 
+        $this->decodeDataAPICommonFields($aResult, $aData, $aParams);
+        
         return $aResult;
     }
 

+ 3 - 1
modules/base/text/classes/BxBaseModTextModule.php

@@ -658,7 +658,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
             'title' => $aData[$CNF['FIELD_TITLE']],
             'url' => bx_api_get_relative_url($this->serviceGetLink($iId)),
             'image' => $this->serviceGetThumb($iId),
-            'summary_plain' => $sSummary
+            'summary_plain' => $sSummary,
         ];
 
         if(isset($aParams['extended']) && $aParams['extended'] === true)
@@ -670,6 +670,8 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
             $aResult['meta'] = $oMetaMenu->getCodeAPI();
         }
 
+        $this->decodeDataAPICommonFields($aResult, $aData, $aParams);
+
         return $aResult;
     }