1
0

BxBaseMenuAccountNotifications.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. $this->addMarkers(array(
  19. 'studio_url' => BX_DOL_URL_STUDIO
  20. ));
  21. }
  22. protected function getMenuItemsRaw ()
  23. {
  24. $aItems = $this->_oQuery->getMenuItemsBy(array(
  25. 'type' => 'set_name',
  26. 'set_name' => $this->_aObject['set_name']
  27. ));
  28. $aDuplicates = $this->_oQuery->getMenuItemsBy(array(
  29. 'type' => 'set_name_duplicates',
  30. 'set_name' => $this->_aObject['set_name']
  31. ));
  32. $oProfile = BxDolProfile::getInstance();
  33. if(!$oProfile)
  34. return array();
  35. $sModule = $oProfile->getModule();
  36. $aResult = array();
  37. foreach($aItems as $aItem) {
  38. if(in_array($aItem['name'], $aDuplicates) && $aItem['module'] != $sModule)
  39. continue;
  40. $aResult[$aItem['name']] = $aItem;
  41. }
  42. return $aResult;
  43. }
  44. /**
  45. * Check if menu items is visible with extended checking for friends notifications
  46. * @param $a menu item array
  47. * @return boolean
  48. */
  49. protected function _isVisible ($a)
  50. {
  51. if(!parent::_isVisible($a))
  52. return false;
  53. switch ($a['name']) {
  54. case 'studio':
  55. if (!isAdmin())
  56. return false;
  57. break;
  58. case 'cart':
  59. $oPayments = BxDolPayments::getInstance();
  60. if(!$oPayments->isActive())
  61. return false;
  62. break;
  63. case 'orders':
  64. $oPayments = BxDolPayments::getInstance();
  65. if(!$oPayments->isActive())
  66. return false;
  67. break;
  68. }
  69. return true;
  70. }
  71. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  72. {
  73. $aAddon = parent::_getTmplVarsAddon($mixedAddon, $aMenuItem);
  74. $sAddonF = '';
  75. if(!empty($aAddon['addon']))
  76. $sAddonF = $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  77. 'content' => $aAddon['addon']
  78. ));
  79. return array(
  80. 'addon' => $aAddon['addon'],
  81. 'addonf' => $sAddonF
  82. );
  83. }
  84. }
  85. /** @} */