AntonLV 6 лет назад
Родитель
Сommit
299e8bc4ee

+ 1 - 0
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -85,6 +85,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             'FIELD_TITLE' => 'title',
             'FIELD_TEXT' => 'description',
             'FIELD_STATUS' => 'status',
+            'FIELD_STICKED' => 'sticked',
             'FIELD_DATE' => 'date',
             'FIELD_ANONYMOUS' => 'anonymous',
             'FIELD_CONTROLS' => 'controls',

+ 11 - 4
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -2350,6 +2350,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function serviceGetLiveUpdate($aBrowseParams, $iProfileId, $iValue = 0, $iInit = 0)
     {
+        $CNF = &$this->_oConfig->CNF;
+
         $sKey = $this->_oConfig->getLiveUpdateKey($aBrowseParams);
 
         bx_import('BxDolSession');
@@ -2366,11 +2368,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $iValueNew = 0;
         foreach($aEvents as $aEvent) {
+            if((int)$aEvent[$CNF['FIELD_STICKED']] != 0)
+                continue;
+
             $sContent = $this->_oTemplate->getPost($aEvent, $aParams);
-            if(!empty($sContent)) {
-                $iValueNew = $aEvent['id'];
-                break;
-            }
+            if(empty($sContent)) 
+                continue;
+
+            $iValueNew = $aEvent['id'];
+            break;
         }
 
         if($iValueNew == $iValue)
@@ -2397,6 +2403,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      * @code bx_srv('bx_timeline', 'get_live_updates', [...]); @endcode
      * 
      * Get an array with actual Live Update info. Separate live update notification for each new Event.
+     * Note. This method isn't used for now. @see BxTimelineModule::serviceGetLiveUpdate method instead.
      * 
      * Note. This way to display live update notifications isn't used for now. 
      * See BxTimelineModule::serviceGetLiveUpdate method instead.

+ 17 - 1
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -563,7 +563,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $iFirst = 0;
         $iEvents = count($aEvents);
         if($iEvents > 0)
-            $iFirst = (int)$aEvents[0]['id'];
+            $iFirst = $this->_getFirst($aEvents, $aParams);
         else 
             $sContent .= $bViewTimeline ? $this->getDividerToday() : '';
 
@@ -2571,6 +2571,22 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         return $aResult;
     }
 
+    protected function _getFirst($aEvents, $aParams = array())
+    {
+        $CNF = $this->_oConfig->CNF;
+
+        foreach($aEvents as $aEvent)
+            if((int)$aEvent[$CNF['FIELD_STICKED']] == 0)
+                return (int)$aEvent[$CNF['FIELD_ID']];
+
+        $aParams['start'] += $aParams['per_page'];
+        $aEvents = $this->_getPosts($aParams);
+        if(!empty($aEvents) && is_array($aEvents))
+            return $this->_getFirst($aEvents, $aParams);
+
+        return 0;
+    }
+
     protected function _preparetDataActions(&$aEvent, &$aResult)
     {
         if(empty($aEvent) || !is_array($aEvent) || empty($aEvent['id']))