diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index 546ae9401f..d55d6048a2 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -340,15 +340,14 @@ return $this->so->list_events_keyword($keywords); } - function update($p_cal=0,$p_participants=0,$p_start=0,$p_end=0,$p_recur_enddata=0) + function update($params) { - global $HTTP_POST_VARS, $HTTP_GET_VARS; - - $l_cal = ($p_cal?$p_cal:$HTTP_POST_VARS['cal']); - $l_participants = ($p_participants?$p_participants:$HTTP_POST_VARS['participants']); - $l_start = ($p_start?$p_start:$HTTP_POST_VARS['start']); - $l_end = ($p_end?$p_end:$HTTP_POST_VARS['end']); - $l_recur_enddate = ($p_recur_enddate?$p_recur_enddate:$HTTP_POST_VARS['recur_enddate']); + $l_cal = ($params['cal']?$params['cal']:$GLOBALS['HTTP_POST_VARS']['cal']); + $l_participants = ($params['participants']?$params['participants']:$GLOBALS['HTTP_POST_VARS']['participants']); + $l_start = ($params['start']?$params['start']:$GLOBALS['HTTP_POST_VARS']['start']); + $l_end = ($params['end']?$params['end']:$GLOBALS['HTTP_POST_VARS']['end']); + $l_recur_enddate = ($params['recur_enddate']?$params['recur_enddate']:$GLOBALS['HTTP_POST_VARS']['recur_enddate']); + $l_reference = ($params['reference']?$params['reference']:$GLOBALS['HTTP_POST_VARS']['reference']); $send_to_ui = True; if($p_cal || $p_participants || $p_start || $p_end || $p_recur_enddata) @@ -405,6 +404,7 @@ $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_reference?$l_reference:0)); if($l_cal['id']) { $this->so->add_attribute('id',$l_cal['id']); @@ -508,12 +508,22 @@ ); } + $event_ids = Array(); + if($event['id']) + { + $event_ids[] = $event['id']; + } + if($event['reference']) + { + $event_ids[] = $event['reference']; + } + $overlapping_events = $this->overlap( $this->maketime($event['start']) - $this->datetime->tz_offset, $this->maketime($event['end']) - $this->datetime->tz_offset, $event['participants'], $event['owner'], - $event['id'] + $event_ids ); } @@ -651,6 +661,7 @@ $retval = Array(); $ok = False; +/* This needs some attention.. by commenting this chunk of code it will fix bug #444265 */ if($starttime == $endtime && $GLOBALS['phpgw']->common->show_date($starttime,'Hi') == 0) { $endtime = mktime(23,59,59,$GLOBALS['phpgw']->common->show_date($starttime,'m'),$GLOBALS['phpgw']->common->show_date($starttime,'d') + 1,$GLOBALS['phpgw']->common->show_date($starttime,'Y')) - $this->datetime->tz_offset; @@ -673,7 +684,7 @@ } if($users) { - $p_g .= 'phpgw_cal_user.cal_login in ('.implode(',',$users).')'; + $p_g .= 'phpgw_cal_user.cal_login IN ('.implode(',',$users).')'; } } if($p_g) @@ -684,7 +695,8 @@ if($id) { - $sql .= ' AND phpgw_cal.cal_id <> '.$id; + @reset($id); + $sql .= ' AND phpgw_cal.cal_id NOT IN ('.(count($id)==1?$id[0]:implode(',',$id)).')'; } $sql .= ' ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC'; @@ -945,7 +957,7 @@ for($i=0;$icached_events[$date]);$i++) { $events = $this->cached_events[$date][$i]; - if($this->cached_events[$date][$i]['id'] == $event['id']) + if($this->cached_events[$date][$i]['id'] == $event['id'] || $this->cached_events[$date][$i]['reference'] == $event['id']) { if($this->debug) { @@ -1195,16 +1207,16 @@ { $c_evt_day = 0; } -// if($this->debug) -// { -// echo "Date: ".$j." Count : ".$c_evt_day."
\n"; -// } + if($this->debug) + { + echo "Date: ".$j." Count : ".$c_evt_day."
\n"; + } if($this->cached_events[$j][$c_evt_day]['id'] != $event['id']) { -// if($this->debug) -// { -// echo "Adding Event for Date: ".$j."
\n"; -// } + if($this->debug) + { + echo "Adding Event for Date: ".$j."
\n"; + } $this->cached_events[$j][] = $event; } } @@ -1228,7 +1240,10 @@ $retval = Array(); for($j=date('Ymd',mktime(0,0,0,$smonth,$sday,$syear)),$k=0;$j<=date('Ymd',mktime(0,0,0,$emonth,$eday,$eyear));$k++,$j=date('Ymd',mktime(0,0,0,$smonth,$sday + $k,$syear))) { - $retval[$j] = $this->cached_events[$j]; + if(is_array($this->cached_events[$j])) + { + $retval[$j] = $this->cached_events[$j]; + } } return $retval; // return $this->cached_events; diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index 16a3ca1c16..79417ede82 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -115,6 +115,7 @@ class socalendar_ extends socalendar__ $this->set_category(intval($this->stream->f('category'))); $this->set_title($GLOBALS['phpgw']->strip_html($this->stream->f('title'))); $this->set_description($GLOBALS['phpgw']->strip_html($this->stream->f('description'))); + $this->add_attribute('reference',intval($this->stream->f('reference'))); // This is the preferred method once everything is normalized... //$this->event->alarm = intval($this->stream->f('alarm')); @@ -392,7 +393,8 @@ class socalendar_ extends socalendar__ . "cal_type='".$type."', " . 'is_public='.$event['public'].', ' . "title='".addslashes($event['title'])."', " - . "description='".addslashes($event['description'])."' " + . "description='".addslashes($event['description'])."', " + . 'reference='.$event['reference'].' ' . 'WHERE cal_id='.$event['id']; $this->stream->query($sql,__LINE__,__FILE__); diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 932f3b5ddc..48dc7379cd 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -512,14 +512,37 @@ 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'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $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' => '' + ); + $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'); + } } if ($this->bo->check_perms(PHPGW_ACL_DELETE)) @@ -539,8 +562,6 @@ function edit($params='') { - global $HTTP_GET_VARS; - if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) { $this->no_edit(); @@ -557,16 +578,32 @@ ) ); } - elseif(isset($HTTP_GET_VARS['cal_id'])) + elseif(isset($GLOBALS['HTTP_GET_VARS']['cal_id'])) { - $cal_id = $HTTP_GET_VARS['cal_id']; - $event = $this->bo->read_entry(intval($HTTP_GET_VARS['cal_id'])); + $cal_id = $GLOBALS['HTTP_GET_VARS']['cal_id']; + $event = $this->bo->read_entry(intval($GLOBALS['HTTP_GET_VARS']['cal_id'])); $can_edit = $this->bo->can_user_edit($event); if(!$can_edit) { - $this->view(intval($HTTP_GET_VAR['cal_id'])); + $this->view(intval($GLOBALS['HTTP_GET_VARS']['cal_id'])); + } + if(@isset($GLOBALS['HTTP_POST_VARS']['edit_type']) && $GLOBALS['HTTP_POST_VARS']['edit_type'] == 'single') + { + $event['id'] = 0; + $event['start']['month'] = $this->bo->month; + $event['start']['mday'] = $this->bo->day; + $event['start']['year'] = $this->bo->year; + $event['end']['month'] = $this->bo->month; + $event['end']['mday'] = $this->bo->day; + $event['end']['year'] = $this->bo->year; + $event['recur_type'] = MCAL_RECUR_NONE; + $event['recur_interval'] = 0; + $event['recur_data'] = 0; + $event['recur_enddate']['month'] = 0; + $event['recur_enddate']['mday'] = 0; + $event['recur_enddate']['year'] = 0; } $this->edit_form( Array( @@ -1521,7 +1558,8 @@ if ($editable) { - $p->set_var('link_link',$this->page('view','&cal_id='.$event['id'])); + $date = sprintf('%04d%02d%02d',$year,$month,$day); + $p->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date)); $p->set_var('lang_view',lang('View this entry')); $p->parse('picture','link_open',True); @@ -2681,7 +2719,8 @@ 'calendar_action' => ($event['id']?lang('Calendar - Edit'):lang('Calendar - Add')), 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), 'common_hidden' => ''."\n" - . ''."\n", + . ''."\n" + . ($GLOBALS['HTTP_GET_VARS']['cal_id'] && $event['id'] == 0?''."\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 af7841a4c5..413405be25 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.002'; + $setup_info['calendar']['version'] = '0.9.13.003'; $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 364daa6aff..44f43503ea 100644 --- a/calendar/setup/tables_current.inc.php +++ b/calendar/setup/tables_current.inc.php @@ -25,7 +25,8 @@ 'cal_type' => array('type' => 'varchar', 'precision' => 10,'nullable' => True), 'is_public' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 1), 'title' => array('type' => 'varchar', 'precision' => 80,'nullable' => False,'default' => '1'), - 'description' => array('type' => 'text','nullable' => True) + 'description' => array('type' => 'text','nullable' => True), + 'reference' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => 0) ), 'pk' => array('cal_id'), 'fk' => array(), diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index 03ff03ad54..ba725b0391 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -892,6 +892,7 @@ $setup_info['calendar']['currentver'] = '0.9.11.011'; return $setup_info['calendar']['currentver']; } + $test[] = '0.9.11.011'; function calendar_upgrade0_9_11_011() { @@ -906,4 +907,16 @@ $setup_info['calendar']['currentver'] = '0.9.13.002'; return $setup_info['calendar']['currentver']; } + + $test[] = '0.9.13.002'; + function calendar_upgrade0_9_13_002() + { + global $setup_info, $phpgw_setup; + + $phpgw_setup->oProc->AddColumn('phpgw_cal','reference',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); + + $setup_info['calendar']['currentver'] = '0.9.13.003'; + return $setup_info['calendar']['currentver']; + } + ?>