BxPostsModule.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ));
  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 serviceCheckAllowedCommentsPost($iContentId, $sObjectComments)
  39. {
  40. $CNF = &$this->_oConfig->CNF;
  41. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  42. if ($aContentInfo[$CNF['FIELD_DISABLE_COMMENTS']] == 1)
  43. return false;
  44. return parent::serviceCheckAllowedCommentsPost($iContentId, $sObjectComments);
  45. }
  46. public function serviceCheckAllowedCommentsView($iContentId, $sObjectComments)
  47. {
  48. $CNF = &$this->_oConfig->CNF;
  49. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  50. if ($aContentInfo[$CNF['FIELD_DISABLE_COMMENTS']] == 1)
  51. return false;
  52. return parent::serviceCheckAllowedCommentsView($iContentId, $sObjectComments);
  53. }
  54. }
  55. /** @} */