setting the default events widget to display ALL events. selecting next, back or...
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 30 Jan 2017 21:20:23 +0000 (16:20 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 30 Jan 2017 21:20:23 +0000 (16:20 -0500)
from the dropdown will specifiy the month's events

models/admin/ajax/eventsCalMonthAJAX.php
views/front/events/sidebarEvents.html

index 6fa7a3d..0fcea9d 100644 (file)
@@ -131,32 +131,42 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes
         $event_data = [];
         
         // this section is for a sidebar events widget, typically on a front page
-        if(isset($_REQUEST['date_string'])){
-            $date = date_parse($_REQUEST['date_string']);
-            $month = $date['month'];
-            $year  = $date['year'];
+        if( isset( $_REQUEST['date_string'] ) || isset($_REQUEST['all_events'] ) ){
             $image_url = GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/';
             
-            $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
-            $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE YEAR(start_time) = $year AND MONTH(start_time) = $month AND active = 1 ORDER BY start_time ) LIMIT 3; ";
-            $events = $wpdb->get_results($sql);
-                     
+            if(isset($_REQUEST['date_string'])){
+                $date = date_parse($_REQUEST['date_string']);
+                $month = $date['month'];
+                $year  = $date['year'];
+                
+
+                $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
+                $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE YEAR(start_time) = $year AND MONTH(start_time) = $month AND active = 1 ORDER BY start_time ) LIMIT 3; ";
+                $events = $wpdb->get_results($sql);
+
+          
+            } else if(isset($_REQUEST['all_events'])){
+                $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
+                $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ORDER BY start_time ) LIMIT 3; ";
+                $events = $wpdb->get_results($sql);
+
+            }
             foreach($events as $event){
                 $sql = "SELECT start_time, end_time FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE event = " . $event->id;
-                
+
                 if($event->image !== ''){
                     $image = $image_url . $event->image;
                 } else {
                     $image = "none";
                 }
-                
+
                 $date = $wpdb->get_results($sql);
                 $dates[] = $date[0];
                 $start_date = date('M d', strtotime($date[0]->start_time));
                 $end_date = date('M d', strtotime($date[0]->end_time));
                 $start_timestamp = strtotime($start_date);
                 $end_timestamp = strtotime($end_date);
-             
+
                 $sidebar_events[$event->id] = 
                     array(
                         "start_date" => $start_date, 
@@ -170,12 +180,12 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes
 //               $events_date[$start_date] = array();
                $arrayDates[date('F d D', strtotime($start_date))]  = array();
             }
-      
+
             function sortFunction( $event1, $event2 ) {
                 return strtotime($event1['start_date']) - strtotime($event2["start_date"]);
             }
             usort($sidebar_events, "sortFunction");
-            
+
             foreach($arrayDates as $key=>$date){
                 foreach($sidebar_events as $event){
                     if($event['timestamp'] === strtotime($key)){
index 60a834d..496dd13 100644 (file)
@@ -74,7 +74,7 @@
         var dat = {
                 action: 'glm_members_admin_ajax',
                 glm_action: 'eventsCalMonthAJAX',
-                date_string: date_string
+                all_events: 'true'
         };
         ajaxEvents(dat);