BxPostsModule.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 Posts Posts
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Posts module
  13. */
  14. class BxPostsModule 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. $CNF['FIELD_ANONYMOUS'],
  23. $CNF['FIELD_ALLOW_COMMENTS']
  24. ));
  25. }
  26. /**
  27. * Entry post for Timeline module
  28. */
  29. public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
  30. {
  31. $CNF = &$this->_oConfig->CNF;
  32. $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  33. if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
  34. return $aResult;
  35. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  36. if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
  37. $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
  38. return $aResult;
  39. }
  40. public function serviceCheckAllowedCommentsPost($iContentId, $sObjectComments)
  41. {
  42. $CNF = &$this->_oConfig->CNF;
  43. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  44. if ($aContentInfo && $aContentInfo[$CNF['FIELD_ALLOW_COMMENTS']] == 0)
  45. return false;
  46. return parent::serviceCheckAllowedCommentsPost($iContentId, $sObjectComments);
  47. }
  48. public function serviceCheckAllowedCommentsView($iContentId, $sObjectComments)
  49. {
  50. $CNF = &$this->_oConfig->CNF;
  51. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  52. if ($aContentInfo && $aContentInfo[$CNF['FIELD_ALLOW_COMMENTS']] == 0)
  53. return false;
  54. return parent::serviceCheckAllowedCommentsView($iContentId, $sObjectComments);
  55. }
  56. }
  57. /** @} */