Kaynağa Gözat

#104 - Integration with Comments.

AntonLV 12 yıl önce
ebeveyn
işleme
b2d5d8635c

+ 18 - 7
inc/classes/BxDolCmts.php

@@ -674,14 +674,10 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         if (!$this->isEnabled())
             return '';
 
-        $iCmtVParentId = bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT);
-        $iCmtStart = isset($_REQUEST['CmtStart']) ? bx_process_input($_REQUEST['CmtStart'], BX_DATA_INT) : -1;
-        $iCmtPerView = isset($_REQUEST['CmtPerView']) ? bx_process_input($_REQUEST['CmtPerView'], BX_DATA_INT) : -1;
-        $sCmtBrowse = isset($_REQUEST['CmtBrowse']) ? bx_process_input($_REQUEST['CmtBrowse'], BX_DATA_TEXT) : '';
-        $sCmtDisplay = isset($_REQUEST['CmtDisplay']) ? bx_process_input($_REQUEST['CmtDisplay'], BX_DATA_TEXT) : '';
-        $sCmtFilter = isset($_REQUEST['CmtFilter']) ? bx_process_input($_REQUEST['CmtFilter'], BX_DATA_TEXT) : '';
+        $aBp = $aDp = array();
+		$this->_getParams($aBp, $aDp);
 
-        return $this->getComments(array('vparent_id' => $iCmtVParentId, 'start' => $iCmtStart, 'per_view' => $iCmtPerView, 'type' => $sCmtBrowse, 'filter' => $sCmtFilter), array('type' => $sCmtDisplay, 'show_empty' => true));
+        return $this->getComments($aBp, $aDp);
     }
 
     public function actionSubmitPostForm()
@@ -816,6 +812,18 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         return BxDolForm::getObjectInstance($this->_sFormObject, $this->$sDisplayName);
     }
 
