From 0b5de55bbf264bf0e36f3690f7e133ef6fc7532b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 23 Nov 2003 13:06:47 +0000 Subject: [PATCH] fix to deal with empty groups selected in the planner --- calendar/inc/class.socalendar.inc.php | 30 ++++++++------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index 171ad610b0..53caf33eeb 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -85,32 +85,20 @@ function list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday,$owner_id=0) { - if($GLOBALS['phpgw_info']['server']['calendar_type'] != 'sql') + if(!$owner_id) + { + $owner_id = $this->is_group ? $this->g_owner : $this->owner; + } + if($GLOBALS['phpgw_info']['server']['calendar_type'] != 'sql' || + !count($owner_id)) // happens with empty groups { return Array(); } $starttime = mktime(0,0,0,$smonth,$sday,$syear) - $GLOBALS['phpgw']->datetime->tz_offset; $endtime = mktime(23,59,59,$emonth,$eday,$eyear) - $GLOBALS['phpgw']->datetime->tz_offset; -// $starttime = mktime(0,0,0,$smonth,$sday,$syear); -// $endtime = mktime(23,59,59,$emonth,$eday,$eyear); - $sql = "AND (phpgw_cal.cal_type='M') " - . 'AND (phpgw_cal_user.cal_login in ('; - if($owner_id) - { - if(is_array($owner_id)) - { - $sql .= implode(',',$owner_id); - } - else - { - $sql .= $owner_id; - } - } - else - { - $sql .= (!$this->is_group?$this->owner:implode(',',$this->g_owner)); - } + $sql = "AND phpgw_cal.cal_type='M' AND phpgw_cal_user.cal_login IN (". + (is_array($owner_id) ? implode(',',$owner_id) : $owner_id).')'; // $member_groups = $GLOBALS['phpgw']->accounts->membership($this->user); // @reset($member_groups); @@ -122,7 +110,7 @@ // $sql .= ','.implode(',',$member).') '; // $sql .= 'AND (phpgw_cal.datetime <= '.$starttime.') '; // $sql .= 'AND (((phpgw_cal_repeats.recur_enddate >= '.$starttime.') AND (phpgw_cal_repeats.recur_enddate <= '.$endtime.')) OR (phpgw_cal_repeats.recur_enddate=0))) ' - $sql .= ') AND ((phpgw_cal_repeats.recur_enddate >= '.$starttime.') OR (phpgw_cal_repeats.recur_enddate=0))) ' + $sql .= ' AND (phpgw_cal_repeats.recur_enddate >= '.$starttime.' OR phpgw_cal_repeats.recur_enddate=0) ' . (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'') . ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":'') . 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';