Ver código fonte

Ticket #4971 - Build-in API support: Don't show non-existent contexts in Context Switcher.

AntonLV 9 meses atrás
pai
commit
16045f2b29
2 arquivos alterados com 8 adições e 3 exclusões
  1. 1 1
      inc/classes/BxDolProfile.php
  2. 7 2
      template/scripts/BxBasePage.php

+ 1 - 1
inc/classes/BxDolProfile.php

@@ -144,7 +144,7 @@ class BxDolProfile extends BxDolFactory implements iBxDolProfile
         $aRv = [
             'id' => $oProfile->id(),
             'display_name' => $oProfile->getDisplayName(),
-            'url' => bx_api_get_relative_url($oProfile->getUrl()),
+            'url' => ($sUrl = $oProfile->getUrl()) !== false ? bx_api_get_relative_url($sUrl) : false,
             'url_avatar' => $oProfile->{isset($aParams['get_avatar']) && method_exists($oProfile, $aParams['get_avatar']) ? $aParams['get_avatar'] : 'getAvatar'}(),
             'module' => $oProfile->getModule(),
         ];

+ 7 - 2
template/scripts/BxBasePage.php

@@ -660,8 +660,13 @@ class BxBasePage extends BxDolPage
                 $aCpIds = bx_srv($sContextSwitcher, 'get_participating_profiles', [$iLogged, ($sContextConnection != 'participants' ? $sContextConnection : false)]);
 
                 $aContexts = [];
-                foreach($aCpIds as $iCpId)
-                    $aContexts[] = BxDolProfile::getData($iCpId);
+                foreach($aCpIds as $iCpId) {
+                    $aProfileData = BxDolProfile::getData($iCpId); 
+                    if($aProfileData['display_name'] === false && $aProfileData['url'] === false )
+                        continue;
+
+                    $aContexts[] = $aProfileData;
+                }
 
                 $aInvitedTo = [];
                 if(($aInvitations = bx_srv($sContextSwitcher, 'invitations', [$iLogged, true])) && is_array($aInvitations))