+    protected function _getParams(&$aBp, &$aDp)
+    {
+    	$aBp['vparent_id'] = isset($_REQUEST['CmtParent'])? bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT) : 0;
+    	$aBp['type'] = isset($_REQUEST['CmtBrowse']) ? bx_process_input($_REQUEST['CmtBrowse'], BX_DATA_TEXT) : '';
+    	$aBp['filter'] = isset($_REQUEST['CmtFilter']) ? bx_process_input($_REQUEST['CmtFilter'], BX_DATA_TEXT) : '';
+        $aBp['start'] = isset($_REQUEST['CmtStart']) ? bx_process_input($_REQUEST['CmtStart'], BX_DATA_INT) : -1;
+        $aBp['per_view'] = isset($_REQUEST['CmtPerView']) ? bx_process_input($_REQUEST['CmtPerView'], BX_DATA_INT) : -1;
+
+        $aDp['type'] = isset($_REQUEST['CmtDisplay']) ? bx_process_input($_REQUEST['CmtDisplay'], BX_DATA_TEXT) : '';
+        $aDp['blink'] = isset($_REQUEST['CmtBlink']) ? bx_process_input($_REQUEST['CmtBlink'], BX_DATA_TEXT) : '';
+    }
+
     protected function _prepareTextForEdit ($s)
     {
         if ($this->isNl2br())
@@ -855,6 +863,9 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         $aBp['order']['way'] = isset($aBp['order_way']) ? $aBp['order_way'] : $this->_aOrder['way'];
 
         $aDp['type'] = isset($aDp['type']) && !empty($aDp['type']) ? $aDp['type'] : $this->_sDisplayType;
+        $aDp['blink'] = isset($aDp['blink']) && !empty($aDp['blink']) ? $aDp['blink'] : array();
+        if(!is_array($aDp['blink']))
+        	$aDp['blink'] = explode(',', $aDp['blink']);
 
         switch($aDp['type']) {
             case BX_CMT_DISPLAY_FLAT:

+ 35 - 0
inc/classes/BxDolCmtsQuery.php

@@ -137,6 +137,41 @@ class BxDolCmtsQuery extends BxDolDb
         return $this->getAll($sQuery);
     }
 
+	function getCommentsBy($aParams = array())
+    {
+    	$aMethod = array('name' => 'getAll', 'params' => array(0 => 'query'));
+        $sSelectClause = $sJoinClause = $sWhereClause = $sOrderClause = $sLimitClause = "";
+
+        $sSelectClause = "
+        	`{$this->_sTable}`.`cmt_id`,
+            `{$this->_sTable}`.`cmt_parent_id`,
+            `{$this->_sTable}`.`cmt_vparent_id`,
+            `{$this->_sTable}`.`cmt_object_id`,
+            `{$this->_sTable}`.`cmt_author_id`,
+            `{$this->_sTable}`.`cmt_level`,
+            `{$this->_sTable}`.`cmt_text`,
+            `{$this->_sTable}`.`cmt_replies`,
+            `{$this->_sTable}`.`cmt_time`";
+
+        if(isset($aParams['object_id']))
+        	$sWhereClause .= $this->prepare(" AND `{$this->_sTable}`.`cmt_object_id` = ?" , (int)$aParams['object_id']);
+
+        switch($aParams['type']) {
+            case 'latest_ids':
+            	$aMethod['name'] = 'getColumn';
+				$sSelectClause = "`{$this->_sTable}`.`cmt_id`";
+                $sOrderClause = "ORDER BY `{$this->_sTable}`.`cmt_time` DESC";
+                $sLimitClause = isset($aParams['per_page']) ? "LIMIT " . $aParams['start'] . ", " . $aParams['per_page'] : "";
+                break;
+        }
+
+        $aMethod['params'][0] = "SELECT " . $sSelectClause . "
+            FROM `{$this->_sTable}` " . $sJoinClause . "
+            WHERE 1 " . $sWhereClause . " " . $sOrderClause . " " . $sLimitClause;
+
+		return call_user_func_array(array($this, $aMethod['name']), $aMethod['params']);
+    }
+
     function getComment ($iId, $iCmtId)
     {
         $sFields = $sJoin = "";

+ 93 - 35
inc/js/classes/BxDolCmts.js

@@ -6,10 +6,12 @@
 
 function BxDolCmts (options) {
     this._sObjName = undefined == options.sObjName ? 'oCmts' : options.sObjName;    // javascript object name, to run current object instance from onTimer
+    this._sActionsUrl = options.sRootUrl + 'cmts.php'; // actions url address
+
     this._sSystem = options.sSystem; // current comment system
     this._iAuthorId = options.iAuthorId; // this comment's author ID.
     this._iObjId = options.iObjId; // this object id comments
-    this._sActionsUrl = options.sRootUrl + 'cmts.php'; // actions url address
+    this._sBaseUrl = options.sBaseUrl; // base url to view comment's listing.
 
     this._sPostFormPosition = undefined == options.sPostFormPosition ? 'top' : options.sPostFormPosition;
     this._sDisplayType = undefined == options.sDisplayType ? 'threaded' : options.sDisplayType;
@@ -27,6 +29,9 @@ function BxDolCmts (options) {
     	var sFormId = $(this._sRootId + ' .cmt-post-reply form').attr('id');
     	this.cmtInitFormPost(sFormId);
     }
+
+    // blink (highlight) necessary comments
+    this._cmtsBlink($(this._sRootId));
 }
 
 /*--- Main layout functionality ---*/
@@ -162,6 +167,8 @@ BxDolCmts.prototype.cmtEdit = function(oLink, iCmtId) {
                 alert(oData.msg);
 
         	if(oData && oData.form != undefined && oData.form_id != undefined) {
+        		$(oLink).parents('.bx-popup-applied:first:visible').dolPopupHide();
+
         		$(sBodyId).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                     $(this).html(oData.form).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                     	$this.cmtInitFormEdit(oData.form_id);
@@ -194,6 +201,8 @@ BxDolCmts.prototype.cmtRemove = function(e, iCmtId) {
                 alert(oData.msg);
 
             if(oData && oData.id != undefined) {
+            	$(e).parents('.bx-popup-applied:first:visible').dolPopupHide();
+
             	$('#cmt' + oData.id).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                 	var oCounter = $(this).parent('ul.cmts').siblings('.cmt-cont').find('.cmt-actions a.cmt-comment-replies span');
                 	if(oCounter)
@@ -217,7 +226,14 @@ BxDolCmts.prototype.cmtLoad = function(oLink, iCmtParentId, iStart, iPerView)
 	else 
 		this._loading($(oLink).parents('ul.cmts:first'), true);
 
-	this._getCmts(null, iCmtParentId, iStart, iPerView, this._sDisplayType, this._sBrowseType, this._sBrowseFilter, function(sListId, sContent) {
+	this._getCmts(oLink, {
+		CmtParent: iCmtParentId,
+		CmtStart: iStart,
+		CmtPerView: iPerView,
+		CmtBrowse: this._sBrowseType,
+		CmtFilter: this._sBrowseFilter,
+		CmtDisplay: this._sDisplayType
+	}, function(sListId, sContent) {
 		if(bButton)
 			$this._loadingInButton(oLink, false);
 		else 
@@ -230,7 +246,12 @@ BxDolCmts.prototype.cmtLoad = function(oLink, iCmtParentId, iStart, iPerView)
 BxDolCmts.prototype.cmtChangeDisplay = function(oLink, sType)
 {
 	var $this = this;
-	this._getCmts(oLink, 0, undefined, undefined, sType, this._sBrowseType, this._sBrowseFilter, function(sListId, sContent) {
+	this._getCmts(oLink, {
+		CmtParent: 0,
+		CmtBrowse: this._sBrowseType,
+		CmtFilter: this._sBrowseFilter,
+		CmtDisplay: sType
+	}, function(sListId, sContent) {
 		$this._sDisplayType = sType;
 		$this._cmtsReplaceContent($(sListId), sContent);
 	});
@@ -239,7 +260,12 @@ BxDolCmts.prototype.cmtChangeDisplay = function(oLink, sType)
 BxDolCmts.prototype.cmtChangeBrowse = function(oLink, sType)
 {
 	var $this = this;
-	this._getCmts(oLink, 0, undefined, undefined, this._sDisplayType, sType, this._sBrowseFilter, function(sListId, sContent) {
+	this._getCmts(oLink, {
+		CmtParent: 0,
+		CmtBrowse: sType,
+		CmtFilter: this._sBrowseFilter,
+		CmtDisplay: this._sDisplayType
+	}, function(sListId, sContent) {
 		$this._sBrowseType = sType;
 		$this._cmtsReplaceContent($(sListId), sContent);
 	});
@@ -248,28 +274,29 @@ BxDolCmts.prototype.cmtChangeBrowse = function(oLink, sType)
 BxDolCmts.prototype.cmtChangeFilter = function(oLink, sType)
 {
 	var $this = this;
-	this._getCmts(oLink, 0, undefined, undefined, this._sDisplayType, $this._sBrowseType, sType, function(sListId, sContent) {
+	this._getCmts(oLink, {
+		CmtParent: 0,
+		CmtBrowse: this._sBrowseType,
+		CmtFilter: sType,
+		CmtDisplay: this._sDisplayType
+	}, function(sListId, sContent) {
 		$this._sBrowseFilter = sType;
 		$this._cmtsReplaceContent($(sListId), sContent);
 	});
 };
 BxDolCmts.prototype.showLiveUpdate = function(oData)
 {
+	/*
+	 * Note. oData.count_old and oData.count_new are also available and can be checked or used in notification popup.  
+	 */
 	if(!oData.code)
 		return;
 
-	var iCountNew = parseInt(oData.count_new);
-	var iCountOld = parseInt(oData.count_old);
-	if(iCountNew <= iCountOld)
-		return;
-
 	var oNotification = $(oData.code);
-	oNotification.find('.cmt-message span').html(iCountNew - iCountOld);
-
 	var sId = oNotification.attr('id');
 	$('#' + sId).remove();
 
-    $(oNotification).prependTo('body').dolPopup({
+    oNotification.prependTo('body').dolPopup({
     	position: 'fixed',
     	top: ($(window).height() - oNotification.height()) + 'px',
     	left: ($(window).width() - oNotification.width())/2 + 'px',
@@ -340,6 +367,24 @@ BxDolCmts.prototype.toggleManagePopup = function(oLink, iCmtId) {
 	});
 };
 
+BxDolCmts.prototype.goTo = function(oLink, sGoToId, sBlinkIds)
+{
+	$(oLink).parents('.bx-popup-applied:first:visible').dolPopupHide();
+
+	var $this = this;
+	this._getCmts(null, {
+		CmtParent: 0,
+		CmtBrowse: this._sBrowseType,
+		CmtFilter: this._sBrowseFilter,
+		CmtDisplay: this._sDisplayType,
+		CmtBlink: sBlinkIds
+	}, function(sListId, sContent) {
+		$this._cmtsReplaceContent($(sListId), sContent, function() {
+			location.hash = sGoToId;
+		});
+	});
+};
+
 BxDolCmts.prototype._getCmt = function (e, iCmtId)
 {
     var $this = this;
@@ -375,34 +420,24 @@ BxDolCmts.prototype._getCmt = function (e, iCmtId)
     );
 };
 
-BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, sDisplayType, sBrowseType, sBrowseFilter, onLoad)
+BxDolCmts.prototype._getCmts = function (oElement, oRequestParams, onLoad)
 {
     var $this = this;
     var oData = this._getDefaultActions();    
     oData['action'] = 'GetCmts';
-    oData['CmtParent'] = iCmtParentId;
-    if(parseInt(iStart) >= 0)
-        oData['CmtStart'] = iStart;
-    if(parseInt(iPerView) >= 0)
-        oData['CmtPerView'] = iPerView;
-    if(sDisplayType)
-        oData['CmtDisplay'] = sDisplayType;
-    if(sBrowseType)
-        oData['CmtBrowse'] = sBrowseType;
-    if(sBrowseFilter)
-        oData['CmtFilter'] = sBrowseFilter;
-
-    var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul:first';
+    oData = $.extend({}, oData, oRequestParams);
 
-    if(e)
-        this._loadingInBlock(e, true);
+    var sListId =  this._sRootId + ' #cmt' + oData['CmtParent'] + ' > ul:first';
+
+    if(oElement)
+        this._loadingInBlock(oElement, true);
 
     jQuery.post (
         this._sActionsUrl,
         oData,
         function(s) {
-        	if(e)
-        		$this._loadingInBlock(e, false);
+        	if(oElement)
+        		$this._loadingInBlock(oElement, false);
 
         	if(typeof onLoad == 'function')
     			onLoad(sListId, s);
@@ -449,19 +484,42 @@ BxDolCmts.prototype._cmtsPrepend = function(sIdTo, sContent)
 	$(sIdTo).prepend($(sContent).hide()).children(':hidden').bxTime().bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
 };
 
-BxDolCmts.prototype._cmtsReplace = function(oReplace, sContent)
+BxDolCmts.prototype._cmtsReplace = function(oReplace, sContent, onLoad)
 {
 	var $this = this;
 	$(oReplace).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
-		$(this).after($(sContent).hide()).nextAll(':hidden').bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+		$(this).after($(sContent).hide()).nextAll(':hidden').bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+			$this._cmtsBlink($(this));
+
+			if(typeof onLoad == 'function')
+    			onLoad();
+		});
 		$(this).remove();
 	});
 };
-BxDolCmts.prototype._cmtsReplaceContent = function(oParent, sContent)
+BxDolCmts.prototype._cmtsReplaceContent = function(oParent, sContent, onLoad)
 {
 	var $this = this;
 	$(oParent).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
-		$(this).html(sContent).bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+		$(this).html(sContent).bxTime().bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+			$this._cmtsBlink($(this));
+
+			if(typeof onLoad == 'function')
+    			onLoad();
+		});
+	});
+};
+
+BxDolCmts.prototype._cmtsBlink = function(oParent)
+{
+	var sBlinkClass = 'cmt-blink';
+
+	oParent.find('.' + sBlinkClass + '-plate:visible').animate({
+		opacity: 0
+	}, 
+	5000, 
+	function() {
+		oParent.find('.' + sBlinkClass).removeClass(sBlinkClass);
 	});
 };
 

+ 2 - 1
template/comment.html

@@ -1,6 +1,7 @@
 <li id="cmt__id__" class="__style_prefix____class__ bx-def-padding-top bx-def-margin-bottom">
+	<a id="__system____id__" class="__style_prefix__-anchor bx-anchor-invisible">&nbsp;</a>
 	<div class="__style_prefix__-cnt">
-		<a id="__system____id__" class="__style_prefix__-anchor bx-anchor-invisible">&nbsp;</a>
+		<div class="__style_prefix__-blink-plate"></div>
 		<div class="__style_prefix__-avatar bx-def-thumb bx-def-thumb-size">
 			<bx_if:show_icon>
 				<img class="bx-def-thumb bx-def-thumb-size" src="__author_icon__" />

+ 1 - 1
template/comments_notification.html

@@ -1,7 +1,7 @@
 <div id="__html_id__" class="__style_prefix__-notification bx-def-border bx-def-round-corners" style="display:none;">
 	<div class="__style_prefix__-cnt bx-def-padding-sec-topbottom">
 		<div class="__style_prefix__-message">
-			<a href="__url__">__message__</a>
+			<a href="__url__"<bx_if:show_onclick> onclick="__onclick__"</bx_if:show_onclick>>__message__</a>
 		</div>
 	</div>
 </div>

+ 15 - 1
template/css/cmts.css

@@ -38,6 +38,9 @@
     	line-height: 1.875rem;
     	overflow: hidden;
     }
+    li.cmt-blink div.cmt-blink-plate {
+		display: block;
+    }
     div.cmt-cnt {
 		position: relative;
     }
@@ -63,7 +66,7 @@
     	text-transform: uppercase;
     }    
 
-    /*--- Comment Author ---*/
+    /*--- Comment ---*/
 	div.cmt-avatar {
 		position: absolute;
 		top: 0px;
@@ -77,6 +80,17 @@
     div.cmt-info {
     	position: realtive;
 	}
+	div.cmt-blink-plate {
+		position: absolute;
+		display: none;
+		top: -10px;
+		left: -10px;
+		width: 100%;
+		height: 100%;
+		padding: 10px;
+    	background-color: rgb(255, 244, 213);
+    	background-color: rgba(255, 234, 193, 0.5);
+    }
 	div.cmt-head div.cmt-username,
 	div.cmt-head div.cmt-username,
 	div.cmt-head div.cmt-ago,

+ 36 - 7
template/scripts/BxBaseCmts.php

@@ -64,6 +64,7 @@ class BxBaseCmts extends BxDolCmts
             'sSystem' => $this->getSystemName(),
             'iAuthorId' => $this->_getAuthorId(),
             'iObjId' => $this->getId(),
+        	'sBaseUrl' => $this->getBaseUrl(),
             'sPostFormPosition' => $this->_aSystem['post_form_position'],
             'sBrowseType' => $this->_sBrowseType,
             'sDisplayType' => $this->_sDisplayType
@@ -78,11 +79,15 @@ class BxBaseCmts extends BxDolCmts
      */
     function getCommentsBlock($iParentId = 0, $iVParentId = 0, $bInDesignbox = true)
     {
-        $aBp = array('parent_id' => $iParentId, 'vparent_id' => $iVParentId);
-        $aDp = array('show_empty' => true);
+    	$aBp = $aDp = array();
+		$this->_getParams($aBp, $aDp);
+
+        $aBp['parent_id'] = $iParentId;
+        $aBp['vparent_id'] = $iVParentId;
+        $aDp['show_empty'] = true;
 
 		//add live update
-		$sServiceCall = BxDolService::getSerializedService('system', 'get_live_updates_comments', array($this->_sSystem, $this->_iId, $this->_getAuthorId()), 'TemplCmtsServices');
+		$sServiceCall = BxDolService::getSerializedService('system', 'get_live_updates_comments', array($this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'), 'TemplCmtsServices');
 
 		bx_import('BxDolLiveUpdates');
 		BxDolLiveUpdates::getInstance()->add($this->_sSystem . '_live_updates_cmts', 1, $sServiceCall);
@@ -122,7 +127,7 @@ class BxBaseCmts extends BxDolCmts
         $aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['filter'], $aBp['order'], $aBp['start'], $aBp['per_view']);
         if(empty($aCmts) || !is_array($aCmts))
             return isset($aDp['show_empty']) && $aDp['show_empty'] === true ? $this->_getEmpty() : '';
-            
+
         $sCmts = '';
         foreach($aCmts as $k => $aCmt)
             $sCmts .= $this->getComment($aCmt, $aBp, $aDp);
@@ -184,6 +189,9 @@ class BxBaseCmts extends BxDolCmts
         if($aCmt['cmt_author_id'] == $iUserId)
             $sClass .= ' cmt-mine';
 
+		if(!empty($aDp['blink']) && in_array($aCmt['cmt_id'], $aDp['blink']))
+			$sClass .= ' cmt-blink';
+
         $sActions = $this->_getActionsBox($aCmt, $aDp);
 
         $sText = $aCmt['cmt_text'];
@@ -344,14 +352,35 @@ class BxBaseCmts extends BxDolCmts
         return $this->_getFormEdit($aCmt);
     }
 
-    function getNotification($iCount = 0)
+    function getNotification($iCountOld = 0, $iCountNew = 0)
     {
+    	$sUrl = $this->getBaseUrl();
+    	$sOnClick = '';
+
+    	$iCount = (int)$iCountNew - (int)$iCountOld;
+    	if($iCount > 0) {
+    		$aCommentsIds = $this->_oQuery->getCommentsBy(array('type' => 'latest_ids', 'object_id' => $this->_iId, 'start' => '0', 'per_page' => $iCount));
+    		if(!empty($aCommentsIds) && is_array($aCommentsIds)) {
+    			$sBlink = implode(',', $aCommentsIds);
+    			$iCommentId = array_pop($aCommentsIds);
+
+				$sUrl = "javascript:void(0)";
+				$sOnClick = "javascript:" . $this->getJsObjectName() . ".goTo(this, '" . $this->_sSystem . $iCommentId . "', '" . $sBlink . "');";
+    		}
+    	}
+
     	bx_import('BxDolTemplate');
     	$sContent = BxDolTemplate::getInstance()->parseHtmlByName('comments_notification.html', array(
     		'html_id' => 'cmts-notification-' . $this->_sSystem . '-' + $this->_iId,
 			'style_prefix' => $this->_sStylePrefix,
-    		'url' => $this->getBaseUrl(),
-			'message' => _t('_cmt_txt_n_new_comments', $iCount)
+    		'url' => $sUrl,
+    		'bx_if:show_onclick' => array(
+    			'condition' => !empty($sOnClick),
+    			'content' => array(
+    				'onclick' => $sOnClick
+    			)
+    		),
+			'message' => _t('_cmt_txt_n_new_comments', (int)$iCountNew - (int)$iCountOld)
 		));
 
 		return $sContent;

+ 7 - 3
template/scripts/BxBaseCmtsServices.php

@@ -29,18 +29,22 @@ class BxBaseCmtsServices extends BxDol
         return '';
     }
 
-    public function serviceGetLiveUpdatesComments($sSystem, $iContentId, $iProfileId)
+    public function serviceGetLiveUpdatesComments($sSystem, $iContentId, $iProfileId, $iCount = 0)
     {
     	bx_import('BxDolCmts');
         $oCmts = BxDolCmts::getObjectInstance($sSystem, $iContentId);
         if(!$oCmts || !$oCmts->isEnabled())
             return false;
 
+		$iCountNew = $oCmts->getCommentsCount($iContentId, 0, BX_CMT_FILTER_OTHERS);
+		if($iCountNew < $iCount)
+			return false;
+
     	return array(
-    		'count' => $oCmts->getCommentsCount($iContentId, 0, BX_CMT_FILTER_OTHERS), // required
+    		'count' => $iCountNew, // required
     		'method' => $oCmts->getJsObjectName() . '.showLiveUpdate(oData)', // required
     		'data' => array(
-    			'code' => $oCmts->getNotification()
+    			'code' => $oCmts->getNotification($iCount, $iCountNew)
     		),  // optional, may have some additional data to be passed in JS method provided using 'method' param above.
     	);
     }