BxNotesMenuViewNote.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // don't show current item, also this will solve problem when only one view note item is visible
  35. if ('bx_notes_view' == $this->_sObject && $this->_isSelected($a))
  36. return false;
  37. $sFuncCheckAccess = false;
  38. switch ($a['name']) {
  39. case 'view-note':
  40. $sFuncCheckAccess = 'isAllowedView';
  41. break;
  42. case 'edit-note':
  43. $sFuncCheckAccess = 'isAllowedEdit';
  44. break;
  45. case 'delete-note':
  46. $sFuncCheckAccess = 'isAllowedDelete';
  47. break;
  48. }
  49. if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->$sFuncCheckAccess($this->_aContentInfo))
  50. return true;
  51. // default visible settings
  52. bx_import('BxDolAcl');
  53. return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
  54. }
  55. protected function _addJsCss() {
  56. parent::_addJsCss();
  57. $this->_oModule->_oTemplate->addJs('forms.js');
  58. }
  59. }
  60. /** @} */