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

#4148 - Build-in API support (connection lists)

roman.lesnikov@gmail.com 3 лет назад
Родитель
Сommit
c35307b8b2

+ 1 - 0
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -124,6 +124,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         if ($oConnection){
             $oProfile = BxDolProfile::getInstanceByContentAndType($aData[$CNF['FIELD_ID']], $this->_aModule['name']);
             $aResult['members_count'] = $oConnection->getConnectedInitiatorsCount($oProfile->id(), false);
+            $aResult['members_list'] = $oConnection->getConnectedListAPI($oProfile->id(), false, BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
         }
         $aResult['visibility'] = $aData[$CNF['FIELD_ALLOW_VIEW_TO']];
 

+ 11 - 0
template/scripts/BxBaseConnection.php

@@ -139,6 +139,17 @@ class BxBaseConnection extends BxDolConnection
             'countf' => _t(isset($aParams['caption']) ? $aParams['caption'] : '_view_counter', $iCount)
         ];
     }
+    
+    public function getConnectedListAPI($iProfileId, $bIsMutual, $sContentType)
+    {
+        $aProfiles = [];
+        $aIds = $this->{BX_CONNECTIONS_CONTENT_TYPE_INITIATORS == $sContentType ? 'getConnectedInitiators' : 'getConnectedContent'}($iProfileId, $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)
     {

+ 16 - 1
template/scripts/BxBaseServiceAccount.php

@@ -167,7 +167,22 @@ class BxBaseServiceAccount extends BxDol
     {
         if (false === $iAccountId)
             $iAccountId = getLoggedId();
-        return $this->_oAccountForms->editAccountInfoForm($iAccountId);
+        
+        $bApi = bx_is_api();
+        
+        $mixedResult =$this->_oAccountForms->editAccountInfoForm($iAccountId);
+        if($bApi) {
+            if(is_array($mixedResult))
+                return [bx_api_get_block('form', $mixedResult, [
+                    'ext' => [
+                        'request' => ['url' => '/api.php?r=system/account_settings_email/TemplServiceAccount', 'immutable' => true]
+                    ]
+                ])];
+            else
+                return bx_api_get_msg($mixedResult);
+        }
+        
+        return $mixedResult;
     }
 
     public function serviceAccountSettingsDelAccount ($iAccountId = false)