BxBaseMenuAccountNotifications.php 3.0 KB

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