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

System enhancements:
- profile switcher
- .bx-clearfix CSS class was added

Alex Trofimov 13 лет назад
Родитель
Сommit
0fa3e8df52

+ 20 - 1
inc/classes/BxDolAccount.php

@@ -70,7 +70,7 @@ class BxDolAccount extends BxDol {
     public function isConfirmed($iAccountId = false) {
         if (!getParam('sys_email_confirmation')) // if email_confirmation procedure is disabled, always return true
             return true;
-        $a = $this->getInfo((int)$iAccountId);        
+        $a = $this->getInfo((int)$iAccountId);
         return $a['email_confirmed'] ? true : false;
     }
 
@@ -93,6 +93,25 @@ class BxDolAccount extends BxDol {
         return false;
     }    
 
+    public function updateProfileContext($iSwitchToProfileId, $iAccountId = false) {
+        $iId = (int)$iAccountId ? (int)$iAccountId : $this->_iAccountID;
+        $aInfo = $this->getInfo((int)$iId);
+        if (!$aInfo)
+            return false;
+
+        $ret = null;
+        bx_alert('account', 'before_switch_context', $iId, $iSwitchToProfileId, array('profile_id_current' => $aInfo['profile_id'], 'override_result' => &$ret));
+        if ($ret !== null)
+            return $ret;
+
+        if ($this->_oQuery->updateCurrentProfile($iId, $iSwitchToProfileId)) {
+            bx_alert('account', 'switch_context', $iId, $iSwitchToProfileId, array('profile_id_old' => $aInfo['profile_id']));
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * Send "confirmation" email
      */

+ 5 - 4
inc/classes/BxDolPermalinks.php

@@ -160,12 +160,13 @@ class BxDolPermalinks extends BxDolDb {
     /**
      * Make permalink from link.
      * @param $sLink - relative URL.
+     * @param $aParams - params to add to the url.
      * @return - relative permalinked URL if it was detected and permalinks are ON or unchanged URL otherwise.
      */
-    function permalink($sLink) {
+    function permalink($sLink, $aParams = array()) {
 
         $sRet = null;
-        bx_alert('system', 'permalink', 0, 0, array('link' => $sLink, 'return_data' => &$sRet));
+        bx_alert('system', 'permalink', 0, 0, array('link' => $sLink, 'params' => &$aParams, 'return_data' => &$sRet));
         if (null !== $sRet)
             return $sRet;
 
@@ -181,11 +182,11 @@ class BxDolPermalinks extends BxDolDb {
             if (!$this->_isEnabled($sKey))
                 return $sLink;
 
-            return $this->aLinksStandard[$sKey]['permalink'] . $sPage;
+            return bx_append_url_params($this->aLinksStandard[$sKey]['permalink'] . $sPage, $aParams);
 
         }
 
-        return $this->_isEnabled($sLink) ? $this->aLinksStandard[$sLink]['permalink'] : $sLink;
+        return bx_append_url_params($this->_isEnabled($sLink) ? $this->aLinksStandard[$sLink]['permalink'] : $sLink, $aParams);
     }
 
     /**

+ 45 - 3
inc/classes/BxDolProfile.php

@@ -43,18 +43,29 @@ class BxDolProfile extends BxDol {
     }
 
     /**
-     * Get singleton instance of the class
+     * Get singleton instance of the class by account id
      */
     public static function getInstanceAccountProfile($iAccountId = false) {
         $oQuery = BxDolProfileQuery::getInstance();
         $aProfile = $oQuery->getAccountProfile($iAccountId ? $iAccountId : getLoggedId());
         if (!$aProfile)
             return false;
-        return $this->getInstance($aProfile['id']);
+        return self::getInstance($aProfile['id']);
     }
 
     /**
-     * Get singleton instance of the class
+     * Get singleton instance of the class by account id, content id and type
+     */
+    public static function getInstanceByContentTypeAccount($iContent, $sType, $iAccountId = false) {
+        $oQuery = BxDolProfileQuery::getInstance();
+        $aProfile = $oQuery->getProfileByContentTypeAccount($iContent, $sType, $iAccountId ? $iAccountId : getLoggedId());
+        if (!$aProfile)
+            return false;
+        return self::getInstance($aProfile['id']);
+    }
+
+    /**
+     * Get singleton instance of the class by profile id
      */
     public static function getInstance($mixedProfileId = false) {
 
@@ -81,6 +92,14 @@ class BxDolProfile extends BxDol {
         return $this->_oQuery->getIdById($this->_iProfileID);
     }
 
+    /**
+     * Get account id associated with the profile
+     */
+    public function getAccountId() {
+        $aInfo = $this->getInfo();
+        return $aInfo['account_id'];
+    }
+
     /**
      * Check if profile status is active
      */
@@ -237,6 +256,29 @@ class BxDolProfile extends BxDol {
         return true;
     }
 
+
+    /**
+     * Display informer message if it is possible to switch to this profile
+     */
+    public function checkSwitchToProfile($oTemplate = null, $iViewerAccountId = false, $iViewerProfileId = false) {
+        if (false === $iViewerAccountId)
+            $iViewerAccountId = getLoggedId();
+        if (false === $iViewerProfileId)
+            $iViewerProfileId = bx_get_logged_profile_id();
+
+        if (!$iViewerAccountId || !$iViewerProfileId)
+            return;
+
+        if ($iViewerAccountId != $this->getAccountId() ||  $iViewerProfileId == $this->id())
+            return;
+
+        bx_import('BxDolInformer');
+        bx_import('BxDolPermalinks');
+        $oInformer = BxDolInformer::getInstance($oTemplate);
+        if ($oInformer)
+            $oInformer->add('sys-switch-profile-context', _t('_sys_txt_account_profile_context_change_suggestion', BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $this->id()))), BX_INFORMER_INFO);
+
+    }
 }
 
 /** @} */

+ 10 - 0
inc/classes/BxDolProfileQuery.php

@@ -60,6 +60,16 @@ class BxDolProfileQuery extends BxDolDb {
         return $this->getRow($sSql);
     }
 
+    /**
+     * Get profile by account id.
+     * @param string $iAccountId account id
+     * @return array if aprofile ids, key is profile id
+     */
+    public function getProfileByContentTypeAccount ($iContentId, $sType, $iAccountId) {
+        $sSql = $this->prepare("SELECT * FROM `sys_profiles` WHERE `account_id` = ? AND `type` = ? AND `content_id` = ?", $iAccountId, $sType, $iContentId);
+        return $this->getRow($sSql);
+    }
+
     /**
      * Insert account and content id association. Also if currect profile id is not defined - it updates current profile id in account.
      * @param $iAccountId account id

+ 3 - 0
inc/utils.inc.php

@@ -1336,6 +1336,9 @@ function bx_encode_url_params ($a, $aExcludeKeys = array (), $aOnlyKeys = false)
 }
 
 function bx_append_url_params ($sUrl, $mixedParams) {
+    if (!$mixedParams)
+        return $sUrl;
+
     $sParams = false == strpos($sUrl, '?') ? '?' : '&';
 
     if (is_array($mixedParams)) {

+ 9 - 4
install/sql/v70.sql

@@ -2863,10 +2863,11 @@ INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `tit
 
 -- account settings menu
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `order`) VALUES
-('sys_account_settings', 'system', 'account-settings-info', '_sys_menu_item_title_system_account_settings_info', '_sys_menu_item_title_account_settings_info', 'page.php?i=account-settings-info', '', '', 'info-sign', '', 2147483646, 1, 1),
-('sys_account_settings', 'system', 'account-settings-email', '_sys_menu_item_title_system_account_settings_email', '_sys_menu_item_title_account_settings_email', 'page.php?i=account-settings-email', '', '', 'envelope', '', 2147483646, 1, 2),
-('sys_account_settings', 'system', 'account-settings-password', '_sys_menu_item_title_system_account_settings_pwd', '_sys_menu_item_title_account_settings_pwd', 'page.php?i=account-settings-password', '', '', 'key', '', 2147483646, 1, 3),
-('sys_account_settings', 'system', 'account-settings-delete', '_sys_menu_item_title_system_account_settings_delete', '_sys_menu_item_title_account_settings_delete', 'page.php?i=account-settings-delete', '', '', 'remove', '', 2147483646, 1, 4);
+('sys_account_settings', 'system', 'account-settings-profile-context', '_sys_menu_item_title_system_account_profile_context', '_sys_menu_item_title_account_profile_context', 'page.php?i=account-profile-switcher', '', '', 'user', '', 2147483646, 1, 1),
+('sys_account_settings', 'system', 'account-settings-info', '_sys_menu_item_title_system_account_settings_info', '_sys_menu_item_title_account_settings_info', 'page.php?i=account-settings-info', '', '', 'info-sign', '', 2147483646, 1, 2),
+('sys_account_settings', 'system', 'account-settings-email', '_sys_menu_item_title_system_account_settings_email', '_sys_menu_item_title_account_settings_email', 'page.php?i=account-settings-email', '', '', 'envelope', '', 2147483646, 1, 3),
+('sys_account_settings', 'system', 'account-settings-password', '_sys_menu_item_title_system_account_settings_pwd', '_sys_menu_item_title_account_settings_pwd', 'page.php?i=account-settings-password', '', '', 'key', '', 2147483646, 1, 4),
+('sys_account_settings', 'system', 'account-settings-delete', '_sys_menu_item_title_system_account_settings_delete', '_sys_menu_item_title_account_settings_delete', 'page.php?i=account-settings-delete', '', '', 'remove', '', 2147483646, 1, 5);
 
 
 -- --------------------------------------------------------
@@ -3176,6 +3177,7 @@ INSERT INTO `sys_objects_page` (`object`, `uri`, `title_system`, `title`, `modul
 ('sys_account_settings_pwd', 'account-settings-password', '_sys_page_title_system_account_settings_pwd', '_sys_page_title_account_settings_pwd', 'system', 1, 2147483647, 1, 'page.php?i=account-settings-pwd', '', '', '', 0, 1, 0, 'BxTemplPageAccount', ''),
 ('sys_account_settings_info', 'account-settings-info', '_sys_page_title_system_account_settings_info', '_sys_page_title_account_settings_info', 'system', 1, 2147483647, 1, 'page.php?i=account-settings-info', '', '', '', 0, 1, 0, 'BxTemplPageAccount', ''),
 ('sys_account_settings_delete', 'account-settings-delete', '_sys_page_title_system_account_settings_delete', '_sys_page_title_account_settings_delete', 'system', 1, 2147483647, 1, 'page.php?i=account-settings-delete', '', '', '', 0, 1, 0, 'BxTemplPageAccount', ''),
+('sys_account_profile_switcher', 'account-profile-switcher', '_sys_page_title_system_account_profile_switcher', '_sys_page_title_account_profile_switcher', 'system', 1, 2147483647, 1, 'page.php?i=account-profile-switcher', '', '', '', 0, 1, 0, 'BxTemplPageAccount', ''),
 ('sys_unsubscribe_notifications', 'unsubscribe-notifications', '_sys_page_title_system_unsubscribe_notifications', '_sys_page_title_unsubscribe_notifications', 'system', 5, 2147483647, 1, 'page.php?i=unsubscribe-notifications', '', '', '', 0, 1, 0, '', ''),
 ('sys_unsubscribe_news', 'unsubscribe-news', '_sys_page_title_system_unsubscribe_news', '_sys_page_title_unsubscribe_news', 'system', 5, 2147483647, 1, 'page.php?i=unsubscribe-news', '', '', '', 0, 1, 0, '', '');
 
@@ -3274,6 +3276,9 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designb
 ('sys_account_settings_delete', 2, 'system', '_sys_page_block_title_account_settings_delete', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:28:"account_settings_del_account";s:6:"params";a:0:{}s:5:"class";s:19:"TemplServiceAccount";}', 0, 1, 1),
 ('sys_account_settings_delete', 1, 'system', '_sys_page_block_title_account_settings_menu', 11, 2147483647, 'menu', 'sys_account_settings', 0, 1, 1),
 
+('sys_account_profile_switcher', 1, 'system', '_sys_page_block_title_account_settings_menu', 11, 2147483647, 'menu', 'sys_account_settings', 1, 1, 1),
+('sys_account_profile_switcher', 2, 'system', '_sys_page_block_title_account_profile_switcher', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:24:"account_profile_switcher";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1),
+
 ('sys_unsubscribe_notifications', 1, 'system', '_sys_page_block_title_unsubscribe_notifications', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:25:"unsubscribe_notifications";s:6:"params";a:0:{}s:5:"class";s:19:"TemplServiceAccount";}', 0, 1, 1),
 
 ('sys_unsubscribe_news', 1, 'system', '_sys_page_block_title_unsubscribe_news', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:16:"unsubscribe_news";s:6:"params";a:0:{}s:5:"class";s:19:"TemplServiceAccount";}', 0, 1, 1);

+ 8 - 2
modules/boonex/english/data/langs/system.xml

@@ -3278,8 +3278,7 @@ More info about URI DNSBL: <br />
     <string name="_sys_menu_item_title_system_account_settings_info"><![CDATA[Info]]></string>
     <string name="_sys_menu_item_title_system_account_settings_email"><![CDATA[Email]]></string>
     <string name="_sys_menu_item_title_system_account_settings_pwd"><![CDATA[Password]]></string>
-    <string name="_sys_menu_item_title_system_account_settings_delete"><![CDATA[Delete Account]]></string>
-     
+    <string name="_sys_menu_item_title_system_account_settings_delete"><![CDATA[Delete Account]]></string>     
     <string name="_sys_menu_item_title_system_account"><![CDATA[Account]]></string>
     <string name="_sys_menu_item_title_system_create_profile"><![CDATA[Create Profile]]></string>
     <string name="_sys_menu_item_title_system_logout"><![CDATA[Log Out]]></string>
@@ -3287,6 +3286,7 @@ More info about URI DNSBL: <br />
     <string name="_sys_menu_item_title_system_account_settings_email"><![CDATA[Email]]></string>
     <string name="_sys_menu_item_title_system_account_settings_pwd"><![CDATA[Password]]></string>
     <string name="_sys_menu_item_title_system_account_settings_delete"><![CDATA[Delete Account]]></string>
+    <string name="_sys_menu_item_title_system_account_profile_context"><![CDATA[Profile Context]]></string>
 
     <string name="_sys_menu_item_title_home"><![CDATA[Home]]></string>
     <string name="_sys_menu_item_title_about"><![CDATA[About]]></string>    
@@ -3297,6 +3297,7 @@ More info about URI DNSBL: <br />
     <string name="_sys_menu_item_title_account_settings_pwd"><![CDATA[Password]]></string>
     <string name="_sys_menu_item_title_account_settings_info"><![CDATA[Info]]></string>
     <string name="_sys_menu_item_title_account_settings_delete"><![CDATA[Delete Account]]></string>
+    <string name="_sys_menu_item_title_account_profile_context"><![CDATA[Profile Context]]></string>
 
     <string name="_sys_menu_set_title_site"><![CDATA[Site]]></string>
     <string name="_sys_menu_set_title_footer"><![CDATA[Footer]]></string>
@@ -3354,6 +3355,8 @@ More info about URI DNSBL: <br />
     <string name="_sys_txt_account_pending"><![CDATA[Your account is pending approval, please wait until it is activated.]]></string>
     <string name="_sys_txt_account_suspended"><![CDATA[Your account is suspended.]]></string>
     <string name="_sys_txt_account_already_created"><![CDATA[Account is already created.]]></string>
+    <string name="_sys_txt_account_profile_context_changed_success"><![CDATA[Profile context has beed succesfully changed to: <b>{0}</b>]]></string>
+    <string name="_sys_txt_account_profile_context_change_suggestion"><![CDATA[This is your profile, you can <a href="{0}">change profile context</a> to this profile]]></string>
 
     <string name="_sys_txt_error_account_creation"><![CDATA[Account creation failed]]></string>
     <string name="_sys_txt_error_account_update"><![CDATA[Account update failed]]></string>
@@ -3460,6 +3463,8 @@ More info about URI DNSBL: <br />
     <string name="_sys_page_title_system_confirm_email"><![CDATA[Email Confirmation]]></string>
     <string name="_sys_page_title_system_unsubscribe_notifications"><![CDATA[Unsubscribe From Notifications]]></string>
     <string name="_sys_page_title_system_unsubscribe_news"><![CDATA[Unsubscribe From Newsletters]]></string>
+    <string name="_sys_page_title_system_account_profile_switcher"><![CDATA[Profile Context Switcher]]></string>
+    <string name="_sys_page_title_account_profile_switcher"><![CDATA[Profile Context Switcher]]></string>
 
     <string name="_sys_page_title_home"><![CDATA[{site_title} :: Homepage]]></string>
     <string name="_sys_page_title_about"><![CDATA[About]]></string>
@@ -3489,6 +3494,7 @@ More info about URI DNSBL: <br />
     <string name="_sys_page_block_title_existing_profiles"><![CDATA[Existing Profiles]]></string>
     <string name="_sys_page_block_title_create_profile"><![CDATA[Create New Profile]]></string>
     <string name="_sys_page_block_title_my_profiles"><![CDATA[My Profiles]]></string>
+    <string name="_sys_page_block_title_account_profile_switcher"><![CDATA[Profile Context Switcher]]></string>
 
 	<string name="_sys_acl_action_not_allowed"><![CDATA[Your current membership (<b>{2}</b>) doesn't allow you to <b>{1}</b>.]]></string>
 	<string name="_sys_acl_action_limit_reached"><![CDATA[You have reached your limit for now. Your current membership (<b>{2}</b>) allows you to {1} no more than {3} times]]></string>

+ 1 - 1
modules/boonex/persons/classes/BxPersonsModule.php

@@ -44,7 +44,7 @@ class BxPersonsModule extends BxDolModule {
         $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
         if (!$aContentInfo)
             return false;        
-        return $this->_oTemplate->unit($aContentInfo);
+        return $this->_oTemplate->thumb($aContentInfo);
     }
 
     public function serviceProfileName ($iContentId) {

+ 9 - 2
modules/boonex/persons/classes/BxPersonsPageProfile.php

@@ -36,8 +36,11 @@ class BxPersonsPageProfile extends BxTemplPage {
         if ($this->_aContentInfo)
             $this->addMarkers($this->_aContentInfo); // every profile field can be used as marker
 
+        bx_import('BxDolProfile');        
+        $oProfileAuthor = $this->_aContentInfo ? BxDolProfile::getInstance($this->_aContentInfo['author']) : false;
+
         // display message if profile isn't active
-        if ($this->_aContentInfo && bx_get_logged_profile_id() == $this->_aContentInfo['author']) { 
+        if ($oProfileAuthor && bx_get_logged_profile_id() == $oProfileAuthor->id()) { 
             $sStatus = $this->_aContentInfo['profile_status'];
             if (isset($this->_aMapStatus2LangKey[$sStatus])) {
                 bx_import('BxDolInformer');
@@ -45,8 +48,12 @@ class BxPersonsPageProfile extends BxTemplPage {
                 if ($oInformer)
                     $oInformer->add('bx-persons-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
             }
-        }        
+        }
 
+        // display message if it is possible to switch to this profile
+        $oProfile = $this->_aContentInfo ? BxDolProfile::getInstanceByContentTypeAccount($this->_aContentInfo['id'], 'bx_persons') : false;
+        if ($oProfile)
+            $oProfile->checkSwitchToProfile($this->_oTemplate);
     }
 
     public function getCode () {

+ 18 - 8
modules/boonex/persons/classes/BxPersonsTemplate.php

@@ -24,16 +24,13 @@ class BxPersonsTemplate extends BxDolTwigTemplate {
         $this->addCss ('main.css');
     }
 
+    /**
+     * Get profile unit
+     */
     function unit ($aData, $sTemplateName = 'unit.html') {
 
         // get picture thumb url
-        $sPictureThumb = '';
-        if ($aData[BxPersonsConfig::$FIELD_PICTURE]) {
-            bx_import('BxDolImageTranscoder');                    
-            $oImagesTranscoder = BxDolImageTranscoder::getObjectInstance(BxPersonsConfig::$OBJECT_IMAGES_TRANSCODER_THUMB);
-            if ($oImagesTranscoder)
-                $sPictureThumb = $oImagesTranscoder->getImageUrl($aData[BxPersonsConfig::$FIELD_PICTURE]);
-        }
+        $sPictureThumb = $this->thumb ($aData);
 
         // get person's url
         bx_import('BxDolPermalinks');
@@ -42,7 +39,7 @@ class BxPersonsTemplate extends BxDolTwigTemplate {
         // generate html
         $aVars = array (
             'id' => $aData['id'],
-            'thumb_url' => $sPictureThumb ? $sPictureThumb : $this->getImageUrl('no-picture-thumb.png'),
+            'thumb_url' => $sPictureThumb,
             'content_url' => $sUrl,
             'title' => $aData[BxPersonsConfig::$FIELD_NAME],
         );
@@ -51,6 +48,19 @@ class BxPersonsTemplate extends BxDolTwigTemplate {
 
     }
 
+    /**
+     * Get profile picture thumb url
+     */
+    function thumb ($aData, $bSubstituteNoImage = true) {
+        if ($aData[BxPersonsConfig::$FIELD_PICTURE]) {
+            bx_import('BxDolImageTranscoder');                    
+            $oImagesTranscoder = BxDolImageTranscoder::getObjectInstance(BxPersonsConfig::$OBJECT_IMAGES_TRANSCODER_THUMB);
+            if ($oImagesTranscoder)
+                return $oImagesTranscoder->getImageUrl($aData[BxPersonsConfig::$FIELD_PICTURE]);
+        }
+        return $bSubstituteNoImage ? $this->getImageUrl('no-picture-thumb.png') : '';
+    }
+
 }
 
 /** @} */ 

+ 17 - 0
template/css/account.css

@@ -0,0 +1,17 @@
+
+.sys-profile-switch-row-control,
+.sys-profile-switch-row-unit {
+    display:inline-block;
+    vertical-align:middle;
+}
+
+.sys-profile-switch-row-unit .bx-persons-unit {
+    margin-bottom:0;
+}
+
+.sys-profile-switch-row-control .sys-icon {
+    display:inline-block;`
+    width:32px;
+    height:32px;
+    font-size:32px;
+}

+ 9 - 0
template/css/common.css

@@ -35,6 +35,15 @@ blockquote {
     font-size:1px;
 }
 
+.bx-clearfix:before,
+.bx-clearfix:after {
+    content:"";
+    display:table;
+}
+.bx-clearfix:after {
+    clear:both;
+}
+
 /* --------------- design boxes */
 
 .bx-db-container {

+ 17 - 0
template/profile_switch_row.html

@@ -0,0 +1,17 @@
+<bx_repeat:row>
+
+<hr class="bx-def-hr-auto" />
+
+<div class="sys-profile-switch-row">
+    <div class="sys-profile-switch-row-control bx-def-margin-right">
+        <bx_if:active>
+            <i class="sys-icon check"></i>
+        </bx_if:active>
+        <bx_if:inactive>
+            <a href="__url_switch__"><i class="sys-icon check-empty"></i></a>
+        </bx_if:inactive>
+    </div>
+    <div class="sys-profile-switch-row-unit bx-clearfix">__unit__</div>
+</div>
+
+</bx_repeat:row>

+ 20 - 1
template/scripts/BxBasePageAccount.php

@@ -42,7 +42,26 @@ class BxBasePageAccount extends BxTemplPage {
                 if ($oInformer)
                     $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
             }
-        }        
+        }
+
+        // switch profile context
+        if ($iSwitchToProfileId = (int)bx_get('switch_to_profile')) {
+            bx_import('BxDolInformer');
+            $oInformer = BxDolInformer::getInstance($this->_oTemplate);
+            $oProfile = BxDolProfile::getInstance($iSwitchToProfileId);
+            $sInformerMsg = '';
+
+            if ($oProfile && $oProfile->getAccountId() == getLoggedId()) {
+                bx_import('BxDolProfile');
+                $oAccount = BxDolAccount::getInstance();
+                if ($oAccount->updateProfileContext($iSwitchToProfileId))
+                    $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName());
+            } 
+
+            if ($oInformer)
+                $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_Error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ALERT);
+        }
+
     }
 
     protected function _getPageCacheParams () {

+ 38 - 1
template/scripts/BxBaseServiceProfiles.php

@@ -28,7 +28,7 @@ class BxBaseServiceProfiles extends BxDol {
         $s = '';
         foreach ($aProfiles as $aProfile)
             if ($aProfile['type'] != 'system')
-            $s .= BxDolService::call($aProfile['type'], 'profile_thumb', array($aProfile['content_id']));
+                $s .= BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id']));
 
         if (!$s) 
             $s = MsgBox(_t('_sys_txt_empty'));
@@ -37,6 +37,43 @@ class BxBaseServiceProfiles extends BxDol {
 
     }
 
+    public function serviceAccountProfileSwitcher ($iAccountId = false) {
+        bx_import('BxDolProfileQuery');
+        $oProfilesQuery = BxDolProfileQuery::getInstance();
+
+        $aProfiles = $oProfilesQuery->getProfilesByAccount($iAccountId ? $iAccountId : getLoggedId());
+        if (!$aProfiles)
+            return false;
+        
+        $iLoggedPofileId = bx_get_logged_profile_id();
+        $aVars = array (
+            'bx_repeat:row' => array(),
+        );
+        foreach ($aProfiles as $aProfile) {
+            //if ($aProfile['type'] == 'system')
+            //    continue;
+            $aVars['bx_repeat:row'][] = array (
+                'bx_if:active' => array (
+                    'condition' => $iLoggedPofileId == $aProfile['id'],
+                    'content' => array('id' => $aProfile['id']), 
+                ),
+                'bx_if:inactive' => array (
+                    'condition' => $iLoggedPofileId != $aProfile['id'],
+                    'content' => array('id' => $aProfile['id'], 'url_switch' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $aProfile['id']))),
+                ),
+                'unit' => BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id'])),
+            );
+        }
+
+        if (!$aVars['bx_repeat:row']) 
+            return MsgBox(_t('_sys_txt_empty'));
+
+        bx_import('BxDolTemplate');
+        $oTemplate = BxDolTemplate::getInstance();
+        $oTemplate->addCss('account.css');
+        return $oTemplate->parseHtmlByName('profile_switch_row.html', $aVars);
+    }
+
 }
 
 /** @} */