This adds the bility to exclude individual events from a repeating event.

This commit is contained in:
skeeter 2001-11-05 02:08:31 +00:00
parent c5314f991b
commit 1f8ae0362f
9 changed files with 320 additions and 74 deletions

View File

@ -23,7 +23,8 @@
'update' => True,
'preferences' => True,
'store_to_cache' => True,
'export_event' => True
'export_event' => True,
'reinstate' => True
);
var $soap_functions = Array(
@ -366,6 +367,36 @@
}
}
function delete_single($param)
{
if($this->check_perms(PHPGW_ACL_DELETE))
{
$temp_event = $this->get_cached_event();
$event = $this->read_entry(intval($param['id']));
if($this->owner == $event['owner'])
{
$exception_time = mktime($event['start']['hour'],$event['start']['min'],0,$param['month'],$param['day'],$param['year']) - $this->datetime->tz_offset;
$event['recur_exception'][] = intval($exception_time);
$this->so->cal->event = $event;
if($this->debug)
{
echo '<!-- exception time = '.$event['recur_exception'][count($event['recur_exception']) -1].' -->'."\n";
echo '<!-- count event exceptions = '.count($event['recur_exception']).' -->'."\n";
}
$this->so->add_entry($event);
$cd = 16;
}
else
{
$cd = 60;
}
}
$this->so->cal->event = $temp_event;
unset($temp_event);
return $cd;
}
function delete_entry($id)
{
if($this->check_perms(PHPGW_ACL_DELETE))
@ -384,6 +415,52 @@
return $cd;
}
function reinstate($params='')
{
if($this->check_perms(PHPGW_ACL_EDIT) && isset($params['cal_id']) && isset($params['reinstate_index']))
{
$event = $this->so->read_entry($params['cal_id']);
@reset($params['reinstate_index']);
echo '<!-- Count of reinstate_index = '.count($params['reinstate_index']).' -->'."\n";
if(count($params['reinstate_index']) > 1)
{
while(list($key,$value) = each($params['reinstate_index']))
{
if($this->debug)
{
echo '<!-- reinstate_index ['.$key.'] = '.intval($value).' -->'."\n";
echo '<!-- exception time = '.$event['recur_exception'][intval($value)].' -->'."\n";
}
unset($event['recur_exception'][intval($value)]);
if($this->debug)
{
echo '<!-- count event exceptions = '.count($event['recur_exception']).' -->'."\n";
}
}
}
else
{
if($this->debug)
{
echo '<!-- reinstate_index [0] = '.intval($params['reinstate_index'][0]).' -->'."\n";
echo '<!-- exception time = '.$event['recur_exception'][intval($params['reinstate_index'][0])].' -->'."\n";
}
unset($event['recur_exception'][intval($params['reinstate_index'][0])]);
if($this->debug)
{
echo '<!-- count event exceptions = '.count($event['recur_exception']).' -->'."\n";
}
}
$this->so->cal->event = $event;
$this->so->add_entry($event);
return 42;
}
else
{
return 43;
}
}
function delete_calendar($owner)
{
if($GLOBALS['phpgw_info']['user']['apps']['admin'])
@ -1169,6 +1246,24 @@
return $temp;
}
function get_exception_array($exception_str='')
{
$exception = Array();
if(strpos(' '.$exception_str,','))
{
$exceptions = explode(',',$exception_str);
for($exception_count=0;$exception_count<count($exceptions);$exception_count++)
{
$exception[] = intval($exceptions[$exception_count]);
}
}
elseif($exception_str != '')
{
$exception[] = intval($exception_str);
}
return $exception;
}
function build_time_for_display($fixed_time)
{
$time = $this->splittime($fixed_time);
@ -1185,7 +1280,19 @@
function sort_event($event,$date)
{
$inserted = False;
if($this->cached_events[$date])
if(isset($event['recur_exception']))
{
$event_time = mktime($event['start']['hour'],$event['start']['min'],0,intval(substr($date,4,2)),intval(substr($date,6,2)),intval(substr($date,0,4))) - $this->datetime->tz_offset;
while($inserted == False && list($key,$exception_time) = each($event['recur_exception']))
{
echo '<!-- checking exception datetime '.$exception_time.' to event datetime '.$event_time.' -->'."\n";
if($exception_time == $event_time)
{
$inserted = True;
}
}
}
if($this->cached_events[$date] && $inserted == False)
{
if($this->debug)

View File

@ -182,13 +182,13 @@ class socalendar__
return $this->fetch_event($this->event['id']);
}
function add_attribute($attribute,$value,$element='False')
function add_attribute($attribute,$value,$element='**(**')
{
if(is_array($value))
{
reset($value);
}
if($element!='False')
if($element!='**(**')
{
$this->event[$attribute][$element] = $value;
}

View File

@ -182,6 +182,18 @@ class socalendar_ extends socalendar__
echo 'Event ID#'.$this->event['id'].' : Enddate = '.$enddate."<br>\n";
}
$this->add_attribute('recur_data',$this->stream->f('recur_data'));
$exception_list = $this->stream->f('recur_exception');
$exceptions = Array();
if(strpos(' '.$exception_list,','))
{
$exceptions = explode(',',$exception_list);
}
elseif($exception_list != '')
{
$exceptions[]= $exception_list;
}
$this->add_attribute('recur_exception',$exceptions);
}
//Legacy Support
@ -513,10 +525,12 @@ class socalendar_ extends socalendar__
else
{
$this->stream->query('UPDATE phpgw_cal_repeats '
.'SET recur_type='.$event['recur_type'].', '
.'recur_enddate='.$end.', '
.'recur_data='.$event['recur_data'].', recur_interval='.$event['recur_interval'].' '
.'WHERE cal_id='.$event['id'],__LINE__,__FILE__);
. 'SET recur_type='.$event['recur_type'].', '
. 'recur_enddate='.$end.', '
. 'recur_data='.$event['recur_data'].', '
. 'recur_interval='.$event['recur_interval'].', '
. "recur_exception='".(count($event['recur_exception'])>1?implode(',',$event['recur_exception']):(count($event['recur_exception'])==1?$event['recur_exception'][0]:''))."' "
. 'WHERE cal_id='.$event['id'],__LINE__,__FILE__);
}
}
else

