1
0

BxBaseModGeneralMenuView.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseGeneral Base classes for modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxTemplMenu');
  12. bx_import('BxDolModule');
  13. /**
  14. * View entry menu
  15. */
  16. class BxBaseModGeneralMenuView extends BxTemplMenu
  17. {
  18. protected $MODULE;
  19. protected $_oModule;
  20. public function __construct($aObject, $oTemplate = false)
  21. {
  22. parent::__construct($aObject, $oTemplate);
  23. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  24. }
  25. /**
  26. * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  27. * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  28. * @param $a menu item array
  29. * @return boolean
  30. */
  31. protected function _isVisible ($a)
  32. {
  33. // default visible settings
  34. bx_import('BxDolAcl');
  35. if (!BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']))
  36. return false;
  37. $CNF = $this->_oModule->_oConfig->CNF;
  38. // get custom function name to check menu item visibility
  39. $sFuncCheckAccess = false;
  40. if (isset($CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']]))
  41. $sFuncCheckAccess = $CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']];
  42. // check custom visibility settings defined in module config class
  43. if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED !== call_user_func_array(array($this->_oModule, $sFuncCheckAccess), isset($this->_aContentInfo) ? array(&$this->_aContentInfo) : array()))
  44. return false;
  45. return true;
  46. }
  47. }
  48. /** @} */