Explorar o código

#4148 - Build-in API support (cmts)

roman.lesnikov@gmail.com %!s(int64=3) %!d(string=hai) anos
pai
achega
c96e5bbce1
Modificáronse 2 ficheiros con 7 adicións e 9 borrados
  1. 3 7
      inc/classes/BxDolCmts.php
  2. 4 2
      template/scripts/BxBaseCmtsServices.php

+ 3 - 7
inc/classes/BxDolCmts.php

@@ -2213,17 +2213,15 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
                 }
                 else {
                     $iPassLevel = $iLevel;
-                    $aPassStructure = &$aStructure;
+                    $aPassStructure = [];//&$aStructure TODO: need to be checked by author, changed to avoid *RECURSION*;
                 }
-
+                
                 foreach($aItems as $aItem)
                     $this->_getStructure($aItem, $aBp, $iPassLevel, $aPassStructure);
-
+                
                 //--- Sort subitems
                 $iWay = isset($aBp['order']['way']) && $aBp['order']['way'] == 'desc' ? -1 : 1;
 
-                //tODO fix
-               // print_r($aPassStructure);
                 uasort($aPassStructure, function($aItem1, $aItem2) use ($iWay) {
                     if($aItem1['order'] == $aItem2['order'])
                         return 0;
@@ -2231,8 +2229,6 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
                     return $iWay * ($aItem1['order'] < $aItem2['order'] ? -1 : 1);
                 });
                 $aStructure[$iI]['items'] = $aPassStructure;
-               // print_r($aPassStructure);
-            //    echo '-----------------';
             }
         }
     }

+ 4 - 2
template/scripts/BxBaseCmtsServices.php

@@ -511,6 +511,7 @@ class BxBaseCmtsServices extends BxDol
     
     public function serviceGetCommentsApi($oCmts, $aParams)
     {
+        
         $mixedResult = $oCmts->isViewAllowed();
         if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
             return $mixedResult; // TODO: error checking
@@ -518,7 +519,7 @@ class BxBaseCmtsServices extends BxDol
         $aBp = !isset($aParams['aBp']) ? [] : $aParams['aBp'];
         $aDp = ['in_designbox' => false, 'show_empty' => false];
         
-        $aDp['type'] = !getParam('sys_api_access_unsafe_services') ? 'threaded' : 'flat';
+        $aDp['type'] = !getParam('sys_api_comments_flat') ? 'threaded' : 'flat';
         $aBp['type'] = 'head';
         $oCmts->getParams($aBp, $aDp);
         $oCmts->prepareParams($aBp, $aDp);
@@ -554,6 +555,7 @@ class BxBaseCmtsServices extends BxDol
             }
             $aCmtsRv[] = $oCmt;
         }
+        
         $aData = [
             'unit' => 'comments',
             'start' => $aParams['start_from'],
@@ -579,7 +581,7 @@ class BxBaseCmtsServices extends BxDol
         if (isset($aParams['comment_id'])){
             $aRv['new'] = $aParams['comment_id'];
         }
-        print_r($aRv);
+       
         return $aRv;
     }
 }