BxReviewsModule.php 2.0 KB

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