BxBaseCmtsServices.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 UnaBaseView UNA 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. public function serviceManageTools($sType = 'common')
  47. {
  48. $oGrid = BxDolGrid::getObjectInstance('sys_cmts_administration');
  49. if(!$oGrid)
  50. return '';
  51. $oTemplate = BxDolTemplate::getInstance();
  52. $oTemplate->addJs(array('BxDolCmtsManageTools.js'));
  53. $oTemplate->addCss(array('cmts_manage_tools.css'));
  54. $oTemplate->addJsTranslation(array('_sys_grid_search'));
  55. return array(
  56. 'content' => $oGrid->getCode()
  57. );
  58. }
  59. }
  60. /** @} */