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

#4148 Build-in API support (profile switcher)

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

+ 14 - 0
template/scripts/BxBaseServiceProfiles.php

@@ -777,6 +777,16 @@ class BxBaseServiceProfiles extends BxDol
 
             if (!BxDolService::call($aProfile['type'], 'act_as_profile'))
                 continue;
+            
+            if($this->_bIsApi){
+                $o = BxDolProfile::getInstance($aProfile['id']);
+                $aProfilesData[] = [
+                    'id' => $o->id(),
+                    'display_name' => $o->getDisplayName(),
+                    'url' => bx_api_get_relative_url($o->getUrl()),
+                    'avatar' => $o->getAvatar()
+                ];
+            }
 
             $aVars['bx_repeat:row'][] = array (
                 'class' => $iActiveProfileId == $aProfile['id'] ? '' : 'bx-def-color-bg-box',
@@ -796,6 +806,10 @@ class BxBaseServiceProfiles extends BxDol
             );
         }
 
+        if($this->_bIsApi){
+            return ['active_profile_id' => $iActiveProfileId, 'profiles' => $aProfilesData];
+        }
+        
         $oTemplate->addCss('account.css');
         return array(
             'content' => $oTemplate->parseHtmlByName('profile_switch_row.html', $aVars),

+ 1 - 0
template/scripts/BxBaseServices.php

@@ -62,6 +62,7 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         
             'KeywordsCloud' => 'BxBaseServiceMetatags',
 
+            'AccountProfileSwitcher' => 'BxBaseServiceProfiles',
             'ProfileMembership' => 'BxBaseServiceProfiles',
             'ProfileNotifications' => 'BxBaseServiceProfiles',
             'GetCountOnlineProfiles' => 'BxBaseServiceProfiles',