BxBaseCmtsServices.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 UnaCoreBaseRepresentation UNA Core Base Representation Classes
  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. $sKey = $oCmts->getNotificationId();
  32. bx_import('BxDolSession');
  33. if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
  34. return false;
  35. $iCountNew = $oCmts->getCommentsCount($iContentId, -1, BX_CMT_FILTER_OTHERS);
  36. if($iCountNew <= $iCount)
  37. return false;
  38. return array(
  39. 'count' => $iCountNew, // required
  40. 'method' => $oCmts->getJsObjectName() . '.showLiveUpdate(oData)', // required
  41. 'data' => array(
  42. 'code' => $oCmts->getNotification($iCount, $iCountNew)
  43. ), // optional, may have some additional data to be passed in JS method provided using 'method' param above.
  44. );
  45. }
  46. }
  47. /** @} */