BxPostsModule.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. }
  20. /**
  21. * Entry post for Timeline module
  22. */
  23. public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
  24. {
  25. $CNF = &$this->_oConfig->CNF;
  26. $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
  27. if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
  28. return $aResult;
  29. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  30. if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
  31. $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
  32. return $aResult;
  33. }
  34. public function onPublished($iContentId)
  35. {
  36. $CNF = &$this->_oConfig->CNF;
  37. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  38. if(!$aContentInfo)
  39. return MsgBox(_t('_sys_txt_error_occured'));
  40. $aParams = array('object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]);
  41. if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
  42. $aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
  43. bx_alert($this->getName(), 'added', $iContentId, false, $aParams);
  44. return '';
  45. }
  46. }
  47. /** @} */