BxNotesMenuViewNote.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 Notes Notes
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxTemplMenu');
  12. /**
  13. * 'View Note' menu.
  14. */
  15. class BxNotesMenuViewNote extends BxTemplMenu {
  16. protected $_aContentInfo;
  17. protected $_oModule;
  18. public function __construct($aObject, $oTemplate = false) {
  19. parent::__construct($aObject, $oTemplate);
  20. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  21. bx_import('BxDolModule');
  22. $this->_oModule = BxDolModule::getInstance('bx_notes');
  23. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
  24. if ($this->_aContentInfo)
  25. $this->addMarkers(array('content_id' => $this->_aContentInfo['id']));
  26. }
  27. /**
  28. * Check if menu items is visible.
  29. * @param $a menu item array
  30. * @return boolean
  31. */
  32. protected function _isVisible ($a) {
  33. $iProfileId = bx_get_logged_profile_id();
  34. // all links are visible for owner
  35. if ($this->_aContentInfo['author'] == $iProfileId)
  36. return true;
  37. // all links are visible for admin/moderator
  38. $aCheck = checkActionModule($iProfileId, 'edit any note', 'bx_notes');
  39. if ($aCheck[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)
  40. return true;
  41. // default visible settings
  42. bx_import('BxDolAcl');
  43. return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
  44. }
  45. protected function _addJsCss() {
  46. parent::_addJsCss();
  47. $this->_oModule->_oTemplate->addJs('forms.js');
  48. }
  49. }
  50. /** @} */