BxBaseMenuAccountPopup.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Menu representation.
  11. * @see BxDolMenu
  12. */
  13. class BxBaseMenuAccountPopup extends BxTemplMenuCustom
  14. {
  15. protected $_oProfile;
  16. public function __construct ($aObject, $oTemplate)
  17. {
  18. parent::__construct ($aObject, $oTemplate);
  19. $this->_oProfile = BxDolProfile::getInstance();
  20. }
  21. protected function _getCode($sTmplName, $aTmplVars)
  22. {
  23. if(!$this->_oProfile)
  24. return '';
  25. return parent::_getCode($sTmplName, $aTmplVars);
  26. }
  27. protected function _getMenuItemProfileActive ($aItem)
  28. {
  29. return $this->_oTemplate->parseHtmlByName('map_profile_active.html', [
  30. 'profile_unit' => $this->_oProfile->getUnit()
  31. ]);
  32. }
  33. protected function _getMenuItemProfileNotifications ($aItem)
  34. {
  35. return BxDolMenu::getObjectInstance('sys_account_notifications')->getCode();
  36. }
  37. protected function _getMenuItemProfileSwitcher ($aItem)
  38. {
  39. $aResult = bx_srv('system', 'account_profile_switcher', [], 'TemplServiceProfiles');
  40. return $aResult['content'];
  41. }
  42. protected function _getMenuItemProfileCreate ($aItem)
  43. {
  44. if(!BxDolAccount::isAllowedCreateMultiple($this->_oProfile->id()))
  45. return '';
  46. return $this->_oTemplate->parseHtmlByName('map_profile_create.html', [
  47. 'url_switch_profile' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher')
  48. ]);
  49. }
  50. }
  51. /** @} */