Browse Source

Fix global calendar events. Show events that start or end between a date range too - refs #7556

Imanol Losada 10 years ago
parent
commit
e479b19600
1 changed files with 5 additions and 9 deletions
  1. 5 9
      main/inc/lib/agenda.lib.php

+ 5 - 9
main/inc/lib/agenda.lib.php

@@ -1490,23 +1490,19 @@ class Agenda
         $start = intval($start);
         $end = intval($end);
 
-        $startCondition = '';
-        $endCondition = '';
-
+        $condition = null;
         if ($start !== 0) {
             $start = api_get_utc_datetime($start);
-            $startCondition = "AND start_date >= '".$start."'";
+            $condition = " AND (start_date >= '".$start."' OR end_date >= '".$start."')";
         }
-        if ($start !== 0) {
+        if ($end !== 0) {
             $end = api_get_utc_datetime($end);
-            $endCondition = "AND end_date <= '".$end."'";
+            $condition .= " AND (start_date <= '".$end."' OR end_date <= '".$end."')";
         }
-
         $access_url_id = api_get_current_access_url_id();
 
         $sql = "SELECT * FROM ".$this->tbl_global_agenda."
-               WHERE access_url_id = $access_url_id $startCondition $endCondition";
-
+                       WHERE access_url_id = $access_url_id$condition";echo $sql;
         $result = Database::query($sql);
         $my_events = array();
         if (Database::num_rows($result)) {