BxNotesPageNote.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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('BxTemplPage');
  12. bx_import('BxDolModule');
  13. bx_import('BxDolMenu');
  14. /**
  15. * Note create/edit pages.
  16. */
  17. class BxNotesPageNote extends BxTemplPage {
  18. protected $_oModule;
  19. protected $_aContentInfo = false;
  20. protected $_aMapStatus2LangKey = array (
  21. BX_PROFILE_STATUS_PENDING => '_bx_notes_txt_status_pending',
  22. );
  23. public function __construct($aObject, $oTemplate = false) {
  24. parent::__construct($aObject, $oTemplate);
  25. $this->_oModule = BxDolModule::getInstance('bx_notes');
  26. // select view note submenu
  27. $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
  28. $oMenuSumbemu->setObjectSubmenu('bx_notes_view_submenu', 'notes-home');
  29. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  30. if ($iContentId)
  31. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
  32. if ($this->_aContentInfo)
  33. $this->addMarkers($this->_aContentInfo); // every field can be used as marker
  34. /* TODO: status
  35. // display message if profile isn't active
  36. if ($this->_aContentInfo && bx_get_logged_profile_id() == $this->_aContentInfo['author']) {
  37. $sStatus = $this->_aContentInfo['status'];
  38. if (isset($this->_aMapStatus2LangKey[$sStatus])) {
  39. bx_import('BxDolInformer');
  40. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  41. if ($oInformer)
  42. $oInformer->add('bx-notes-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
  43. }
  44. }
  45. */
  46. }
  47. public function getCode () {
  48. if (!$this->_aContentInfo) { // if note is not found - display standard "404 page not found" page
  49. $this->_oTemplate->displayPageNotFound();
  50. exit;
  51. }
  52. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->isAllowedView($this->_aContentInfo))) {
  53. $this->_oTemplate->displayAccessDenied($sMsg);
  54. exit;
  55. }
  56. $this->_oModule->isAllowedView($this->_aContentInfo, true);
  57. return parent::getCode ();
  58. }
  59. protected function _getPageCacheParams () {
  60. return $this->_aContentInfo[BxNotesConfig::$FIELD_ID]; // cache is different for every note
  61. }
  62. }
  63. /** @} */