From 0cde39204de39f4881d6daea4e92912674c1c291 Mon Sep 17 00:00:00 2001 From: skeeter Date: Sat, 8 Sep 2001 08:48:38 +0000 Subject: [PATCH] Backend work for processing alarms. --- calendar/inc/class.bocalendar.inc.php | 39 +++++++++++++++++++++-- calendar/inc/class.socalendar_sql.inc.php | 9 +++--- calendar/inc/class.uicalendar.inc.php | 26 +++++++++++---- calendar/setup/setup.inc.php | 2 +- calendar/setup/tables_current.inc.php | 3 +- calendar/setup/tables_update.inc.php | 9 ++++++ 6 files changed, 73 insertions(+), 15 deletions(-) diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index d95d185233..f8cfdc2e0a 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -439,8 +439,8 @@ $this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0); $this->so->set_end($l_end['year'],$l_end['month'],$l_end['mday'],$l_end['hour'],$l_end['min'],0); $this->so->set_class($is_public); - $this->so->add_attribute('reference',($l_cal['reference']?$l_cal['reference']:0)); - $this->so->add_attribute('location',($l_cal['location']?$l_cal['location']:'')); + $this->so->add_attribute('reference',(@isset($l_cal['reference']) && $l_cal['reference']?$l_cal['reference']:0)); + $this->so->add_attribute('location',(@isset($l_cal['location']) && $l_cal['location']?$l_cal['location']:'')); if($l_cal['id']) { $this->so->add_attribute('id',$l_cal['id']); @@ -1826,6 +1826,41 @@ return $this->so->get_alarm($event_id); } + function alarm_today($event,$today,$starttime) + { + $found = False; + @reset($event['alarm']); + $starttime_hi = $GLOBALS['phpgw']->common->show_date($starttime,'Hi'); + $t_appt['month'] =$GLOBALS['phpgw']->common->show_date($today,'m'); + $t_appt['mday'] = $GLOBALS['phpgw']->common->show_date($today,'d'); + $t_appt['year'] = $GLOBALS['phpgw']->common->show_date($today,'Y'); + $t_appt['hour'] = $GLOBALS['phpgw']->common->show_date($starttime,'H'); + $t_appt['min'] = $GLOBALS['phpgw']->common->show_date($starttime,'i'); + $t_appt['sec'] = 0; + $t_time = $this->maketime($t_appt) - $this->datetime->tz_offset; + $y_time = $t_time - 86400; + $tt_time = $t_time + 86399; +//echo 'T_TIME : '.$t_time."
\n"; +//echo 'Y_TIME : '.$y_time."
\n"; +//echo 'TT_TIME : '.$tt_time."
\n"; + while(list($key,$alarm) = each($event['alarm'])) + { +//echo 'TIME : '.$alarm['time']."
\n"; + if($event['recur_type'] != MCAL_RECUR_NONE) /* Recurring Event */ + { + if($alarm['time'] > $y_time && $GLOBALS['phpgw']->common->show_date($alarm['time'],'Hi') < $starttime_hi && $alarm['time'] < $t_time) + { + $found = True; + } + } + elseif($GLOBALS['phpgw']->common->show_date($alarm['time'],'Hi') < $starttime_hi) + { + $found = True; + } + } + return $found; + } + function prepare_recipients(&$new_event,$old_event) { // Find modified and deleted users..... diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index f6611688d0..c98a517bb2 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -128,16 +128,13 @@ class socalendar_ extends socalendar__ //$this->event->alarm = intval($this->stream->f('alarm')); // But until then, do it this way... //Legacy Support (New) - $this->set_alarm(0); -// $this->add_attribute('datetime',intval($this->stream->f('datetime'))); $datetime = $this->datetime->localdates($this->stream->f('datetime')); $this->set_start($datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); $datetime = $this->datetime->localdates($this->stream->f('mdatetime')); $this->set_date('modtime',$datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); -// $this->add_attribute('edatetime',intval($this->stream->f('edatetime'))); $datetime = $this->datetime->localdates($this->stream->f('edatetime')); $this->set_end($datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); @@ -206,7 +203,11 @@ class socalendar_ extends socalendar__ { while($this->stream->next_record()) { - $this->add_attribute('alarm',$this->stream->f('cal_text'),intval($this->stream->f('cal_time'))); + $this->event['alarm'][] = Array( + 'time' => intval($this->stream->f('cal_time')), + 'text' => $this->stream->f('cal_text'), + 'enabled' => intval($this->stream->f('alarm_enabled')) + ); } } } diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 97d42186b9..6bb3e6a2c6 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -1657,7 +1657,18 @@ 'height' => 13 ); } - + if(@isset($event['alarm']) && count($event['alarm']) >= 1) + { + if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) + { + $picture[] = Array( + 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm.gif'), + 'width' => 13, + 'height' => 13 + ); + } + } + $description = $this->bo->get_short_field($event,$is_private,'description'); for($i=0;$ioutput_template_array($p,'row','list',$var[$i]); } - if($alarms = $this->bo->get_alarms($event['id'])) + if(@isset($event['alarm'])) { $p->set_var('hr_text','
'); $p->parse('row','hr',True); $p->set_var('hr_text','
'.lang('Alarms').'

'); $p->parse('row','hr',True); - @reset($alarms); - while(list($time,$text) = each($alarms)) + @reset($event['alarm']); + while(list($key,$alarm) = each($event['alarm'])) { + $icon = ''; $var = Array( - 'field' => $GLOBALS['phpgw']->common->show_date($time), - 'data' => $text + 'field' => $icon.$GLOBALS['phpgw']->common->show_date($alarm['time']), + 'data' => $alarm['text'] ); $this->output_template_array($p,'row','list',$var); } @@ -2809,7 +2821,7 @@ . ''."\n" . ''."\n" . ($GLOBALS['HTTP_GET_VARS']['cal_id'] && $event['id'] == 0?''."\n": - ($event['reference']?''."\n":'')), + (@isset($event['reference'])?''."\n":'')), 'errormsg' => ($params['cd']?$GLOBALS['phpgw']->common->check_code($params['cd']):'') ); $p->set_var($vars); diff --git a/calendar/setup/setup.inc.php b/calendar/setup/setup.inc.php index ba3eb5701d..85daed7b17 100755 --- a/calendar/setup/setup.inc.php +++ b/calendar/setup/setup.inc.php @@ -13,7 +13,7 @@ $setup_info['calendar']['name'] = 'calendar'; $setup_info['calendar']['title'] = 'Calendar'; - $setup_info['calendar']['version'] = '0.9.13.004'; + $setup_info['calendar']['version'] = '0.9.13.005'; $setup_info['calendar']['app_order'] = 3; $setup_info['calendar']['enable'] = 1; diff --git a/calendar/setup/tables_current.inc.php b/calendar/setup/tables_current.inc.php index 1867d3b281..1a39c40fbd 100644 --- a/calendar/setup/tables_current.inc.php +++ b/calendar/setup/tables_current.inc.php @@ -82,7 +82,8 @@ 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), 'cal_owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False), 'cal_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False), - 'cal_text' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False) + 'cal_text' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), + 'alarm_enabled' => array('type' => 'int', 'precision' => 4, 'nullable' => False, 'default' => '1') ), 'pk' => array('alarm_id'), 'fk' => array(), diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index f2d29e6c5e..49826868b7 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -868,4 +868,13 @@ $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.004'; return $GLOBALS['setup_info']['calendar']['currentver']; } + + $test[] = '0.9.13.004'; + function calendar_upgrade0_9_13_004() + { + $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cal_alarm','alarm_enabled',array('type' => 'int', 'precision' => 4,'nullable' => False, 'default' => '1')); + + $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.005'; + return $GLOBALS['setup_info']['calendar']['currentver']; + } ?>