diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index edbe8f630b..b307eee505 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -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 ''."\n"; + echo ''."\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 ''."\n"; + if(count($params['reinstate_index']) > 1) + { + while(list($key,$value) = each($params['reinstate_index'])) + { + if($this->debug) + { + echo ''."\n"; + echo ''."\n"; + } + unset($event['recur_exception'][intval($value)]); + if($this->debug) + { + echo ''."\n"; + } + } + } + else + { + if($this->debug) + { + echo ''."\n"; + echo ''."\n"; + } + unset($event['recur_exception'][intval($params['reinstate_index'][0])]); + if($this->debug) + { + echo ''."\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_countsplittime($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 ''."\n"; + if($exception_time == $event_time) + { + $inserted = True; + } + } + } + if($this->cached_events[$date] && $inserted == False) { if($this->debug) diff --git a/calendar/inc/class.socalendar__.inc.php b/calendar/inc/class.socalendar__.inc.php index 8e77c74af9..4a64fbd237 100755 --- a/calendar/inc/class.socalendar__.inc.php +++ b/calendar/inc/class.socalendar__.inc.php @@ -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; } diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index 0df121bc77..99cf396ebc 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -182,6 +182,18 @@ class socalendar_ extends socalendar__ echo 'Event ID#'.$this->event['id'].' : Enddate = '.$enddate."
\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 diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index e040020a68..ac2f3d0fe6 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -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 == '
'.lang('You do not have permission to read this record!').'
') { + echo ''."\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' => '' ); $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 '
'; + + $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.').'
'."\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!').''."\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').'.'.''."\n"; + $GLOBALS['phpgw']->common->phpgw_exit(True); + } + elseif(!isset($event['recur_exception'])) + { + echo lang('Sorry, this event does not have exceptions defined').'.'.''."\n"; + $GLOBALS['phpgw']->common->phpgw_exit(True); + } + + $ret_value = $this->view_event($event,True); + echo $ret_value; + + if($ret_value == '
'.lang('You do not have permission to read this record!').'
') + { + echo ''."\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'.$GLOBALS['phpgw']->common->show_date($event['recur_exception'][$i]).''."\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".' ' + ); + $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').''; + } + + 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 ''."\n"; + } + $cd = $this->bo->reinstate( + Array( + 'cal_id' => $cal_id, + 'reinstate_index' => $reinstate_index + ) + ); + if($this->debug) + { + echo ''."\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'])."
\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++) diff --git a/calendar/setup/setup.inc.php b/calendar/setup/setup.inc.php index a704419c61..b3bcbd09ba 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.006'; + $setup_info['calendar']['version'] = '0.9.13.007'; $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 8cf9217bb0..7f7f657a82 100644 --- a/calendar/setup/tables_current.inc.php +++ b/calendar/setup/tables_current.inc.php @@ -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(), diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index 282969ca0b..140085b7e1 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -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']; + } ?> diff --git a/calendar/templates/default/day.tpl b/calendar/templates/default/day.tpl index b7b9d13af4..32b1b0d7f1 100755 --- a/calendar/templates/default/day.tpl +++ b/calendar/templates/default/day.tpl @@ -1,4 +1,5 @@ + {printer_friendly} @@ -13,12 +14,8 @@
- - - - +
- {daily_events} -
+ {day_events}
@@ -29,4 +26,12 @@ {print} + + + + + {daily_events} + + + diff --git a/calendar/templates/default/day_cal.tpl b/calendar/templates/default/day_cal.tpl index 698ef51816..eb3423588e 100755 --- a/calendar/templates/default/day_cal.tpl +++ b/calendar/templates/default/day_cal.tpl @@ -1,32 +1,5 @@ - {row}