From 59ca017000e8a007689f6529c8de036153433a80 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 18 Aug 2015 09:07:12 +0000 Subject: [PATCH] allow to use nextmatch filters in calendar list-view --- calendar/inc/class.calendar_so.inc.php | 13 ++++++++++--- calendar/inc/class.calendar_uilist.inc.php | 13 ++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index 75badcdd21..f72a6ec003 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -687,7 +687,7 @@ class calendar_so * Please Note: a search never returns repeating events more then once AND does not honor start+end date !!! * array: everything is directly used as $where * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma - * @param string $params['sql_filter'] sql to be and'ed into query (fully quoted) + * @param string|array $params['sql_filter'] sql to be and'ed into query (fully quoted), or usual filter array * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date", * if specified and not false an iterator for the rows is returned * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause @@ -746,9 +746,16 @@ class calendar_so $private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')'; $where[] = $private_filter; } - if (!empty($params['sql_filter']) && is_string($params['sql_filter'])) + if (!empty($params['sql_filter'])) { - $where[] = $params['sql_filter']; + if (is_string($params['sql_filter'])) + { + $where[] = $params['sql_filter']; + } + elseif(is_array($params['sql_filter'])) + { + $where = array_merge($where, $params['sql_filter']); + } } if ($users) { diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 695a19ecdb..1ceb82cbd8 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -378,9 +378,20 @@ class calendar_uilist extends calendar_ui { $search_params['users'] = explode(',',$this->owner); } + if ($params['col_filter']) + { + $col_filter = array(); + foreach($params['col_filter'] as $name => $val) + { + if ($name != 'participants' && (string)$val !== '') + { + $col_filter[$name] = $val; + } + } + } $rows = $js_integration_data = array(); - foreach((array) $this->bo->search($search_params) as $event) + foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) { $this->to_client($event);