BxDirModule.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Directory Directory
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Directory module
  13. */
  14. class BxDirModule extends BxBaseModTextModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. $CNF = &$this->_oConfig->CNF;
  20. $this->_aSearchableNamesExcept = array_merge($this->_aSearchableNamesExcept, array(
  21. $CNF['FIELD_PUBLISHED']
  22. ));
  23. }
  24. /**
  25. * Entry post for Timeline module
  26. */
  27. public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
  28. {
  29. $CNF = &$this->_oConfig->CNF;
  30. $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  31. if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
  32. return $aResult;
  33. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  34. if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
  35. $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
  36. return $aResult;
  37. }
  38. public function onPublished($iContentId)
  39. {
  40. $CNF = &$this->_oConfig->CNF;
  41. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  42. if(!$aContentInfo)
  43. return MsgBox(_t('_sys_txt_error_occured'));
  44. $aParams = array('object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]);
  45. if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  46. $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
  47. bx_alert($this->getName(), 'added', $iContentId, false, $aParams);
  48. return '';
  49. }
  50. public function serviceCheckAllowedCommentsPost($iContentId, $sObjectComments)
  51. {
  52. $CNF = &$this->_oConfig->CNF;
  53. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  54. if ($aContentInfo[$CNF['FIELD_DISABLE_COMMENTS']] == 1)
  55. return false;
  56. return parent::serviceCheckAllowedCommentsPost($iContentId, $sObjectComments);
  57. }
  58. public function serviceCheckAllowedCommentsView($iContentId, $sObjectComments)
  59. {
  60. $CNF = &$this->_oConfig->CNF;
  61. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  62. if ($aContentInfo[$CNF['FIELD_DISABLE_COMMENTS']] == 1)
  63. return false;
  64. return parent::serviceCheckAllowedCommentsView($iContentId, $sObjectComments);
  65. }
  66. }
  67. /** @} */