BxBaseMenuAccountPopup.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 $this->_oTemplate->parseHtmlByName('map_profile_notifications.html', [
  36. 'menu' => BxDolMenu::getObjectInstance('sys_account_notifications')->getCode()
  37. ]);
  38. }
  39. protected function _getMenuItemProfileSwitcher ($aItem)
  40. {
  41. $aResult = bx_srv('system', 'account_profile_switcher', [], 'TemplServiceProfiles');
  42. return $aResult['content'];
  43. }
  44. protected function _getMenuItemProfileCreate ($aItem)
  45. {
  46. if(!BxDolAccount::isAllowedCreateMultiple($this->_oProfile->id()))
  47. return '';
  48. return $this->_oTemplate->parseHtmlByName('map_profile_create.html', [
  49. 'url_switch_profile' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher')
  50. ]);
  51. }
  52. }
  53. /** @} */