Index: inc/class.bocalendar.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/calendar/inc/class.bocalendar.inc.php,v retrieving revision 1.71 diff -u -r1.71 class.bocalendar.inc.php --- inc/class.bocalendar.inc.php 12 Jan 2002 01:33:40 -0000 1.71 +++ inc/class.bocalendar.inc.php 2 Mar 2002 03:47:36 -0000 @@ -1070,10 +1070,16 @@ // $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; // } // -// - $sql = 'AND ((('.$starttime.' <= phpgw_cal.datetime) AND ('.$endtime.' >= phpgw_cal.datetime) AND ('.$endtime.' <= phpgw_cal.edatetime)) ' -// . 'OR (('.$starttime.' >= phpgw_cal.datetime) AND ('.$starttime.' < phpgw_cal.edatetime) AND ('.$endtime.' >= phpgw_cal.edatetime)) ' -// - . 'OR (('.$starttime.' <= phpgw_cal.datetime) AND ('.$endtime.' >= phpgw_cal.edatetime)) ' -// - . 'OR (('.$starttime.' >= phpgw_cal.datetime) AND ('.$endtime.' <= phpgw_cal.edatetime))) '; +// - $sql = "AND ((('".$GLOBALS['phpgw']->db->to_timestamp($starttime)."' <= phpgw_cal.datetime) " +// . "AND ('".$GLOBALS['phpgw']->db->to_timestamp($endtime)."' >= phpgw_cal.datetime) " +// . "AND ('".$GLOBALS['phpgw']->db->to_timestamp($endtime)."' <= phpgw_cal.edatetime)) " +// . "OR (('".$GLOBALS['phpgw']->db->to_timestamp($starttime)."' >= phpgw_cal.datetime) " +// . "AND ('".$GLOBALS['phpgw']->db->to_timestamp($starttime)."' < phpgw_cal.edatetime) " +// . "AND ('".$GLOBALS['phpgw']->db->to_timestamp($endtime)."' >= phpgw_cal.edatetime)) " +// - . "OR (('".$GLOBALS['phpgw']->db->to_timestamp($starttime)."' <= phpgw_cal.datetime) " +// . "AND ('".$GLOBALS['phpgw']->db->to_timestamp($endtime)."' >= phpgw_cal.edatetime)) " +// - . "OR (('".$GLOBALS['phpgw']->db->to_timestamp($starttime)."' >= phpgw_cal.datetime) " +// . "AND ('".$GLOBALS['phpgw']->db->to_timestamp($endtime)."' <= phpgw_cal.edatetime))) "; // // if(count($participants) > 0) // { Index: inc/class.socalendar.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/calendar/inc/class.socalendar.inc.php,v retrieving revision 1.22.2.1 diff -u -r1.22.2.1 class.socalendar.inc.php --- inc/class.socalendar.inc.php 7 Feb 2002 02:14:01 -0000 1.22.2.1 +++ inc/class.socalendar.inc.php 2 Mar 2002 03:47:36 -0000 @@ -111,9 +111,15 @@ // } // @reset($member); // $sql .= ','.implode(',',$member).') '; -// $sql .= 'AND (phpgw_cal.datetime <= '.$starttime.') '; -// $sql .= 'AND (((phpgw_cal_repeats.recur_enddate >= '.$starttime.') AND (phpgw_cal_repeats.recur_enddate <= '.$endtime.')) OR (phpgw_cal_repeats.recur_enddate=0))) ' - $sql .= ') AND ((phpgw_cal_repeats.recur_enddate >= '.$starttime.') OR (phpgw_cal_repeats.recur_enddate=0))) ' +// $sql .= "AND (phpgw_cal.datetime <= '".$this->cal->stream->to_timestamp($starttime)."') "; +// $sql .= "AND (((phpgw_cal_repeats.recur_enddate >= '" +// . $this->cal->stream->to_timestamp($starttime)."') " +// . "AND (phpgw_cal_repeats.recur_enddate <= '" +// . $this->cal->stream->to_timestamp($endtime)."')) " +// . "OR (phpgw_cal_repeats.recur_enddate='".$this->cal->stream->to_timestamp(0)."'))) " + $sql .= ") AND ((phpgw_cal_repeats.recur_enddate >= '" + . $this->cal->stream->to_timestamp($starttime)."') " + . "OR (phpgw_cal_repeats.recur_enddate='".$this->cal->stream->to_timestamp(0)."'))) " . (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'') . ($this->cat_id?"AND phpgw_cal.category like '%".$this->cat_id."%' ":'') . 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC'; @@ -236,7 +242,7 @@ { while($this->cal->next_record()) { - $arr[] = intval($this->cal->f('datetime')); + $arr[] = intval($this->cal->from_timestamp($this->cal->f('datetime'))); } } if(count($arr) == 0) Index: inc/class.socalendar_sql.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/calendar/inc/class.socalendar_sql.inc.php,v retrieving revision 1.28 diff -u -r1.28 class.socalendar_sql.inc.php --- inc/class.socalendar_sql.inc.php 10 Jan 2002 02:15:33 -0000 1.28 +++ inc/class.socalendar_sql.inc.php 2 Mar 2002 03:47:36 -0000 @@ -129,13 +129,13 @@ // But until then, do it this way... //Legacy Support (New) - $datetime = $this->datetime->localdates($this->stream->f('datetime')); + $datetime = $this->datetime->localdates($this->stream->from_timestamp($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')); + $datetime = $this->datetime->localdates($this->stream->from_timestamp($this->stream->f('mdatetime'))); $this->set_date('modtime',$datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); - $datetime = $this->datetime->localdates($this->stream->f('edatetime')); + $datetime = $this->datetime->localdates($this->stream->from_timestamp($this->stream->f('edatetime'))); $this->set_end($datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); //Legacy Support @@ -156,7 +156,7 @@ $this->add_attribute('recur_type',intval($this->stream->f('recur_type'))); $this->add_attribute('recur_interval',intval($this->stream->f('recur_interval'))); - $enddate = $this->stream->f('recur_enddate'); + $enddate = $this->stream->from_timestamp($this->stream->f('recur_enddate')); if($enddate != 0 && $enddate != Null) { $datetime = $this->datetime->localdates($enddate); @@ -276,21 +276,21 @@ echo '<!-- '.$user_where.' -->'."\n"; } - $startDate = 'AND ( ( (phpgw_cal.datetime >= '.$datetime.') '; + $startDate = "AND ( ( (phpgw_cal.datetime >= '".$this->stream->to_timestamp($datetime)."') "; $enddate = ''; if($endYear != 0 && $endMonth != 0 && $endDay != 0) { $edatetime = mktime(23,59,59,intval($endMonth),intval($endDay),intval($endYear)) - $tz_offset; - $endDate .= 'AND (phpgw_cal.edatetime <= '.$edatetime.') ) ' - . 'OR ( (phpgw_cal.datetime <= '.$datetime.') ' - . 'AND (phpgw_cal.edatetime >= '.$edatetime.') ) ' - . 'OR ( (phpgw_cal.datetime >= '.$datetime.') ' - . 'AND (phpgw_cal.datetime <= '.$edatetime.') ' - . 'AND (phpgw_cal.edatetime >= '.$edatetime.') ) ' - . 'OR ( (phpgw_cal.datetime <= '.$datetime.') ' - . 'AND (phpgw_cal.edatetime >= '.$datetime.') ' - . 'AND (phpgw_cal.edatetime <= '.$edatetime.') '; + $endDate .= "AND (phpgw_cal.edatetime <= '".$this->stream->to_timestamp($edatetime)."') ) " + . "OR ( (phpgw_cal.datetime <= '".$this->stream->to_timestamp($datetime)."') " + . "AND (phpgw_cal.edatetime >= '".$this->stream->to_timestamp($edatetime)."') ) " + . "OR ( (phpgw_cal.datetime >= '".$this->stream->to_timestamp($datetime)."') " + . "AND (phpgw_cal.datetime <= '".$this->stream->to_timestamp($edatetime)."') " + . "AND (phpgw_cal.edatetime >= '".$this->stream->to_timestamp($edatetime)."') ) " + . "OR ( (phpgw_cal.datetime <= '".$this->stream->to_timestamp($datetime)."') " + . "AND (phpgw_cal.edatetime >= '".$this->stream->to_timestamp($datetime)."') " + . "AND (phpgw_cal.edatetime <= '".$this->stream->to_timestamp($edatetime)."') "; } $endDate .= ') ) '; @@ -474,9 +474,9 @@ $sql = 'UPDATE phpgw_cal SET ' . 'owner='.$event['owner'].', ' - . 'datetime='.$date.', ' - . 'mdatetime='.$today.', ' - . 'edatetime='.$enddate.', ' + . "datetime='".$this->stream->to_timestamp($date)."', " + . "mdatetime='".$this->stream->to_timestamp($today)."', " + . "edatetime='".$this->stream->to_timestamp($enddate)."', " . 'priority='.$event['priority'].', ' . "category='".$event['category']."', " . "cal_type='".$type."', " @@ -520,13 +520,13 @@ if($num_rows == 0) { $this->stream->query('INSERT INTO phpgw_cal_repeats(cal_id,recur_type,recur_enddate,recur_data,recur_interval) ' - .'VALUES('.$event['id'].','.$event['recur_type'].','.$end.','.$event['recur_data'].','.$event['recur_interval'].')',__LINE__,__FILE__); + .'VALUES('.$event['id'].','.$event['recur_type'].",'".$this->stream->to_timestamp($end)."',".$event['recur_data'].','.$event['recur_interval'].')',__LINE__,__FILE__); } else { $this->stream->query('UPDATE phpgw_cal_repeats ' . 'SET recur_type='.$event['recur_type'].', ' - . 'recur_enddate='.$end.', ' + . "recur_enddate='".$this->stream->to_timestamp($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]:''))."' " Index: setup/setup.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/calendar/setup/setup.inc.php,v retrieving revision 1.15 diff -u -r1.15 setup.inc.php --- setup/setup.inc.php 7 Jan 2002 10:50:42 -0000 1.15 +++ setup/setup.inc.php 2 Mar 2002 03:47:36 -0000 @@ -13,7 +13,7 @@ $setup_info['calendar']['name'] = 'calendar'; $setup_info['calendar']['title'] = 'Calendar'; - $setup_info['calendar']['version'] = '0.9.13.007'; + $setup_info['calendar']['version'] = '0.9.13.008'; $setup_info['calendar']['app_order'] = 3; $setup_info['calendar']['enable'] = 1; Index: setup/tables_current.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/calendar/setup/tables_current.inc.php,v retrieving revision 1.13 diff -u -r1.13 tables_current.inc.php --- setup/tables_current.inc.php 5 Nov 2001 18:17:41 -0000 1.13 +++ setup/tables_current.inc.php 2 Mar 2002 03:47:36 -0000 @@ -19,9 +19,9 @@ 'owner' => array('type' => 'int', 'precision' => 8,'nullable' => False), 'category' => array('type' => 'varchar', 'precision' => 30,'nullable' => True), 'groups' => array('type' => 'varchar', 'precision' => 255,'nullable' => True), - 'datetime' => array('type' => 'int', 'precision' => 8,'nullable' => True), - 'mdatetime' => array('type' => 'int', 'precision' => 8,'nullable' => True), - 'edatetime' => array('type' => 'int', 'precision' => 8,'nullable' => True), + 'datetime' => array('type' => 'timestamp','nullable' => True), + 'mdatetime' => array('type' => 'timestamp','nullable' => True), + 'edatetime' => array('type' => 'timestamp','nullable' => True), 'priority' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 2), 'cal_type' => array('type' => 'varchar', 'precision' => 10,'nullable' => True), 'is_public' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 1), @@ -56,7 +56,7 @@ 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), 'recur_type' => array('type' => 'int', 'precision' => 8, 'nullable' => False), 'recur_use_end' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => 0), - 'recur_enddate' => array('type' => 'int', 'precision' => 8, 'nullable' => True), + 'recur_enddate' => array('type' => 'timestamp', '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' => '') Index: setup/tables_update.inc.php =================================================================== RCS file: /cvsroot/phpgroupware/calendar/setup/tables_update.inc.php,v retrieving revision 1.21.2.1 diff -u -r1.21.2.1 tables_update.inc.php --- setup/tables_update.inc.php 19 Jan 2002 18:36:14 -0000 1.21.2.1 +++ setup/tables_update.inc.php 2 Mar 2002 03:47:36 -0000 @@ -913,4 +913,145 @@ $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.007'; return $GLOBALS['setup_info']['calendar']['currentver']; } + + $test[] = '0.9.13.007'; + function calendar_upgrade0_9_13_007() + { + $calendar_data = Array(); + $GLOBALS['phpgw_setup']->oProc->query('SELECT cal_id, datetime, mdatetime, edatetime FROM phpgw_cal',__LINE__,__FILE__); + while($GLOBALS['phpgw_setup']->oProc->next_record()) + { + $calendar_data[$GLOBALS['phpgw_setup']->oProc->f('cal_id')]['datetime'] = $GLOBALS['phpgw_setup']->oProc->f('datetime'); + $calendar_data[$GLOBALS['phpgw_setup']->oProc->f('cal_id')]['mdatetime'] = $GLOBALS['phpgw_setup']->oProc->f('mdatetime'); + $calendar_data[$GLOBALS['phpgw_setup']->oProc->f('cal_id')]['edatetime'] = $GLOBALS['phpgw_setup']->oProc->f('edatetime'); + } + + $GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_cal', 'datetime', 'datetime_old'); + $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cal','datetime',array('type' => 'timestamp', 'nullable' => True)); + $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_cal',array( + 'fd' => array( + 'cal_id' => array('type' => 'auto','nullable' => False), + 'uid' => array('type' => 'varchar', 'precision' => 255,'nullable' => False), + 'owner' => array('type' => 'int', 'precision' => 8,'nullable' => False), + 'category' => array('type' => 'varchar', 'precision' => 30,'nullable' => True), + 'groups' => array('type' => 'varchar', 'precision' => 255,'nullable' => True), + 'datetime' => array('type' => 'timestamp','nullable' => True), + 'mdatetime_old' => array('type' => 'int', 'precision' => 8,'nullable' => True), + 'edatetime_old' => array('type' => 'int', 'precision' => 8,'nullable' => True), + 'priority' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 2), + '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), + 'location' => array('type' => 'varchar', 'precision' => 255,'nullable' => True), + 'reference' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => 0) + ), + 'pk' => array('cal_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ),'datetime_old'); + + $GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_cal', 'mdatetime', 'mdatetime_old'); + $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cal','mdatetime',array('type' => 'timestamp', 'nullable' => True)); + $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_cal',array( + 'fd' => array( + 'cal_id' => array('type' => 'auto','nullable' => False), + 'uid' => array('type' => 'varchar', 'precision' => 255,'nullable' => False), + 'owner' => array('type' => 'int', 'precision' => 8,'nullable' => False), + 'category' => array('type' => 'varchar', 'precision' => 30,'nullable' => True), + 'groups' => array('type' => 'varchar', 'precision' => 255,'nullable' => True), + 'datetime' => array('type' => 'timestamp','nullable' => True), + 'mdatetime' => array('type' => 'timestamp','nullable' => True), + 'edatetime_old' => array('type' => 'int', 'precision' => 8,'nullable' => True), + 'priority' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 2), + '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), + 'location' => array('type' => 'varchar', 'precision' => 255,'nullable' => True), + 'reference' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => 0) + ), + 'pk' => array('cal_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ),'mdatetime_old'); + + $GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_cal', 'edatetime', 'edatetime_old'); + $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cal','edatetime',array('type' => 'timestamp', 'nullable' => True)); + $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_cal',array( + 'fd' => array( + 'cal_id' => array('type' => 'auto','nullable' => False), + 'uid' => array('type' => 'varchar', 'precision' => 255,'nullable' => False), + 'owner' => array('type' => 'int', 'precision' => 8,'nullable' => False), + 'category' => array('type' => 'varchar', 'precision' => 30,'nullable' => True), + 'groups' => array('type' => 'varchar', 'precision' => 255,'nullable' => True), + 'datetime' => array('type' => 'timestamp','nullable' => True), + 'mdatetime' => array('type' => 'timestamp','nullable' => True), + 'edatetime' => array('type' => 'timestamp','nullable' => True), + 'priority' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 2), + '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), + 'location' => array('type' => 'varchar', 'precision' => 255,'nullable' => True), + 'reference' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => 0) + ), + 'pk' => array('cal_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ),'edatetime_old'); + + @reset($calendar_data); + while($calendar_data && list($cal_id,$calendar_row) = each($calendar_data)) + { + $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_cal SET datetime='" + .$GLOBALS['phpgw_setup']->db->to_timestamp($calendar_row['datetime']) + ."' WHERE cal_id=".$cal_id,__LINE__,__FILE__); + $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_cal SET mdatetime='" + .$GLOBALS['phpgw_setup']->db->to_timestamp($calendar_row['mdatetime']) + ."' WHERE cal_id=".$cal_id,__LINE__,__FILE__); + $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_cal SET edatetime='" + .$GLOBALS['phpgw_setup']->db->to_timestamp($calendar_row['edatetime']) + ."' WHERE cal_id=".$cal_id,__LINE__,__FILE__); + } + + $repeat_data = Array(); + $GLOBALS['phpgw_setup']->oProc->query('SELECT cal_id, recur_enddate FROM phpgw_cal_repeats',__LINE__,__FILE__); + while($GLOBALS['phpgw_setup']->oProc->next_record()) + { + $repeat_data[$GLOBALS['phpgw_setup']->oProc->f('cal_id')] = $GLOBALS['phpgw_setup']->oProc->f('recur_enddate'); + } + + $GLOBALS['phpgw_setup']->oProc->RenameColumn('phpgw_cal_repeats', 'recur_enddate', 'recur_enddate_old'); + $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cal_repeats','recur_enddate',array('type' => 'timestamp', 'nullable' => True)); + $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_cal_repeats',array( + 'fd' => array( + 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), + 'recur_type' => array('type' => 'int', 'precision' => 8, 'nullable' => False), + 'recur_use_end' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => 0), + 'recur_enddate' => array('type' => 'timestamp', '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(), + 'ix' => array(), + 'uc' => array() + ),'recur_enddate_old'); + + @reset($repeat_data); + while($repeat_data && list($cal_id,$recur_enddate) = each($repeat_data)) + { + $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_cal_repeats SET recur_enddate='" + .$GLOBALS['phpgw_setup']->db->to_timestamp($recur_enddate) + ."' WHERE cal_id=".$cal_id,__LINE__,__FILE__); + } + + $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.008'; + return $GLOBALS['setup_info']['calendar']['currentver']; + } ?>