1
0

BxBaseModProfileMenuView.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * View profile entry menu
  13. */
  14. class BxBaseModProfileMenuView extends BxTemplMenuMoreAuto
  15. {
  16. protected $_sModule;
  17. protected $_oModule;
  18. protected $_iContentId;
  19. protected $_aContentInfo;
  20. protected $_oProfile;
  21. protected $_aProfileInfo;
  22. public function __construct($aObject, $oTemplate = false)
  23. {
  24. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  25. if(!$oTemplate)
  26. $oTemplate = $this->_oModule->_oTemplate;
  27. parent::__construct($aObject, $oTemplate);
  28. $CNF = $this->_oModule->_oConfig->CNF;
  29. $this->_aHtmlIds['main'] = 'bx-menu-main-submenu';
  30. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  31. if(empty($iContentId) && bx_get('profile_id') !== false)
  32. $iContentId = BxDolProfile::getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT))->getContentId();
  33. if(!empty($iContentId))
  34. $this->setContentId($iContentId);
  35. }
  36. public function setContentId($iContentId)
  37. {
  38. $this->_iContentId = (int)$iContentId;
  39. $this->_oProfile = BxDolProfile::getInstanceByContentAndType($this->_iContentId, $this->_sModule);
  40. if(!$this->_oProfile)
  41. return;
  42. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iContentId);
  43. $this->_aProfileInfo = $this->_oProfile->getInfo();
  44. $this->addMarkers($this->_aProfileInfo);
  45. $this->addMarkers(array(
  46. 'profile_id' => $this->_oProfile->id()
  47. ));
  48. }
  49. public function isMenuItemActive($a)
  50. {
  51. return parent::_isActive($a);
  52. }
  53. public function isMenuItemVisible($a)
  54. {
  55. return parent::_isVisible($a);
  56. }
  57. /**
  58. * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  59. * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  60. * @param $a menu item array
  61. * @return boolean
  62. */
  63. protected function _isVisible ($a)
  64. {
  65. if(!parent::_isVisible($a))
  66. return false;
  67. return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
  68. }
  69. }
  70. /** @} */