Просмотр исходного кода

Ticket #2392 - Point №1: Related fixes.

AntonLV 6 лет назад
Родитель
Сommit
2c88ffd8e4

+ 14 - 2
modules/boonex/notifications/classes/BxNtfsMenuPreview.php

@@ -60,14 +60,26 @@ class BxNtfsMenuPreview extends BxTemplMenuCustom
 
     protected function getMenuItemsRaw ()
     {
-        $aItems = $this->_oModule->serviceGetNotifications($this->_iOwnerId, array('per_page' => $this->_oModule->_oConfig->getPerPage('preview')));
+        $aItems = $this->_oModule->serviceGetNotifications($this->_iOwnerId);
         if(empty($aItems) || !is_array($aItems))
             return array();
 
+        $aResults = array();
+        foreach($aItems as $iKey => $aItem) {
+            if(!$this->_oModule->_oTemplate->getPost($aItem))
+                continue;
+
+            $aResults[] = $aItem;
+        }
+
+        $iPerPage = $this->_oModule->_oConfig->getPerPage('preview');
+        if(count($aResults) > $iPerPage)
+            $aResults = array_slice($aResults, 0, $iPerPage);
+
         $bFirst = true;
         foreach($aItems as $iKey => $aItem) {
             if($bFirst)
-    			$bFirst = !$this->_oModule->_oDb->markAsRead($this->_iOwnerId, $aItem['id']);
+                $bFirst = !$this->_oModule->_oDb->markAsRead($this->_iOwnerId, $aItem['id']);
 
             $aItems[$iKey]['name'] = 'event';
         }

+ 11 - 12
modules/boonex/notifications/classes/BxNtfsModule.php

@@ -228,24 +228,23 @@ class BxNtfsModule extends BxBaseModNotificationsModule
      */
     public function serviceGetNotifications($iOwnerId = 0, $aBrowseParams = array())
     {
-    	if(!$iOwnerId)
-			$iOwnerId = $this->getUserId();
+        if(!$iOwnerId)
+            $iOwnerId = $this->getUserId();
 
-		if(!$iOwnerId)
-			return 0;
+        if(!$iOwnerId)
+            return 0;
 
-		$aParams = $this->_prepareParams(BX_NTFS_TYPE_DEFAULT, $iOwnerId);
-		if(!empty($aBrowseParams) && is_array($aBrowseParams))
-		    $aParams = array_merge($aParams, $aBrowseParams);
+        $aParams = $this->_prepareParams(BX_NTFS_TYPE_DEFAULT, $iOwnerId);
+        if(!empty($aBrowseParams) && is_array($aBrowseParams))
+            $aParams = array_merge($aParams, $aBrowseParams);
 
-		list($aEvent) = $this->_oDb->getEvents($aParams, true);
+        list($aEvent) = $this->_oDb->getEvents($aParams, true);
 
         // returns parsed content for React Jot
-		if (!is_array($aBrowseParams) && $aBrowseParams === 'return_parsed_content')
-		    foreach ($aEvent as &$aContent)
+        if (!is_array($aBrowseParams) && $aBrowseParams === 'return_parsed_content')
+            foreach ($aEvent as &$aContent)
                 $this->_oTemplate->getPost($aContent, array('return_parsed_content'));
 
-
         return $aEvent;
     }
 
@@ -268,7 +267,7 @@ class BxNtfsModule extends BxBaseModNotificationsModule
      */
     public function serviceGetUnreadNotifications($iOwnerId = 0)
     {
-		return $this->serviceGetNotifications($iOwnerId, array('new' => 1));
+        return $this->serviceGetNotifications($iOwnerId, array('new' => 1));
     }
 
     /**