BxBaseMenuAccountNotifications.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 BxBaseMenuAccountNotifications extends BxTemplMenu
  14. {
  15. public function __construct ($aObject, $oTemplate)
  16. {
  17. parent::__construct ($aObject, $oTemplate);
  18. $aMarkers = [
  19. 'studio_url' => BX_DOL_URL_STUDIO,
  20. ];
  21. if(($oProfile = BxDolProfile::getInstance()) !== false && ($sModule = $oProfile->getModule()) != 'system') {
  22. $oModule = BxDolModule::getInstance($sModule);
  23. if($oModule !== null && isset($oModule->_oConfig->CNF['URI_VIEW_ENTRY']))
  24. $aMarkers['own_profile_url'] = 'page.php?i=' . $oModule->_oConfig->CNF['URI_VIEW_ENTRY'];
  25. }
  26. $this->addMarkers($aMarkers);
  27. }
  28. protected function getMenuItemsRaw ()
  29. {
  30. return $this->getMenuItemsRawProfileRelated();
  31. }
  32. /**
  33. * Check if menu items is visible with extended checking for friends notifications
  34. * @param $a menu item array
  35. * @return boolean
  36. */
  37. protected function _isVisible ($a)
  38. {
  39. if(!parent::_isVisible($a))
  40. return false;
  41. switch ($a['name']) {
  42. case 'studio':
  43. if (!isAdmin())
  44. return false;
  45. break;
  46. case 'cart':
  47. $oPayments = BxDolPayments::getInstance();
  48. if(!$oPayments->isActive())
  49. return false;
  50. break;
  51. case 'orders':
  52. $oPayments = BxDolPayments::getInstance();
  53. if(!$oPayments->isActive())
  54. return false;
  55. break;
  56. }
  57. return true;
  58. }
  59. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  60. {
  61. $aAddon = parent::_getTmplVarsAddon($mixedAddon, $aMenuItem);
  62. $sAddonF = '';
  63. if(!empty($aAddon['addon']))
  64. $sAddonF = $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  65. 'content' => $aAddon['addon']
  66. ));
  67. return array(
  68. 'addon' => $aAddon['addon'],
  69. 'addonf' => $sAddonF
  70. );
  71. }
  72. }
  73. /** @} */