View File

@ -41,6 +41,8 @@
'view' => True,
'edit' => True,
'export' => True,
'reinstate_list' => True,
'reinstate' => True,
'add' => True,
'delete' => True,
'preferences' => True,
@ -249,7 +251,7 @@
$m = mktime(0,0,0,$this->bo->month,1,$this->bo->year);
if (!$this->bo->printer_firendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals']))
if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals']))
{
$minical_prev = $this->mini_calendar(
Array(
@ -551,6 +553,7 @@
if($ret_value == '<center>'.lang('You do not have permission to read this record!').'</center>')
{
echo '</center>'."\n";
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
@ -615,7 +618,7 @@
$var = Array(
'action_url_button' => $this->page('delete','&cal_id='.$cal_id),
'action_text_button' => lang('Delete Single'),
'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_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this single occurence ?\\n\\nThis will delete\\nthis entry for all users.")."')\"",
'action_extra_field' => '<input type="hidden" name="delete_type" value="single">'
);
$p->set_var($var);
@ -629,6 +632,18 @@
);
$p->set_var($var);
echo $p->fp('out','form_button');
if($event['recur_exception'])
{
$var = Array(
'action_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id),
'action_text_button' => lang('Reinstate'),
'action_confirm_button' => '',
'action_extra_field' => ''
);
$p->set_var($var);
echo $p->fp('out','form_button');
}
}
else
{
@ -722,6 +737,126 @@
echo nl2br(execmethod('calendar.boicalendar.export',$GLOBALS['HTTP_GET_VARS']['cal_id']));
}
function reinstate_list($params='')
{
if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
{
$this->no_edit();
}
elseif(!$this->bo->check_perms(PHPGW_ACL_ADD))
{
$this->index();
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw']->common->phpgw_header();
echo '<center>';
$cal_id = (isset($params['cal_id'])?intval($params['cal_id']):'');
$cal_id = ($cal_id==''?intval($GLOBALS['HTTP_GET_VARS']['cal_id']):$cal_id);
if ($cal_id < 1)
{
echo lang('Invalid entry id.').'</center>'."\n";
$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!').'</center>'."\n";
$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').'.'.'</center>'."\n";
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
elseif(!isset($event['recur_exception']))
{
echo lang('Sorry, this event does not have exceptions defined').'.'.'</center>'."\n";
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
$ret_value = $this->view_event($event,True);
echo $ret_value;
if($ret_value == '<center>'.lang('You do not have permission to read this record!').'</center>')
{
echo '</center>'."\n";
$GLOBALS['phpgw']->common->phpgw_exit(True);
}
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'form_button' => 'form_button_script.tpl'
)
);
$str = '';
for($i=0;$i<count($event['recur_exception']);$i++)
{
$str .= ' <option value="'.$i.'">'.$GLOBALS['phpgw']->common->show_date($event['recur_exception'][$i]).'</option>'."\n";
}
$var = Array(
'action_url_button' => $this->page('reinstate','&cal_id='.$cal_id),
'action_text_button' => lang('Reinstate'),
'action_confirm_button' => '',
'action_extra_field' => "\n".' <select name="reinstate_index[]" multiple size="5">'."\n".$str.' </select>'
);
$p->set_var($var);
echo $p->fp('out','form_button');
$var = Array(
'action_url_button' => $this->page(''),
'action_text_button' => lang('Cancel'),
'action_confirm_button' => '',
'action_extra_field' => ''
);
$p->set_var($var);
echo $p->fp('out','form_button').'</center>';
}
function reinstate($params='')
{
if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
{
$this->no_edit();
}
elseif(!$this->bo->check_perms(PHPGW_ACL_ADD))
{
$this->index();
}
$cal_id = (isset($params['cal_id'])?intval($params['cal_id']):'');
$cal_id = ($cal_id==''?intval($GLOBALS['HTTP_GET_VARS']['cal_id']):$cal_id);
$reinstate_index = (isset($params['reinstate_index'])?intval($params['reinstate_index']):'');
$reinstate_index = ($reinstate_index==''?intval($GLOBALS['HTTP_POST_VARS']['reinstate_index']):$reinstate_index);
if($this->debug)
{
echo '<!-- Calling bo->reinstate -->'."\n";
}
$cd = $this->bo->reinstate(
Array(
'cal_id' => $cal_id,
'reinstate_index' => $reinstate_index
)
);
if($this->debug)
{
echo '<!-- Return Value = '.$cd.' -->'."\n";
}
Header('Location: '.$this->page('',($cd?'&cd='.$cd:'')));
$GLOBALS['phpgw']->common->phpgw_exit();
}
function add($cd=0,$readsess=0)
{
if(!$this->bo->check_perms(PHPGW_ACL_ADD))
@ -782,24 +917,30 @@
$GLOBALS['phpgw']->common->phpgw_exit();
}
$date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day);
$event = $this->bo->read_entry(intval($GLOBALS['HTTP_GET_VARS']['cal_id']));
if(($GLOBALS['HTTP_GET_VARS']['cal_id'] > 0) && ($event['owner'] == $this->bo->owner) && $this->bo->check_perms(PHPGW_ACL_DELETE))
{
$date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']);
if(isset($GLOBALS['HTTP_GET_VARS']['delete_type']) && $GLOBALS['HTTP_GET_VARS']['delete_type'] == 'delete_series')
if(isset($GLOBALS['HTTP_POST_VARS']['delete_type']) && $GLOBALS['HTTP_POST_VARS']['delete_type'] == 'single')
{
$cd = $this->bo->delete_single(
Array(
'id' => intval($GLOBALS['HTTP_GET_VARS']['cal_id']),
'year' => $this->bo->year,
'month' => $this->bo->month,
'day' => $this->bo->day
)
);
}
elseif((isset($GLOBALS['HTTP_POST_VARS']['delete_type']) && $GLOBALS['HTTP_POST_VARS']['delete_type'] == 'series') || !isset($GLOBALS['HTTP_POST_VARS']['delete_type']))
{
$cd = $this->bo->delete_entry(intval($GLOBALS['HTTP_GET_VARS']['cal_id']));
$this->bo->expunge();
}
else
{
// Still need to create a function to handle the deletion of a single day in a repeating serires.
}
}
else
{
$date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day);
$cd = '';
}
Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:'')));
@ -810,7 +951,7 @@
{
$this->bo->read_holidays();
if (!$this->bo->printer_firendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals']))
if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals']))
{
$minical = $this->mini_calendar(
Array(
@ -852,10 +993,12 @@
'day_t' => 'day.tpl'
)
);
$p->set_block('day_t','day','day');
$p->set_block('day_t','day_event','day_event');
$var = Array(
'printer_friendly' => $printer,
'bg_text' => $GLOBALS['phpgw_info']['themem']['bg_text'],
'bg_text' => $GLOBALS['phpgw_info']['theme']['bg_text'],
'daily_events' => $this->print_day(
Array(
'year' => $this->bo->year,
@ -870,7 +1013,8 @@
);
$p->set_var($var);
$p->pparse('out','day_t');
$p->parse('day_events','day_event');
$p->pparse('out','day');
}
function edit_status()
@ -1611,6 +1755,16 @@
function css()
{
$GLOBALS['phpgw']->browser->browser();
if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA')
{
$time_width = (intval($this->bo->prefs['common']['time_format']) == 12?12:8);
}
else
{
$time_width = (intval($this->bo->prefs['common']['time_format']) == 12?10:7);
}
return 'A.minicalendar { color: #000000 }'."\n"
. ' A.bminicalendar { color: #336699; font-weight: bold; font-style: italic }'."\n"
. ' A.minicalendargrey { color: #999999 }'."\n"
@ -1618,7 +1772,9 @@
. ' A.minicalhol { color: #000000; background-color: '.$this->holiday_color.' }'."\n"
. ' A.bminicalhol { color: #336699; background-color: '.$this->holiday_color.'; font-weight: bold; font-style: italic }'."\n"
. ' A.minicalgreyhol { color: #999999; background-color: '.$this->holiday_color.' }'."\n"
. ' A.bminicalgreyhol { color: #999999; background-color: '.$this->holiday_color.'; font-weight: bold; font-style: italic }'."\n";
. ' A.bminicalgreyhol { color: #999999; background-color: '.$this->holiday_color.'; font-weight: bold; font-style: italic }'."\n"
. ' .event { color: '.$this->theme['bg_text'].'; font-family: '.$this->theme['font'].'; font-weight: 100; font-size: 80%; line-height: 110%; vertical-align: middle; }'."\n"
. ' .time { width: '.$time_width.'%; background-color: '.$this->theme['navbar_bg'].'; border-color: '.$this->theme['navbar_text'].'; border-width: 1; color: '.$this->theme['bg_text'].'; font-family: '.$this->theme['font'].'; font-size: 65%; line-height: 100%; vertical-align: middle; }'."\n";
}
function no_edit()
@ -2493,25 +2649,6 @@
echo "Interval set to : ".intval($this->bo->prefs['calendar']['interval'])."<br>\n";
}
$GLOBALS['phpgw']->browser->browser();
if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA')
{
$time_width = (intval($this->bo->prefs['common']['time_format']) == 12?12:8);
}
else
{
$time_width = (intval($this->bo->prefs['common']['time_format']) == 12?10:7);
}
$var = Array(
'time_width' => $time_width,
'time_bgcolor' => $this->theme['navbar_bg'],
'font_color' => $this->theme['bg_text'],
'time_border_color' => $this->theme['navbar_text'],
'font' => $this->theme['font']
);
$p->set_var($var);
for ($i=0;$i<24;$i++)
{
for($j=0;$j<(60 / intval($this->bo->prefs['calendar']['interval']));$j++)

View File

@ -13,7 +13,7 @@
$setup_info['calendar']['name'] = 'calendar';
$setup_info['calendar']['title'] = 'Calendar';
$setup_info['calendar']['version'] = '0.9.13.006';
$setup_info['calendar']['version'] = '0.9.13.007';
$setup_info['calendar']['app_order'] = 3;
$setup_info['calendar']['enable'] = 1;

View File

@ -59,6 +59,7 @@
'recur_enddate' => array('type' => 'int', 'precision' => 8, 'nullable' => True),
'recur_interval' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => 1),
'recur_data' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => 1)
'recur_exception' => array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => '')
),
'pk' => array(),
'fk' => array(),

