1
0
Эх сурвалжийг харах

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

roman.lesnikov@gmail.com 3 жил өмнө
parent
commit
b30359749c

+ 7 - 1
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -2083,6 +2083,9 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             'image' => $this->serviceGetThumb($iId),
             'cover' => $this->serviceGetCover($iId),
         ];
+        
+        if ($aParams['template'] == 'unit_wo_info')
+            return $aResult;
 
         if(isset($aParams['extended']) && $aParams['extended'] === true)
             $aResult['text'] = $aData[$CNF['FIELD_TEXT']];
@@ -2092,6 +2095,7 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 
             if(($oConnection = BxDolConnection::getObjectInstance('sys_profiles_friends')) !== false) {
                 $aResult['friends_count'] = $oConnection->getConnectedContentCount($iProfileId, true);
+                $aResult['friends_list'] = $oConnection->getConnectedListAPI($iProfileId, true, BX_CONNECTIONS_CONTENT_TYPE_CONTENT);
                 if(isLogged()) {
                     $iLoggedId = bx_get_logged_profile_id();
                     $aResult['mutual_friends_count'] = $oConnection->getCommonContentCount($iProfileId, $iLoggedId, true);
@@ -2099,8 +2103,10 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
                 }
             }
 
-            if(($oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions')) !== false)
+            if(($oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions')) !== false){
                 $aResult['followers_count'] = $oConnection->getConnectedInitiatorsCount($iProfileId);
+                $aResult['followers_list'] = $oConnection->getConnectedListAPI($iProfileId, false, BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
+            }
         }
 
         $sKey = 'OBJECT_MENU_SNIPPET_META';

+ 4 - 4
template/scripts/BxBaseConnection.php

@@ -140,10 +140,10 @@ class BxBaseConnection extends BxDolConnection
         ];
     }
     
-    public function getConnectedListAPI($iProfileId, $bIsMutual, $sContentType)
+    public function getConnectedListAPI($iProfileId, $bIsMutual, $sContentType, $iCount = BX_CONNECTIONS_LIST_COUNTER)
     {
         $aProfiles = [];
-        $aIds = $this->{BX_CONNECTIONS_CONTENT_TYPE_INITIATORS == $sContentType ? 'getConnectedInitiators' : 'getConnectedContent'}($iProfileId, $bIsMutual, 0, BX_CONNECTIONS_LIST_COUNTER);
+        $aIds = $this->{BX_CONNECTIONS_CONTENT_TYPE_INITIATORS == $sContentType ? 'getConnectedInitiators' : 'getConnectedContent'}($iProfileId, $bIsMutual, 0, $iCount);
         foreach($aIds as $iId)
             if(($oProfile = BxDolProfile::getInstanceMagic($iId)) !== false)
                 $aProfiles[] = $oProfile->getUnitAPI(0, ['template' => 'unit_wo_info']);
@@ -151,10 +151,10 @@ class BxBaseConnection extends BxDolConnection
         return $aProfiles;
     }
 
-    public function getCommonListAPI($iProfileId1, $iProfileId2, $bIsMutual)
+    public function getCommonListAPI($iProfileId1, $iProfileId2, $bIsMutual, $iCount = BX_CONNECTIONS_LIST_COUNTER)
     {
         $aProfiles = [];
-        $aIds = $this->getCommonContent($iProfileId1, $iProfileId2, $bIsMutual, 0, BX_CONNECTIONS_LIST_COUNTER);
+        $aIds = $this->getCommonContent($iProfileId1, $iProfileId2, $bIsMutual, 0, $iCount);
         foreach($aIds as $iId)
             if(($oProfile = BxDolProfile::getInstanceMagic($iId)) !== false)
                 $aProfiles[] = $oProfile->getUnitAPI(0, ['template' => 'unit_wo_info']);

+ 5 - 0
template/scripts/BxBasePage.php

@@ -459,6 +459,11 @@ class BxBasePage extends BxDolPage
                 $a['cover_block']['meta_menu'] =  $oMetaMenu->getCodeAPI();
             }
             
+            $oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
+            if ($oConnection){
+                $a['cover_block']['members_list'] =  $oConnection->getConnectedListAPI($this->_aProfileInfo['id'], false, BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 10);
+            }
+            
             if(!empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'])){
                 $oActionMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']);
                 $a['cover_block']['actions_menu'] = $oActionMenu->getCodeAPI();