From cdd5b95433bc7d3cd3ba1e22e95155ba9f77ec43 Mon Sep 17 00:00:00 2001 From: e107steved Date: Sat, 15 Dec 2007 22:15:30 +0000 Subject: [PATCH] Actually filter where no valid event categories --- e107_plugins/calendar_menu/ecal_class.php | 16 +++++++++++----- e107_plugins/calendar_menu/event.php | 7 ++++--- e107_plugins/calendar_menu/next_event_menu.php | 6 +++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/e107_plugins/calendar_menu/ecal_class.php b/e107_plugins/calendar_menu/ecal_class.php index baf599144..a932dc8d6 100644 --- a/e107_plugins/calendar_menu/ecal_class.php +++ b/e107_plugins/calendar_menu/ecal_class.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/ecal_class.php,v $ -| $Revision: 1.3 $ -| $Date: 2007-12-15 14:19:19 $ +| $Revision: 1.4 $ +| $Date: 2007-12-15 22:15:30 $ | $Author: e107steved $ | | Event calendar class: @@ -495,11 +495,12 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default"); // Read a list of events between start and end dates // If $start_only is TRUE, only searches based on the start date/time // Potential option to hook in other routines later - function get_events($start_time, $end_time, $start_only=FALSE, $cat_filter=0, $inc_recur=FALSE, $event_fields='*', $cat_fields='*') + function get_events($start_time, $end_time, $start_only=FALSE, $cat_filter='*', $inc_recur=FALSE, $event_fields='*', $cat_fields='*') { global $sql; $ret = array(); + if ($cat_filter === FALSE) return $ret; $cat_lj = ''; $category_filter = ''; $extra = ''; @@ -567,11 +568,16 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default"); // It always uses the event start date only // It tries to keep the actual number of events in memory to a minimum by discarding when it can. // Once there are $num_events read, it pulls in the $end_time to speed up checks - function get_n_events($num_event, $start_time, $end_time, $cat_filter=0, $inc_recur=FALSE, $event_fields='*', $cat_fields='*') + // $cat_filter = FALSE is 'no categories' - returns an empty array. + // $cat_filter = '*' means 'all categories' + // otherwise $cat_filter mst be a comma-separated list of category IDs. + function get_n_events($num_event, $start_time, $end_time, $cat_filter='*', $inc_recur=FALSE, $event_fields='*', $cat_fields='*') { global $sql; $ret = array(); + if ($cat_filter === FALSE) return $ret; // Empty category + $cat_lj = ''; $category_filter = ''; $extra = ''; @@ -583,7 +589,7 @@ if (!defined("EC_DEFAULT_CATEGORY")) { define('EC_DEFAULT_CATEGORY',"Default"); $cat_lj = ' LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id '; } - if ($cat_filter) $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') "; + if ($cat_filter != '*') $category_filter = " AND find_in_set(e.event_category, '".$cat_filter."') "; if ($inc_recur) $extra = " OR (e.event_recurring >'0' AND (e.event_start <= ".intval($end_time)." AND e.event_end >= ".intval($start_time).")) "; $qry = "SELECT {$event_fields}{$cat_fields} FROM #event as e {$cat_lj} diff --git a/e107_plugins/calendar_menu/event.php b/e107_plugins/calendar_menu/event.php index b9b1590f3..f722eba03 100644 --- a/e107_plugins/calendar_menu/event.php +++ b/e107_plugins/calendar_menu/event.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/event.php,v $ -| $Revision: 1.3 $ -| $Date: 2007-09-04 21:09:47 $ +| $Revision: 1.4 $ +| $Date: 2007-12-15 22:15:30 $ | $Author: e107steved $ | +----------------------------------------------------------------------------+ @@ -53,7 +53,8 @@ require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php"); require_once(e_HANDLER."calendar/calendar_class.php"); $cal = new DHTML_Calendar(true); -$cat_filter = intval(varset($_POST['event_cat_ids'],0)); +$cat_filter = intval(varset($_POST['event_cat_ids'],-1)); +if ($cat_filter == -1) $cat_filter = '*'; $mult_count = 0; diff --git a/e107_plugins/calendar_menu/next_event_menu.php b/e107_plugins/calendar_menu/next_event_menu.php index bb4ec40ea..e6d94f550 100644 --- a/e107_plugins/calendar_menu/next_event_menu.php +++ b/e107_plugins/calendar_menu/next_event_menu.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/next_event_menu.php,v $ -| $Revision: 1.3 $ -| $Date: 2007-11-12 19:56:13 $ +| $Revision: 1.4 $ +| $Date: 2007-12-15 22:15:30 $ | $Author: e107steved $ | +----------------------------------------------------------------------------+ @@ -67,7 +67,7 @@ $cal_row = array(); global $cal_row, $cal_totev; -$ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset($pref['eventpost_fe_set'],0), $show_recurring, +$ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset($pref['eventpost_fe_set'],FALSE), $show_recurring, 'event_id,event_start, event_thread, event_title, event_recurring, event_allday, event_category', 'event_cat_icon'); $cal_totev = count($ev_list);