From: Steve Sutton Date: Thu, 2 Mar 2017 21:32:35 +0000 (-0500) Subject: Update the query to get times to add dates X-Git-Tag: v1.6.16^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=097f90ba76eedb1e32d84f8f96bf2d0c16ea83a7;p=WP-Plugins%2Fglm-member-db-events.git Update the query to get times to add dates Update the query for times to only get times for the searched month range. --- diff --git a/index.php b/index.php index 455bb51..c4204a1 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database Events * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.6.15 + * Version: 1.6.16 * Author: Chuck Scott * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -20,7 +20,7 @@ * @package glmMembersDatabaseEventsAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.6.15 + * @version 1.6.16 */ /* @@ -38,7 +38,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.15'); +define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.16'); define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.1'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/models/admin/ajax/eventsCalMonthAJAX.php b/models/admin/ajax/eventsCalMonthAJAX.php index 75570c5..21f1d4a 100644 --- a/models/admin/ajax/eventsCalMonthAJAX.php +++ b/models/admin/ajax/eventsCalMonthAJAX.php @@ -99,6 +99,7 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events AS ET WHERE ET.status = " . $this->config['status_numb']['Active'] . " ) + AND $this->dateRangeTimes "; $events = $this->getList( $where ); @@ -127,32 +128,32 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes { global $wpdb; - + $event_data = []; - + // this section is for a sidebar events widget, typically on a front page if( isset( $_REQUEST['date_string'] ) || isset($_REQUEST['all_events'] ) ){ $image_url = GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/'; - + 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 AND end_time >= CURDATE() 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"; $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE end_time >= CURDATE() GROUP BY event ORDER BY start_time LIMIT 3;"; // $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ORDER BY start_time LIMIT 3;"; $events_times = $wpdb->get_results($sql); - + foreach($events_times as $times){ $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events WHERE id = " . $times->event.";"; $event[] = $wpdb->get_results($sql); @@ -161,7 +162,7 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes foreach($ev as $e){ $events[] = $e; } - + } } foreach($events as $event){ @@ -180,20 +181,20 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes } else { $end_date = ''; } - + $start_date = date('M d', strtotime($date[0]->start_time)); $start_timestamp = strtotime($start_date); $end_timestamp = strtotime($end_date); - + if($start_timestamp < $end_timestamp){ $start_date = $start_date . " - " . $end_date; } - $sidebar_events[$event->id] = + $sidebar_events[$event->id] = array( "start_date" => $start_date, - "end_date" => $end_date, - "name" => $event->name, - "content" => $event->intro, + "end_date" => $end_date, + "name" => $event->name, + "content" => $event->intro, 'image' => $image, 'id' => $event->id, 'timestamp' => $start_timestamp, @@ -217,11 +218,11 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes } } } - + ksort($arrayDates); } // end section for front page events widget data - + $month = filter_var_array( $_REQUEST['month'], array( @@ -235,7 +236,7 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes $from = date('Y-m-d', strtotime($start)); $to = date('Y-m-d', strtotime($last)); - $this->dateRange = "start_time BETWEEN CAST('{$from}' AS DATE) AND CAST('{$to}' as DATE)"; + $this->dateRangeTimes = "start_time BETWEEN CAST('{$from}' AS DATE) AND CAST('{$to}' as DATE)"; $this->dateRange = "id IN ( SELECT id FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times @@ -265,7 +266,7 @@ class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes // $slug = sanitize_title( $val['event_name'] ); $event_data[$e]['url'] = GLM_MEMBERS_EVENTS_SITE_BASE_URL . "event-detail/" . $slug . "/"; } - + $return = array( // 'status' => false, // Assume nothing works 'events' => $event_data , // Where our events list will go