From 551bfb8dbbd2cf62551a9f312284e3d3e6f7d7a0 Mon Sep 17 00:00:00 2001 From: skeeter Date: Thu, 25 Oct 2001 23:52:15 +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. This also adds a little more support for alarm management. --- calendar/inc/class.socalendar_sql.inc.php | 22 ++- calendar/inc/class.uicalendar.inc.php | 183 ++++++++++++---------- 2 files changed, 116 insertions(+), 89 deletions(-) diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index e660118079..1ab58025b9 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -204,6 +204,7 @@ class socalendar_ extends socalendar__ while($this->stream->next_record()) { $this->event['alarm'][] = Array( + 'id' => intval($this->stream->f('alarm_id')), 'time' => intval($this->stream->f('cal_time')), 'text' => $this->stream->f('cal_text'), 'enabled' => intval($this->stream->f('alarm_enabled')) @@ -229,16 +230,28 @@ class socalendar_ extends socalendar__ } $datetime = mktime(0,0,0,$startMonth,$startDay,$startYear) - $tz_offset; + + $user_where = ' AND (phpgw_cal_user.cal_login in ('; if($owner_id) { - $user_where = ' AND (phpgw_cal_user.cal_login in ('.implode(',',$owner_id).')) '; - - echo ''."\n"; + $user_where .= implode(',',$owner_id); } else { - $user_where = ' AND (phpgw_cal_user.cal_login = '.$this->user.') '; + $user_where .= $this->user; } + $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); + $user_where .= ','.implode(',',$member); + $user_where .= ')) '; + + echo ''."\n"; + $startDate = 'AND ( ( (phpgw_cal.datetime >= '.$datetime.') '; $enddate = ''; @@ -447,6 +460,7 @@ class socalendar_ extends socalendar__ . "title='".$this->stream->db_addslashes($event['title'])."', " . "description='".$this->stream->db_addslashes($event['description'])."', " . "location='".$event['location']."', " + . ($event['groups']?"groups='".(count($event['groups'])>1?implode(',',$event['groups']):','.$event['groups'][0].',')."', ":'') . 'reference='.$event['reference'].' ' . 'WHERE cal_id='.$event['id']; diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 4807a73b93..1d513b0bdb 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -500,123 +500,136 @@ $date = $date?$date:intval($GLOBALS['HTTP_GET_VARS']['date']); // First, make sure they have permission to this entry + $continue_ok = True; if ($cal_id < 1) { - echo lang('Invalid entry id.').''; - return; + echo lang('Invalid entry id.').''."\n"; + $continue_ok = False; + $GLOBALS['phpgw']->common->phpgw_exit(True); } if(!$this->bo->check_perms(PHPGW_ACL_READ)) { - echo lang('You do not have permission to read this record!').''; - return; + echo lang('You do not have permission to read this record!').''."\n"; + $continue_ok = False; + $GLOBALS['phpgw']->common->phpgw_exit(True); } $event = $this->bo->read_entry($cal_id); if(!isset($event['id'])) { - echo lang("Sorry, this event does not exist").'.'.''; - return; + echo lang("Sorry, this event does not exist").'.'.''."\n"; + $continue_ok = False; + $GLOBALS['phpgw']->common->phpgw_exit(True); } - $this->bo->repeating_events = Array(); - $this->bo->cached_events = Array(); - $this->bo->repeating_events[0] = $event; - $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $this->tz_offset; - $this->bo->check_repeating_events($datetime); - $check_date = $GLOBALS['phpgw']->common->show_date($datetime,'Ymd'); - if(is_array($this->bo->cached_events[$check_date][0]) && - $this->bo->cached_events[$check_date][0]['id'] == $event['id']) + if($continue_ok) { - $starttime = $this->bo->maketime($event['start']); - $endtime = $this->bo->maketime($event['end']); - $event['start']['month'] = $this->bo->month; - $event['start']['mday'] = $this->bo->day; - $event['start']['year'] = $this->bo->year; - $temp_end = $this->bo->maketime($event['start']) + ($endtime - $starttime); - $event['end']['month'] = date('m',$temp_end); - $event['end']['mday'] = date('d',$temp_end); - $event['end']['year'] = date('Y',$temp_end); - } - echo $this->view_event($event); - - $p = CreateObject('phpgwapi.Template',$this->template_dir); - $p->set_file( - Array( - 'form_button' => 'form_button_script.tpl' - ) - ); - - if($this->bo->owner == $event['owner']) - { - if ($this->bo->check_perms(PHPGW_ACL_EDIT)) + $this->bo->repeating_events = Array(); + $this->bo->cached_events = Array(); + $this->bo->repeating_events[0] = $event; + $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $this->tz_offset; + $this->bo->check_repeating_events($datetime); + $check_date = $GLOBALS['phpgw']->common->show_date($datetime,'Ymd'); + if(is_array($this->bo->cached_events[$check_date][0]) && + $this->bo->cached_events[$check_date][0]['id'] == $event['id']) { - if($event['recur_type'] != MCAL_RECUR_NONE) + $starttime = $this->bo->maketime($event['start']); + $endtime = $this->bo->maketime($event['end']); + $event['start']['month'] = $this->bo->month; + $event['start']['mday'] = $this->bo->day; + $event['start']['year'] = $this->bo->year; + $temp_end = $this->bo->maketime($event['start']) + ($endtime - $starttime); + $event['end']['month'] = date('m',$temp_end); + $event['end']['mday'] = date('d',$temp_end); + $event['end']['year'] = date('Y',$temp_end); + } + + $ret_value = $this->view_event($event,True); + echo $ret_value; + + if($ret_value == '
'.lang('You do not have permission to read this record!').'
') + { + $GLOBALS['phpgw']->common->phpgw_exit(True); + } + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file( + Array( + 'form_button' => 'form_button_script.tpl' + ) + ); + + if($this->bo->owner == $event['owner']) + { + if ($this->bo->check_perms(PHPGW_ACL_EDIT)) { - $var = Array( - 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), - 'action_text_button' => lang('Edit Single'), - 'action_confirm_button' => '', - 'action_extra_field' => ''."\n" - . '' - - ); - $p->set_var($var); - echo $p->fp('out','form_button'); + if($event['recur_type'] != MCAL_RECUR_NONE) + { + $var = Array( + 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), + 'action_text_button' => lang('Edit Single'), + 'action_confirm_button' => '', + 'action_extra_field' => ''."\n" + . '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + + $var = Array( + 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), + 'action_text_button' => lang('Edit Series'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + } + else + { + $var = Array( + 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), + 'action_text_button' => lang('Edit'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + } $var = Array( - 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), - 'action_text_button' => lang('Edit Series'), + 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), + 'action_text_button' => lang('Alarm Management'), 'action_confirm_button' => '', - 'action_extra_field' => '' + 'action_extra_field' => '' ); $p->set_var($var); echo $p->fp('out','form_button'); } - else + + if ($this->bo->check_perms(PHPGW_ACL_DELETE)) { $var = Array( - 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), - 'action_text_button' => lang('Edit'), - 'action_confirm_button' => '', + 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), + 'action_text_button' => lang('Delete'), + 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", 'action_extra_field' => '' ); $p->set_var($var); echo $p->fp('out','form_button'); } - - $var = Array( - 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), - 'action_text_button' => lang('Alarm Management'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); } - if ($this->bo->check_perms(PHPGW_ACL_DELETE)) - { - $var = Array( - 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), - 'action_text_button' => lang('Delete'), - 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); - } + $var = Array( + 'action_url_button' => $this->page('export','&cal_id='.$cal_id), + 'action_text_button' => lang('Export'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button').''; } - - $var = Array( - 'action_url_button' => $this->page('export','&cal_id='.$cal_id), - 'action_text_button' => lang('Export'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button').''; } function edit($params='') @@ -2146,7 +2159,7 @@ $repeat_days .= $day.' '; } - function view_event($event) + function view_event($event,$alarms=False) { if(!$event['participants'][$this->bo->owner]) { @@ -2370,7 +2383,7 @@ $this->output_template_array($p,'row','list',$var[$i]); } - if(@isset($event['alarm'])) + if($alarms && @isset($event['alarm'])) { $p->set_var('hr_text','
'); $p->parse('row','hr',True);