BxBasePageAccount.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // display message if profile isn't active
  30. if ($oProfile) {
  31. $sStatus = $oProfile->getStatus();
  32. if (isset($this->_aMapStatus2LangKey[$sStatus])) {
  33. bx_import('BxDolInformer');
  34. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  35. if ($oInformer)
  36. $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
  37. }
  38. }
  39. // switch profile context
  40. if ($iSwitchToProfileId = (int)bx_get('switch_to_profile')) {
  41. bx_import('BxDolInformer');
  42. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  43. $oProfile = BxDolProfile::getInstance($iSwitchToProfileId);
  44. $sInformerMsg = '';
  45. if ($oProfile && $oProfile->getAccountId() == getLoggedId()) {
  46. bx_import('BxDolProfile');
  47. $oAccount = BxDolAccount::getInstance();
  48. if ($oAccount->updateProfileContext($iSwitchToProfileId))
  49. $sInformerMsg = _t('_sys_txt_account_profile_context_changed_success', $oProfile->getDisplayName());
  50. }
  51. if ($oInformer)
  52. $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_Error occured'), $sInformerMsg ? BX_INFORMER_INFO : BX_INFORMER_ALERT);
  53. }
  54. }
  55. protected function _getPageCacheParams () {
  56. return getLoggedId(); // cache is different for every account
  57. }
  58. }
  59. /** @} */