Skip to content

Commit

Permalink
Ticket #463 - Related core changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Oct 19, 2016
1 parent 5a56bce commit b85333e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
38 changes: 38 additions & 0 deletions inc/classes/BxDolCmts.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,44 @@ public function actionPauseLiveUpdate()
BxDolSession::getInstance()->setValue($sKey, 1);
}

public function onPostAfter($iId)
{
$iObjectId = (int)$this->getId();
$iObjectAuthorId = $this->getObjectAuthorId($iObjectId);

$aComment = $this->_oQuery->getCommentSimple($iObjectId, $iId);
if(empty($aComment) || !is_array($aComment))
return false;

$iAuthorId = (int)$aComment['cmt_author_id'];
$oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $iObjectId, $iAuthorId, array('comment_id' => $iId, 'comment_text' => $aComment['cmt_text'], 'comment_author_id' => $iAuthorId, 'object_author_id' => $iObjectAuthorId));
$oZ->alert();

$oZ = new BxDolAlerts('comment', 'added', $iId, $iAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iObjectId, 'object_author_id' => $iObjectAuthorId, 'comment_text' => $aComment['cmt_text']));
$oZ->alert();

return true;
}

public function onEditAfter($iId)
{
$iObjectId = (int)$this->getId();
$iObjectAuthorId = $this->getObjectAuthorId($iObjectId);

$aComment = $this->_oQuery->getCommentSimple($iObjectId, $iId);
if(empty($aComment) || !is_array($aComment))
return false;

$iAuthorId = (int)$aComment['cmt_author_id'];
$oZ = new BxDolAlerts($this->_sSystem, 'commentUpdated', $iObjectId, $iAuthorId, array('comment_id' => $iId, 'comment_author_id' => $iAuthorId, 'object_author_id' => $iObjectAuthorId));
$oZ->alert();

$oZ = new BxDolAlerts('comment', 'edited', $iId, $iAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iObjectId, 'object_author_id' => $iObjectAuthorId));
$oZ->alert();

return true;
}

/**
* Internal functions
*/
Expand Down
19 changes: 3 additions & 16 deletions template/scripts/BxBaseCmts.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,6 @@ protected function _getFormPost($iCmtParentId = 0)
$oForm->initChecker();

if($oForm->isSubmittedAndValid()) {
$iCmtObjectId = (int)$this->getId();
$iCmtObjectAuthorId = $this->getObjectAuthorId($iCmtObjectId);
$iCmtAuthorId = $this->_getAuthorId();
$iCmtParentId = $oForm->getCleanValue('cmt_parent_id');
$sCmtText = $oForm->getCleanValue('cmt_text');
Expand Down Expand Up @@ -610,11 +608,7 @@ protected function _getFormPost($iCmtParentId = 0)
$oMetatags->keywordsAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
}

$oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $iCmtObjectId, $iCmtAuthorId, array('comment_id' => $iCmtId, 'comment_text' => $sCmtText, 'comment_author_id' => $iCmtAuthorId, 'object_author_id' => $iCmtObjectAuthorId));
$oZ->alert();

$oZ = new BxDolAlerts('comment', 'added', $iCmtId, $iCmtAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iCmtObjectId, 'object_author_id' => $iCmtObjectAuthorId, 'comment_text' => $sCmtText));
$oZ->alert();
$this->onPostAfter($iCmtId);

return array('id' => $iCmtId, 'parent_id' => $iCmtParentId);
}
Expand All @@ -627,10 +621,7 @@ protected function _getFormPost($iCmtParentId = 0)

protected function _getFormEdit($iCmtId)
{
$iCmtObjectId = (int)$this->getId();
$iCmtObjectAuthorId = $this->getObjectAuthorId($iCmtObjectId);

$aCmt = $this->_oQuery->getCommentSimple ($iCmtObjectId, $iCmtId);
$aCmt = $this->_oQuery->getCommentSimple ((int)$this->getId(), $iCmtId);
if(!$aCmt)
return array('msg' => _t('_No such comment'));

Expand All @@ -656,11 +647,7 @@ protected function _getFormEdit($iCmtId)
$oMetatags->keywordsAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
}

$oZ = new BxDolAlerts($this->_sSystem, 'commentUpdated', $iCmtObjectId, $iCmtAuthorId, array('comment_id' => $aCmt['cmt_id'], 'comment_author_id' => $aCmt['cmt_author_id'], 'object_author_id' => $iCmtObjectAuthorId));
$oZ->alert();

$oZ = new BxDolAlerts('comment', 'edited', $iCmtId, $iCmtAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iCmtObjectId, 'object_author_id' => $iCmtObjectAuthorId));
$oZ->alert();
$this->onEditAfter($iCmtId);

return array('id' => $iCmtId, 'text' => $this->_prepareTextForOutput($sCmtText, $iCmtId));
}
Expand Down

0 comments on commit b85333e

Please sign in to comment.