BxBasePageAccount.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /**
  10. * Account page.
  11. */
  12. class BxBasePageAccount extends BxTemplPage
  13. {
  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. {
  20. parent::__construct($aObject, $oTemplate);
  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. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  31. if ($oMenuSubmenu) {
  32. $oMenuSubmenu->setObjectSubmenu('sys_account_settings_submenu', array (
  33. 'title' => _t('_sys_menu_item_title_account_settings'),
  34. 'link' => BX_DOL_URL_ROOT . 'member.php',
  35. 'icon' => '',
  36. ));
  37. }
  38. // display message if profile isn't active
  39. if ($oProfile) {
  40. $sStatus = $oProfile->getStatus();
  41. if (isset($this->_aMapStatus2LangKey[$sStatus])) {
  42. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  43. if ($oInformer)
  44. $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
  45. }
  46. }
  47. // switch profile context
  48. if ($iSwitchToProfileId = (int)bx_get('switch_to_profile')) {
  49. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  50. $oProfile = BxDolProfile::getInstance($iSwitchToProfileId);
  51. $aProfile = $oProfile->getInfo();
  52. $sInformerMsg = '';
  53. if (BxDolService::call($aProfile['type'], 'act_as_profile')) {
  54. if ($oProfile && $oProfile->getAccountId() == getLoggedId()) {
  55. $oAccount = BxDolAccount::getInstance();
  56. if ($oAccount->updateProfileContext($iSwitchToProfileId))
  57. $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName());
  58. }
  59. if ($oInformer)
  60. $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ERROR);
  61. }
  62. }
  63. }
  64. protected function _isVisiblePage ($a)
  65. {
  66. if (!isLogged())
  67. return false;
  68. return parent::_isVisiblePage ($a);
  69. }
  70. protected function _addJsCss()
  71. {
  72. parent::_addJsCss();
  73. $this->_oTemplate->addCss('account.css');
  74. }
  75. protected function _getPageCacheParams ()
  76. {
  77. return getLoggedId(); // cache is different for every account
  78. }
  79. }
  80. /** @} */