BxBaseCmtsServices.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentCore Trident Core
  7. * @{
  8. */
  9. /**
  10. * System services related to Comments.
  11. */
  12. class BxBaseCmtsServices extends BxDol
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceGetMenuItemAddonVote($sSystem, $iId, $iCmtId)
  19. {
  20. $oCmts = BxDolCmts::getObjectInstance($sSystem, $iId);
  21. $oVote = $oCmts->getVoteObject($iCmtId);
  22. if($oVote !== false)
  23. return $oVote->getCounter();
  24. return '';
  25. }
  26. public function serviceGetLiveUpdatesComments($sSystem, $iContentId, $iProfileId, $iCount = 0)
  27. {
  28. $oCmts = BxDolCmts::getObjectInstance($sSystem, $iContentId);
  29. if(!$oCmts || !$oCmts->isEnabled())
  30. return false;
  31. $iCountNew = $oCmts->getCommentsCount($iContentId, 0, BX_CMT_FILTER_OTHERS);
  32. if($iCountNew < $iCount)
  33. return false;
  34. return array(
  35. 'count' => $iCountNew, // required
  36. 'method' => $oCmts->getJsObjectName() . '.showLiveUpdate(oData)', // required
  37. 'data' => array(
  38. 'code' => $oCmts->getNotification($iCount, $iCountNew)
  39. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  40. );
  41. }
  42. }
  43. /** @} */