BxBaseMenuAccountNotifications.php 2.8 KB

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