View File

@ -897,4 +897,13 @@
$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.006';
return $GLOBALS['setup_info']['calendar']['currentver'];
}
$test[] = '0.9.13.006';
function calendar_upgrade0_9_13_006()
{
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cal_repeats','recur_exception',array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => ''));
$GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.007';
return $GLOBALS['setup_info']['calendar']['currentver'];
}
?>

View File

@ -1,4 +1,5 @@
<!-- $Id$ -->
<!-- BEGIN day -->
{printer_friendly}
<table border="0" width="100%">
<tr>
@ -13,12 +14,8 @@
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="{bg_text}">
{daily_events}
</td>
</tr>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="{bg_text}">
{day_events}
</table>
</td>
<td valign="top" align="right">
@ -29,4 +26,12 @@
</tr>
</table>
{print}
<!-- END day -->
<!-- BEGIN day_event -->
<tr>
<td>
{daily_events}
</td>
</tr>
<!-- END day_event -->

View File

@ -1,32 +1,5 @@
<!-- $Id$ -->
<!-- BEGIN day -->
<style type="text/css">
<!--
.event
{
color: {font_color};
font-family: {font};
font-weight: 100;
font-size: 80%;
line-height: 110%;
vertical-align: middle;
}
.time
{
width: {time_width}%;
background-color: {time_bgcolor};
border-color: {time_border_color};
border-width: 1;
color: {font_color};
font-family: {font};
font-size: 65%;
line-height: 100%;
vertical-align: middle;
}
-->
</style>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
{row}
</table>