BxBasePageAccount.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. bx_import('BxTemplPage');
  10. /**
  11. * Account page.
  12. */
  13. class BxBasePageAccount extends BxTemplPage {
  14. protected $_aMapStatus2LangKey = array (
  15. BX_PROFILE_STATUS_PENDING => '_sys_txt_account_pending',
  16. BX_PROFILE_STATUS_SUSPENDED => '_sys_txt_account_suspended',
  17. );
  18. public function __construct($aObject, $oTemplate) {
  19. parent::__construct($aObject, $oTemplate);
  20. bx_import('BxDolProfile');
  21. $oProfile = BxDolProfile::getInstance();
  22. $aProfileInfo = $oProfile ? $oProfile->getInfo() : false;
  23. $this->addMarkers(array(
  24. 'account_id' => $aProfileInfo ? $aProfileInfo['account_id'] : 0,
  25. 'profile_id' => $aProfileInfo ? $aProfileInfo['id'] : 0,
  26. 'profile_type' => $aProfileInfo ? $aProfileInfo['type'] : 0,
  27. 'profile_content_id' => $aProfileInfo ? $aProfileInfo['content_id'] : 0,
  28. ));
  29. // set settings submenu
  30. bx_import('BxDolMenu');
  31. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  32. if ($oMenuSubmenu) {
  33. $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array (
  34. 'title' => _t('_sys_menu_item_title_account_settings'),
  35. 'link' => BX_DOL_URL_ROOT . 'member.php',
  36. 'icon' => '',
  37. ));
  38. }
  39. // display message if profile isn't active
  40. if ($oProfile) {
  41. $sStatus = $oProfile->getStatus();
  42. if (isset($this->_aMapStatus2LangKey[$sStatus])) {
  43. bx_import('BxDolInformer');
  44. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  45. if ($oInformer)
  46. $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
  47. }
  48. }
  49. // switch profile context
  50. if ($iSwitchToProfileId = (int)bx_get('switch_to_profile')) {
  51. bx_import('BxDolInformer');
  52. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  53. $oProfile = BxDolProfile::getInstance($iSwitchToProfileId);
  54. $sInformerMsg = '';
  55. if ($oProfile && $oProfile->getAccountId() == getLoggedId()) {
  56. bx_import('BxDolProfile');
  57. $oAccount = BxDolAccount::getInstance();
  58. if ($oAccount->updateProfileContext($iSwitchToProfileId))
  59. $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName());
  60. }
  61. if ($oInformer)
  62. $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ERROR);
  63. }
  64. }
  65. protected function _getPageCacheParams () {
  66. return getLoggedId(); // cache is different for every account
  67. }
  68. protected function _getBlockCode($aBlock) {
  69. $sAdd = '';
  70. if ('service' == $aBlock['type'] && $aBlock['content'])
  71. $sAdd = '<a id="top" class="bx-anchor-invisible">&nbsp;</a>';
  72. return $sAdd . parent::_getBlockCode ($aBlock);
  73. }
  74. }
  75. /** @} */