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