BxBasePageAccount.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 TridentCore Trident Core
  7. * @{
  8. */
  9. bx_import('BxTemplPage');
  10. /**
  11. * Account page.
  12. */
  13. class BxBasePageAccount extends BxTemplPage
  14. {
  15. protected $_aMapStatus2LangKey = array (
  16. BX_PROFILE_STATUS_PENDING => '_sys_txt_account_pending',
  17. BX_PROFILE_STATUS_SUSPENDED => '_sys_txt_account_suspended',
  18. );
  19. public function __construct($aObject, $oTemplate)
  20. {
  21. parent::__construct($aObject, $oTemplate);
  22. bx_import('BxDolProfile');
  23. $oProfile = BxDolProfile::getInstance();
  24. $aProfileInfo = $oProfile ? $oProfile->getInfo() : false;
  25. $this->addMarkers(array(
  26. 'account_id' => $aProfileInfo ? $aProfileInfo['account_id'] : 0,
  27. 'profile_id' => $aProfileInfo ? $aProfileInfo['id'] : 0,
  28. 'profile_type' => $aProfileInfo ? $aProfileInfo['type'] : 0,
  29. 'profile_content_id' => $aProfileInfo ? $aProfileInfo['content_id'] : 0,
  30. ));
  31. // set settings submenu
  32. bx_import('BxDolMenu');
  33. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  34. if ($oMenuSubmenu) {
  35. $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array (
  36. 'title' => _t('_sys_menu_item_title_account_settings'),
  37. 'link' => BX_DOL_URL_ROOT . 'member.php',
  38. 'icon' => '',
  39. ));
  40. }
  41. // display message if profile isn't active
  42. if ($oProfile) {
  43. $sStatus = $oProfile->getStatus();
  44. if (isset($this->_aMapStatus2LangKey[$sStatus])) {
  45. bx_import('BxDolInformer');
  46. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  47. if ($oInformer)
  48. $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
  49. }
  50. }
  51. // switch profile context
  52. if ($iSwitchToProfileId = (int)bx_get('switch_to_profile')) {
  53. bx_import('BxDolInformer');
  54. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  55. $oProfile = BxDolProfile::getInstance($iSwitchToProfileId);
  56. $sInformerMsg = '';
  57. if ($oProfile && $oProfile->getAccountId() == getLoggedId()) {
  58. bx_import('BxDolProfile');
  59. $oAccount = BxDolAccount::getInstance();
  60. if ($oAccount->updateProfileContext($iSwitchToProfileId))
  61. $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName());
  62. }
  63. if ($oInformer)
  64. $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ERROR);
  65. }
  66. }
  67. protected function _getPageCacheParams ()
  68. {
  69. return getLoggedId(); // cache is different for every account
  70. }
  71. }
  72. /** @} */