BxBaseMenuAccountNotifications.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. $sModule = BxDolProfile::getInstance()->getModule();
  33. $aResult = array();
  34. foreach($aItems as $aItem) {
  35. if(in_array($aItem['name'], $aDuplicates) && $aItem['module'] != $sModule)
  36. continue;
  37. $aResult[$aItem['name']] = $aItem;
  38. }
  39. return $aResult;
  40. }
  41. /**
  42. * Check if menu items is visible with extended checking for friends notifications
  43. * @param $a menu item array
  44. * @return boolean
  45. */
  46. protected function _isVisible ($a)
  47. {
  48. // default visible settings
  49. if (!BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']))
  50. return false;
  51. switch ($a['name']) {
  52. case 'studio':
  53. if (!isAdmin())
  54. return false;
  55. break;
  56. case 'cart':
  57. $oPayments = BxDolPayments::getInstance();
  58. if(!$oPayments->isActive())
  59. return false;
  60. break;
  61. case 'orders':
  62. $oPayments = BxDolPayments::getInstance();
  63. if(!$oPayments->isActive())
  64. return false;
  65. break;
  66. }
  67. return true;
  68. }
  69. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  70. {
  71. return array(
  72. 'addon' => $mixedAddon,
  73. 'addonf' => $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  74. 'content' => $mixedAddon
  75. ))
  76. );
  77. }
  78. }
  79. /** @} */