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

Ticket #4148 - Build-in API support: Connection lists.

AntonLV 3 лет назад
Родитель
Сommit
b73d875a82

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

@@ -2092,8 +2092,11 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 
             if(($oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends')) !== false) {
                 $aResult['friends_count'] = $oConnection->getConnectedContentCount($iProfileId, true);
-                if(isLogged())
-                    $aResult['mutual_friends_count'] = $oConnection->getCommonContentCount($iProfileId, bx_get_logged_profile_id(), true);
+                if(isLogged()) {
+                    $iLoggedId = bx_get_logged_profile_id();
+                    $aResult['mutual_friends_count'] = $oConnection->getCommonContentCount($iProfileId, $iLoggedId, true);
+                    $aResult['mutual_friends_list'] = $oConnection->getCommonListAPI($iProfileId, $iLoggedId, true);
+                }
             }
 
             if(($oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions')) !== false)

+ 11 - 0
template/scripts/BxBaseConnection.php

@@ -151,6 +151,17 @@ class BxBaseConnection extends BxDolConnection
         return $aProfiles;
     }
 
+    public function getCommonListAPI($iProfileId1, $iProfileId2, $bIsMutual)
+    {
+        $aProfiles = [];
+        $aIds = $this->getCommonContent($iProfileId1, $iProfileId2, $bIsMutual, 0, BX_CONNECTIONS_LIST_COUNTER);
+        foreach($aIds as $iId)
+            if(($oProfile = BxDolProfile::getInstanceMagic($iId)) !== false)
+                $aProfiles[] = $oProfile->getUnitAPI(0, ['template' => 'unit_wo_info']);
+        
+        return $aProfiles;
+    }
+
     protected function _getJsScript($iProfileId, $sContentType, $bIsMutual, $aHtmlIds, $bDynamicMode = false)
     {
         $sJsObject = $this->getJsObjectName($iProfileId);