1
0

BxBaseModProfileMenuView.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  30. if(empty($iContentId) && bx_get('profile_id') !== false)
  31. $iContentId = BxDolProfile::getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT))->getContentId();
  32. if(!empty($iContentId))
  33. $this->setContentId($iContentId);
  34. }
  35. public function setContentId($iContentId)
  36. {
  37. $this->_iContentId = (int)$iContentId;
  38. $this->_oProfile = BxDolProfile::getInstanceByContentAndType($this->_iContentId, $this->_sModule);
  39. if(!$this->_oProfile)
  40. return;
  41. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iContentId);
  42. $this->_aProfileInfo = $this->_oProfile->getInfo();
  43. $this->addMarkers($this->_aProfileInfo);
  44. $this->addMarkers(array(
  45. 'profile_id' => $this->_oProfile->id()
  46. ));
  47. }
  48. /**
  49. * Check if menu items is visible with extended checking linked to "allow*" method of particular module
  50. * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
  51. * @param $a menu item array
  52. * @return boolean
  53. */
  54. protected function _isVisible ($a)
  55. {
  56. return $this->_oModule->isMenuItemVisible($this->_sObject, $a, $this->_aContentInfo);
  57. }
  58. }
  59. /** @} */