BxNotesMenuViewNote.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. $sFuncCheckAccess = false;
  35. switch ($a['name']) {
  36. case 'view-note':
  37. if ($this->_aContentInfo[BxNotesConfig::$FIELD_AUTHOR] != $iProfileId && 'bx_notes_view' == $this->_sObject) // TODO: this is temporary - to hide single view item from menu
  38. return false;
  39. $sFuncCheckAccess = 'isAllowedView';
  40. break;
  41. case 'edit-note':
  42. $sFuncCheckAccess = 'isAllowedEdit';
  43. break;
  44. case 'delete-note':
  45. $sFuncCheckAccess = 'isAllowedDelete';
  46. break;
  47. }
  48. if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->$sFuncCheckAccess($this->_aContentInfo))
  49. return true;
  50. // default visible settings
  51. bx_import('BxDolAcl');
  52. return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
  53. }
  54. protected function _addJsCss() {
  55. parent::_addJsCss();
  56. $this->_oModule->_oTemplate->addJs('forms.js');
  57. }
  58. }
  59. /** @} */