BxNotesMenuViewNote.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. public function getCode () {
  28. if (!bx_get_logged_profile_id())
  29. return false;
  30. return parent::getCode ();
  31. }
  32. /**
  33. * Check if menu items is visible.
  34. * @param $a menu item array
  35. * @return boolean
  36. */
  37. protected function _isVisible ($a) {
  38. $iProfileId = bx_get_logged_profile_id();
  39. // all links are visible for owner
  40. if ($this->_aContentInfo['author'] == $iProfileId)
  41. return true;
  42. $sFuncCheckAccess = false;
  43. switch ($a['name']) {
  44. case 'view-note':
  45. $sFuncCheckAccess = 'isAllowedView';
  46. break;
  47. case 'edit-note':
  48. $sFuncCheckAccess = 'isAllowedEdit';
  49. break;
  50. case 'delete-note':
  51. $sFuncCheckAccess = 'isAllowedDelete';
  52. break;
  53. }
  54. if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->$sFuncCheckAccess($this->_aContentInfo))
  55. return true;
  56. // default visible settings
  57. bx_import('BxDolAcl');
  58. return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
  59. }
  60. protected function _addJsCss() {
  61. parent::_addJsCss();
  62. $this->_oModule->_oTemplate->addJs('forms.js');
  63. }
  64. }
  65. /** @} */