Backend work for processing alarms.

This commit is contained in:
skeeter 2001-09-08 08:48:38 +00:00
parent d5fa717e18
commit 0cde39204d
6 changed files with 73 additions and 15 deletions

View File

@ -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."<br>\n";
//echo 'Y_TIME : '.$y_time."<br>\n";
//echo 'TT_TIME : '.$tt_time."<br>\n";
while(list($key,$alarm) = each($event['alarm']))
{
//echo 'TIME : '.$alarm['time']."<br>\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.....

View File

@ -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'))
);
}
}
}

View File

@ -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;$i<count($picture);$i++)
{
@ -2273,19 +2284,20 @@
$this->output_template_array($p,'row','list',$var[$i]);
}
if($alarms = $this->bo->get_alarms($event['id']))
if(@isset($event['alarm']))
{
$p->set_var('hr_text','<hr>');
$p->parse('row','hr',True);
$p->set_var('hr_text','<center><b>'.lang('Alarms').'</b></center><br>');
$p->parse('row','hr',True);
@reset($alarms);
while(list($time,$text) = each($alarms))
@reset($event['alarm']);
while(list($key,$alarm) = each($event['alarm']))
{
$icon = '<img src="'.$GLOBALS['phpgw']->common->image('calendar',($alarm['enabled']?'enabled.gif':'disabled.gif')).'" width="13" height="13">';
$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 @@
. '<input type="hidden" name="cal[owner]" value="'.$this->bo->owner.'">'."\n"
. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n"
. ($GLOBALS['HTTP_GET_VARS']['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$GLOBALS['HTTP_GET_VARS']['cal_id'].'">'."\n":
($event['reference']?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')),
(@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":'')),
'errormsg' => ($params['cd']?$GLOBALS['phpgw']->common->check_code($params['cd']):'')
);
$p->set_var($vars);

View File

@ -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;

View File

@ -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(),

View File

@ -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'];
}
?>