BxBaseMenuAccountNotifications.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. // default visible settings
  52. if (!BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']))
  53. return false;
  54. switch ($a['name']) {
  55. case 'studio':
  56. if (!isAdmin())
  57. return false;
  58. break;
  59. case 'cart':
  60. $oPayments = BxDolPayments::getInstance();
  61. if(!$oPayments->isActive())
  62. return false;
  63. break;
  64. case 'orders':
  65. $oPayments = BxDolPayments::getInstance();
  66. if(!$oPayments->isActive())
  67. return false;
  68. break;
  69. }
  70. return true;
  71. }
  72. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  73. {
  74. return array(
  75. 'addon' => $mixedAddon,
  76. 'addonf' => $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  77. 'content' => $mixedAddon
  78. ))
  79. );
  80. }
  81. }
  82. /** @} */