BxBaseMenuAccountNotifications.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. return array(
  74. 'addon' => $mixedAddon,
  75. 'addonf' => $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  76. 'content' => $mixedAddon
  77. ))
  78. );
  79. }
  80. }
  81. /** @} */