BxPostsModule.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 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. }
  51. /** @} */