Quellcode durchsuchen

Ticket #4575 - Events: Enhancements. Point 2.

AntonLV vor 2 Jahren
Ursprung
Commit
8da64c847b

+ 1 - 1
modules/boonex/events/classes/BxEventsDb.php

@@ -241,7 +241,7 @@ class BxEventsDb extends BxBaseModGroupsDb
                 ];
 
                 $sWhereClause = " AND `ts`.`event_id`=:event_id";
-                $sOrderClause = "`ts`.`order` ASC";
+                $sOrderClause = "`ts`.`" . !empty($aParams['order_by']) ? $aParams['order_by'] : "order" . "` ASC";
                 break;
         }
 

+ 7 - 3
modules/boonex/events/classes/BxEventsGridSessionsManage.php

@@ -27,14 +27,18 @@ class BxEventsGridSessionsManage extends BxTemplGrid
 
         parent::__construct ($aOptions, $oTemplate);
 
+        if($this->_bIsApi)
+            $this->_aOptions['field_order'] = 'date_start';
+
         $this->_iEventProfileId = 0;
         $this->_iEventContentId = 0;
         $this->_aEventContentInfo = [];
         if(($iEventProfileId = bx_get('profile_id')) !== false)
             $this->setProfileId($iEventProfileId);
     }
-    
-    function getFormCallBackUrlAPI($sAction, $iId = 0){
+
+    public function getFormCallBackUrlAPI($sAction, $iId = 0)
+    {
          return '/api.php?r=system/perfom_action_api/TemplServiceGrid/&params[]=&o=' . $this->_sObject . '&profile_id=' . $this->_iEventProfileId . '&a=' . $sAction . '&id=' . $iId;
     }
 
@@ -48,7 +52,7 @@ class BxEventsGridSessionsManage extends BxTemplGrid
             $this->_aEventContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iEventContentId);
         }
     }
-    
+
     public function performActionAdd()
     {
     	$CNF = &$this->_oModule->_oConfig->CNF;

+ 5 - 9
modules/boonex/events/classes/BxEventsTemplate.php

@@ -24,7 +24,7 @@ class BxEventsTemplate extends BxBaseModGroupsTemplate
     {
         $CNF = &$this->_oConfig->CNF;
 
-        $aSessions = $this->_oDb->getSessions(['sample' => 'event_id', 'event_id' => $iContentId]);
+        $aSessions = $this->_oDb->getSessions(['sample' => 'event_id', 'event_id' => $iContentId, 'order_by' => $this->_bIsApi ? 'date_start' : '']);
         if(empty($aSessions) || !is_array($aSessions))
             return '';
 
@@ -34,29 +34,25 @@ class BxEventsTemplate extends BxBaseModGroupsTemplate
 
         $aTmplVarsSession = [];
         foreach($aSessions as $aSession) {
-            
-
             $sDate = '';
             if(date('d', $aSession['date_start']) == date('d', $aSession['date_end']))
                 $sDate = date($sFormatDate, $aSession['date_start']) . ' ' . date($sFormatTime, $aSession['date_start']) . ' - ' . date($sFormatTime, $aSession['date_end']);
             else
                 $sDate = date($sFormatDateTime, $aSession['date_start']) . ' - ' . date($sFormatDateTime, $aSession['date_end']);
 
-            
             $aTmplVarsSession[] = [
                 'title' => bx_process_output($aSession['title']),
                 'date_time' =>  $sDate,
             ];
         }
-        
+
         $s = $this->parseHtmlByName('entry-sessions.html', [
             'bx_repeat:sessions' => $aTmplVarsSession
         ]);
-        
-        if (bx_is_api()){
+
+        if($this->_bIsApi)
             return [bx_api_get_block('event_sessions',  $aTmplVarsSession)];
-        }
-        
+
         return $s;
     }