Skip to content

Commit

Permalink
Ticket #4148 - Build-in API support: Notifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Oct 30, 2023
1 parent 3b0e2cc commit 8023e2d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion modules/boonex/notifications/classes/BxNtfsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ public function serviceGetBlockView($sType = '', $iStart = -1, $iPerPage = -1, $
$aParams['start'] = end($aContent)['id'];
}

$this->markAsRead($iOwnerId, $aParams);
if($aParams['start'] == 0)
$this->markAsRead($iOwnerId, $aParams);

return [bx_api_get_block('browse', [
'unit' => 'notifications',
Expand Down
24 changes: 22 additions & 2 deletions modules/boonex/notifications/classes/BxNtfsTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,24 @@ public function getPost(&$aEvent, $aBrowseParams = array())
$bClickedIndicator = $this->_oConfig->isClickedIndicator();
$sJsObject = $this->_oConfig->getJsObject('view');

if (bx_is_api())
if(bx_is_api()) {
$aLinks = [
'owner_link' => $aEvent['content']['owner_link'],
'object_owner_link' => $aEvent['content']['object_owner_link']
];
if(!empty($aEvent['content']['entry_url']))
$aLinks['entry_url'] = $this->_getLink($aEvent['content']['entry_url']);
if(!empty($aEvent['content']['subentry_url']))
$aLinks['subentry_url'] = $this->_getLink($aEvent['content']['subentry_url']);

array_walk($aLinks, function(&$sValue, $sKey) {
$sValue = bx_api_get_relative_url($sValue);
});

$aEvent['content'] = array_merge($aEvent['content'], $aLinks);
return $aEvent;

}

return $this->parseHtmlByName('event.html', array (
'html_id' => $this->_oConfig->getHtmlIds('view', 'event') . $aEvent['id'],
'style_prefix' => $this->_oConfig->getPrefix('style'),
Expand Down Expand Up @@ -442,6 +457,11 @@ protected function _getContentLink(&$aEvent)
if(!empty($aEvent['subobject_id']) && !empty($aEvent['content']['subentry_url']))
$sLink = $aEvent['content']['subentry_url'];

return $this->_getLink($sLink);
}

protected function _getLink($sLink)
{
return bx_replace_markers($sLink, [
'bx_url_root' => BX_DOL_URL_ROOT
]);
Expand Down

0 comments on commit 8023e2d

Please sign in to comment.