1
0

BxBaseModProfileMenuView.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /**
  50. * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  51. * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  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. return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
  60. }
  61. }
  62. /** @} */