Bläddra i källkod

Ticket #3467 - Updated switcher availability.

AntonLV 5 år sedan
förälder
incheckning
fda892918c
3 ändrade filer med 30 tillägg och 20 borttagningar
  1. 1 1
      install/sql/system.sql
  2. 7 5
      template/profile_avatar.html
  3. 22 14
      template/scripts/BxBaseServiceProfiles.php

+ 1 - 1
install/sql/system.sql

@@ -5146,7 +5146,7 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `
 -- content blocks
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `tabs`, `async`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
 
-('sys_home', 0, 'system', '', '_sys_page_block_title_profile_avatar', 3, 0, 0, 2147483644, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:14:"profile_avatar";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 0, 1, 1),
+('sys_home', 0, 'system', '', '_sys_page_block_title_profile_avatar', 3, 0, 0, 2147483646, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:14:"profile_avatar";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 0, 1, 1),
  
 ('sys_home', 0, 'system', '', '_sys_page_block_title_profile_menu', 3, 0, 0, 2147483644, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:12:"profile_menu";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 0, 1, 2),
 

+ 7 - 5
template/profile_avatar.html

@@ -1,5 +1,5 @@
 <div class="bx-profile-avatar bx-def-border-radius-block">
-    <a href="javascript:void(0)" onclick="javascript:$('#bx-profile-switcher').dolPopup({});">
+    <a href="__switcher_url__" onclick="__switcher_onclick__">
         <div class="bx-profile-avatar-cnt bx-def-padding-sec">
             <div class="bx-pa-img">__profile_unit__</div>
             <div class="bx-pa-info">
@@ -10,10 +10,12 @@
                     </div>
                 </div>
             </div>
-            <div class="bx-pa-actions">
-                <div class="bx-pa-action bx-def-margin-sec-left"><i class="sys-icon arrows-alt-v"></i></div>
-            </div>
+            <bx_if:show_switcher_icon>
+                <div class="bx-pa-actions">
+                    <div class="bx-pa-action bx-def-margin-sec-left"><i class="sys-icon arrows-alt-v"></i></div>
+                </div>
+            </bx_if:show_switcher_icon>
         </div>
     </a>
 </div>
-__profile_switcher__
+__switcher__

+ 22 - 14
template/scripts/BxBaseServiceProfiles.php

@@ -46,26 +46,28 @@ class BxBaseServiceProfiles extends BxDol
         if(!$oProfile)
             return '';
 
-        $oAcl = BxDolAcl::getInstance();
-        $aAcl = $oAcl->getMemberMembershipInfo($iProfileId);
-        $aAclInfo = $oAcl->getMembershipInfo($aAcl['id']);
-
         $oTemplate = BxDolTemplate::getInstance();
 
+        $sSwitcher = '';
         $aSwitcher = bx_srv('system', 'account_profile_switcher', array(false, null, '', true), 'TemplServiceProfiles');
-        $sSwitcher = $aSwitcher !== false ? BxTemplFunctions::getInstance()->transBox('bx-profile-switcher', $oTemplate->parseHtmlByName('profile_avatar_switcher.html', array(
-            'profile_switcher' => $aSwitcher['content'],
-            'bx_if:multiple_profiles_mode' => array(
-                'condition' => (int)getParam('sys_account_limit_profiles_number') != 1,
-                'content' => array(
-                    'url_switch_profile' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher')
+        if($aSwitcher !== false)
+            $sSwitcher = BxTemplFunctions::getInstance()->transBox('bx-profile-switcher', $oTemplate->parseHtmlByName('profile_avatar_switcher.html', array(
+                'profile_switcher' => $aSwitcher['content'],
+                'bx_if:multiple_profiles_mode' => array(
+                    'condition' => empty($aSwitcher['content']) || (int)getParam('sys_account_limit_profiles_number') != 1,
+                    'content' => array(
+                        'url_switch_profile' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher')
+                    )
                 )
-            )
-        )), true) : '';
+            )), true);
+        $bSwitcher = !empty($sSwitcher);
 
         $sDisplayName = $oProfile->getDisplayName();
 
-        list ($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_getIcon($aAclInfo['icon']);
+        $oAcl = BxDolAcl::getInstance();
+        $aAcl = $oAcl->getMemberMembershipInfo($iProfileId);
+        $aAclInfo = $oAcl->getMembershipInfo($aAcl['id']);
+        list($sIcon, $sIconUrl, $sIconA, $sIconHtml) = $this->_getIcon($aAclInfo['icon']);
 
         $aVars = array(
             'profile_id' => $oProfile->id(),
@@ -99,7 +101,13 @@ class BxBaseServiceProfiles extends BxDol
                 'condition' => (bool)$sIconHtml,
                 'content' => array('icon' => $sIconHtml),
             ),
-            'profile_switcher' => $sSwitcher
+            'switcher_url' => $bSwitcher ? 'javascript:void(0)' : $oProfile->getUrl(),
+            'switcher_onclick' => $bSwitcher ? "javascript:$('#bx-profile-switcher').dolPopup({});" : "",
+            'bx_if:show_switcher_icon' => array(
+                'condition' => $bSwitcher,
+                'content' => array()
+            ),
+            'switcher' => $sSwitcher
         );
 
         return $oTemplate->parseHtmlByName('profile_avatar.html', $aVars);