From 6ee13ea1aa8748ed63dae7d19b9cb50abfd938d2 Mon Sep 17 00:00:00 2001 From: skeeter Date: Thu, 25 Oct 2001 23:51:35 +0000 Subject: [PATCH] This will now allow events to care with the groups, if a group is assigned as a participant. If new users are added to the group, it will populate the datastore with those events when they view the event for the first time. --- calendar/inc/class.bocalendar.inc.php | 41 +++++++++++++++++++++++++-- calendar/inc/class.socalendar.inc.php | 19 ++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index 9620782605..9f221379f1 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -356,6 +356,12 @@ if($this->check_perms(PHPGW_ACL_READ)) { $event = $this->so->read_entry($id); + if(!isset($event['participants'][$this->owner]) && $this->user_is_a_member($event,$this->owner)) + { + $this->add_attribute('participants','U',intval($this->owner)); + $this->so->add_entry($event); + $event = $this->get_cached_event(); + } return $event; } } @@ -545,6 +551,8 @@ } elseif($acct_type == 'g') { + $part[$parts[$i]] = 1; + $groups[] = $parts[$i]; /* This pulls ALL users of a group and makes them as participants to the event */ /* I would like to turn this back into a group thing. */ $acct = CreateObject('phpgwapi.accounts',intval($parts[$i])); @@ -575,6 +583,12 @@ } } + if($groups) + { + @reset($groups); + $this->so->add_attribute('groups',intval($group_id)); + } + $event = $this->get_cached_event(); if(!@isset($event['participants'][$l_cal['owner']])) { @@ -672,6 +686,29 @@ unset($holiday); } + function user_is_a_member($event,$user) + { + @reset($event['participants']); + $uim = False; + $security_equals = $GLOBALS['phpgw']->accounts->membership($user); + while(!$uim && $security_equals && list($participant,$status) = each($event['participants'])) + { + if($GLOBALS['phpgw']->accounts->get_type($participant) == 'g') + { + @reset($security_equals); + while(list($key,$group_info) = each($security_equals)) + { + if($group_info['account_id'] == $participant) + { + return True; + $uim = True; + } + } + } + } + return $uim; + } + function maketime($time) { return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']); @@ -1372,9 +1409,9 @@ return $this->so->get_cached_event(); } - function add_attribute($var,$value) + function add_attribute($var,$value,$index='') { - $this->so->add_attribute($var,$value); + $this->so->add_attribute($var,$value,$index); } function event_init() diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index d4416764b4..9b4ca80a82 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -84,16 +84,27 @@ $endtime = mktime(23,59,59,$emonth,$eday,$eyear) - $this->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') "; + $sql = "AND (phpgw_cal.cal_type='M') " + . 'AND (phpgw_cal_user.cal_login in ('; if($owner_id) { - $sql .= 'AND (phpgw_cal_user.cal_login in ('.implode(',',$owner_id).') '; + $sql .= implode(',',$owner_id); } else { - $sql .= 'AND (phpgw_cal_user.cal_login'.(!$this->is_group?' = '.$this->owner:' in ('.implode(',',$this->g_owner).')').' '; + $sql .= (!$this->is_group?$this->owner:implode(',',$this->g_owner)); } - + + $member_groups = $GLOBALS['phpgw']->accounts->membership($this->user); + @reset($member_groups); + while(list($key,$group_info) = each($member_groups)) + { + $member[] = $group_info['account_id']; + } + @reset($member); + $sql .= ','.implode(',',$member); + + $sql .= ') '; // $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))) ' . (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'')