From 5656ae3514407a6d821750a29b3df79467e33cb2 Mon Sep 17 00:00:00 2001 From: skeeter Date: Fri, 1 Dec 2000 03:36:39 +0000 Subject: [PATCH] new calendar tables/structures and new code --- calendar/edit_entry.php | 84 +++++++--------- calendar/edit_entry_handler.php | 1 + calendar/templates/default/edit.tpl | 4 +- calendar/view.php | 53 ++++++----- calendar/year.php | 2 +- setup/sql/default_applications.inc.php | 4 +- setup/sql/default_applications_plus.inc.php | 4 +- setup/sql/mysql_newtables.inc.php | 49 ++++------ setup/sql/mysql_upgrade_beta.inc.php | 100 ++++++++++++++++++-- setup/sql/pgsql_newtables.inc.php | 47 ++++----- setup/sql/pgsql_upgrade_beta.inc.php | 95 +++++++++++++++++-- version.inc.php | 2 +- 12 files changed, 297 insertions(+), 148 deletions(-) diff --git a/calendar/edit_entry.php b/calendar/edit_entry.php index 049af059f1..fdc97194db 100755 --- a/calendar/edit_entry.php +++ b/calendar/edit_entry.php @@ -29,10 +29,7 @@ $can_edit = true; if(!$cal_info->rpt_end_use) { - $rpt_date = $phpgw->calendar->splitdate(mktime(0,0,0,$cal_info->month,$cal_info->day + 1,$cal_info->year)); - $cal_info->rpt_year = $rpt_date["year"]; - $cal_info->rpt_month = $rpt_date["month"]; - $cal_info->rpt_day = $rpt_date["day"]; + $cal_info->rpt_end = $cal_info->datetime + 86400; } } else if(isset($readsess)) { $cal_info = $phpgw->common->appsession(); @@ -62,26 +59,11 @@ else $thisminute = (int)$minute; - $time = $phpgw->calendar->splittime($phpgw->calendar->fixtime($thishour,$thisminute)); - + $cal_info->datetime = gmmktime($thishour,$thisminute,0,$thismonth,$thisday,$thisyear); $cal_info->name = ""; $cal_info->description = ""; - $cal_info->day = $thisday; - $cal_info->month = $thismonth; - $cal_info->year = $thisyear; - - $cal_info->rpt_day = $thisday + 1; - $cal_info->rpt_month = $thismonth; - $cal_info->rpt_year = $thisyear; - - $cal_info->hour = (int)$time["hour"]; - $cal_info->minute = (!(int)$time["minute"]?"00":(int)$time["minute"]); - $cal_info->ampm = "am"; - if($cal_info->hour > 12 && $phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { - $cal_info["hour"] = $cal_info["hour"] - 12; - $cal_info["ampm"] = "pm"; - } + $cal_info->rpt_end = $cal_info->datetime + 86400; } $phpgw->template->set_file(array("edit_entry_begin" => "edit.tpl", @@ -123,22 +105,19 @@ $day_html = ""; $month_html = ""; $year_html = ""; @@ -156,7 +135,7 @@ $amsel = "checked"; $pmsel = ""; } } - $str = "hour."\" maxlength=\"2\">:minute>=0 && (int)$cal_info->minute<=9?"0".(int)$cal_info->minute:$cal_info->minute)."\" maxlength=\"2\">"; + $str = "common->show_date($cal_info->datetime,"H")."\" maxlength=\"2\">:common->show_date($cal_info->datetime,"i")."\" maxlength=\"2\">"; if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { $str .= "am"; $str .= "pm"; @@ -195,7 +174,7 @@ if ($cal_info->access == "public") $str .= " selected"; $str .= ">".lang("Global Public").""; $str .= ""; $str .= ""; $phpgw->template->set_var("data",$str); @@ -203,12 +182,16 @@ // Groups $phpgw->template->set_var("field",lang("Groups")); - $str = ""; $user_groups = $phpgw->accounts->read_group_names(); for ($i=0;$igroups)) - $str .= " selected"; + for($j=0;$jgroups);$j++) { + if ($user_groups[$i][0] == $cal_info->groups[$j]) { + $str .= " selected"; + break; + } + } $str .= ">" . $user_groups[$i][1] . ""; } $str .= ""; @@ -277,26 +260,25 @@ $phpgw->template->parse("output","list",True); $phpgw->template->set_var("field",lang("Repeat End Date")); - $str = "rpt_end_use) $str .= " checked"; + $str = "rpt_use_end) $str .= " checked"; $str .= ">".lang("Use End Date")." "; $day_html = ""; $month_html = ""; $year_html = ""; @@ -305,13 +287,13 @@ $phpgw->template->parse("output","list",True); $phpgw->template->set_var("field",lang("Repeat Day")."
".lang("(for weekly)")); - $str = "rpt_sun?"checked":"")."> ".lang("Sunday")." "; - $str .= "rpt_mon?"checked":"")."> ".lang("Monday")." "; - $str .= "rpt_tue?"checked":"")."> ".lang("Tuesday")." "; - $str .= "rpt_wed?"checked":"")."> ".lang("Wednesday")." "; - $str .= "rpt_thu?"checked":"")."> ".lang("Thursday")." "; - $str .= "rpt_fri?"checked":"")."> ".lang("Friday")." "; - $str .= "rpt_sat?"checked":"")."> ".lang("Saturday")." "; + $str = "rpt_sun?"checked":"")."> ".lang("Sunday")." "; + $str .= "rpt_mon?"checked":"")."> ".lang("Monday")." "; + $str .= "rpt_tue?"checked":"")."> ".lang("Tuesday")." "; + $str .= "rpt_wed?"checked":"")."> ".lang("Wednesday")." "; + $str .= "rpt_thu?"checked":"")."> ".lang("Thursday")." "; + $str .= "rpt_fri?"checked":"")."> ".lang("Friday")." "; + $str .= "rpt_sat?"checked":"")."> ".lang("Saturday")." "; $phpgw->template->set_var("data",$str); $phpgw->template->parse("output","list",True); diff --git a/calendar/edit_entry_handler.php b/calendar/edit_entry_handler.php index b7abd36db4..0a89b1a07c 100755 --- a/calendar/edit_entry_handler.php +++ b/calendar/edit_entry_handler.php @@ -19,6 +19,7 @@ $cal_info = new calendar_item; if(!isset($readsess)) { + $groups = Array(); for(reset($HTTP_POST_VARS);$key=key($HTTP_POST_VARS);next($HTTP_POST_VARS)) { $data = $HTTP_POST_VARS[$key]; $cal_info->set($key,$data); diff --git a/calendar/templates/default/edit.tpl b/calendar/templates/default/edit.tpl index cca98978f1..38480c5f29 100755 --- a/calendar/templates/default/edit.tpl +++ b/calendar/templates/default/edit.tpl @@ -11,13 +11,13 @@ function validate_and_submit() { } h = parseInt(document.addform.hour.value); m = parseInt(document.addform.minute.value); - if (h > 23) { + if (h < 0 || h > 23) { alert ("{time_error}"); document.addform.hour.select(); document.addform.hour.focus(); return false; } - if (m > 59) { + if (m < 0 || m > 59) { alert ("{time_error}"); document.addform.minute.select(); document.addform.minute.focus(); diff --git a/calendar/view.php b/calendar/view.php index d1bca6abbe..cb4410a9fa 100755 --- a/calendar/view.php +++ b/calendar/view.php @@ -21,9 +21,9 @@ exit; } - function add_day($repeat_days,$day) { + function add_day(&$repeat_days,$day) { if($repeat_days) $repeat_days .= ", "; - return $repeat_days . $day; + $repeat_days .= $day; } if ($year) $thisyear = $year; @@ -33,6 +33,8 @@ $pri[2] = lang("Medium"); $pri[3] = lang("High"); + $db = $phpgw->db; + $unapproved = FALSE; // first see who has access to view this entry @@ -66,7 +68,7 @@ } $phpgw->template->set_var("field",lang("Date")); - $phpgw->template->set_var("data",$phpgw->common->show_date(mktime(0,0,0,$cal_info->month,$cal_info->day,$cal_info->year),"l, F d, Y")); + $phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->datetime,$phpgw_info["user"]["preferences"]["common"]["dateformat"])); $phpgw->template->parse("output","list",True); // save date so the trailer links are for the same time period @@ -74,9 +76,14 @@ $thismonth = (int)$cal_info->month; $thisday = (int)$cal_info->day; - if($cal_info->hour || $cal_info->minute) { + if(intval($phpgw->common->show_date($cal_info->datetime,"H")) || intval($phpgw->common->show_date($cal_info->datetime,"i"))) { $phpgw->template->set_var("field",lang("Time")); - $phpgw->template->set_var("data",$phpgw->calendar->build_time_for_display($phpgw->calendar->fixtime($cal_info->hour,$cal_info->minute,$cal_info->ampm))); + if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { + $format .= "h:i:s a"; + } else { + $format .= "H:i:s"; + } + $phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->datetime,$format)); $phpgw->template->parse("output","list",True); } @@ -106,15 +113,16 @@ $phpgw->template->parse("output","list",True); $phpgw->template->set_var("field",lang("Updated")); - $phpgw->template->set_var("data",$phpgw->common->show_date(mktime(0,0,0,$cal_info->mod_month,$cal_info->mod_day,$cal_info->mod_year),"l, F d, Y")." ".$phpgw->calendar->build_time_for_display($phpgw->calendar->fixtime($cal_info->mod_hour,$cal_info->mod_minute,$cal_info->mod_ampm))); + $phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->mdatetime)); $phpgw->template->parse("output","list",True); - if($cal_info->groups) { - $cal_groups = explode(",",$phpgw->accounts->convert_string_to_names_access($cal_info->groups)); + if($cal_info->groups[0]) { $cal_grps = ""; - for($i=1;$i<=count($cal_groups);$i++) { - if($i>1) $cal_grps .= "
"; - $cal_grps .= $cal_groups[$i]; + for($i=0;$igroups);$i++) { + if($i>0) $cal_grps .= "
"; + $db->query("SELECT group_name FROM groups WHERE group_id=".$cal_info->groups[$i],__LINE__,__FILE__); + $db->next_record(); + $cal_grps .= $db->f("group_name"); } $phpgw->template->set_var("field",lang("Groups")); $phpgw->template->set_var("data",$cal_grps); @@ -132,25 +140,26 @@ // Repeated Events $str = $cal_info->rpt_type; - if($str <> "none" || ($cal_info->rpt_end_month && $cal_info->rpt_end_day && $cal_info->rpt_end_year)) { + if($str <> "none" || $cal_info->rpt_use_end) { $str .= " ("; - if($cal_info->rpt_end_month && $cal_info->rpt_end_day && $cal_info->rpt_end_year) - $str .= lang("ends").": ".$phpgw->common->show_date(mktime(0,0,0,$cal_info->rpt_end_month,$cal_info->rpt_end_day,$cal_info->rpt_end_year),"l, F d, Y")." "; - if($cal_info->rpt_type == "weekly") { + if($cal_info->rpt_use_end) + $str .= lang("ends").": ".$phpgw->common->show_date($cal_info->rpt_end,"l, F d, Y")." "; + if($cal_info->rpt_type == "weekly" || $cal_info->rpt_type == "daily") { + $repeat_days = ""; if ($cal_info->rpt_sun) - $repeat_days = add_day($repeat_days,lang("Sunday ")); + add_day(&$repeat_days,lang("Sunday ")); if ($cal_info->rpt_mon) - $repeat_days = add_day($repeat_days,lang("Monday ")); + add_day(&$repeat_days,lang("Monday ")); if ($cal_info->rpt_tue) - $repeat_days = add_day($repeat_days,lang("Tuesay ")); + add_day(&$repeat_days,lang("Tuesay ")); if ($cal_info->rpt_wed) - $repeat_days = add_day($repeat_days,lang("Wednesday ")); + add_day(&$repeat_days,lang("Wednesday ")); if ($cal_info->rpt_thu) - $repeat_days = add_day($repeat_days,lang("Thursday ")); + add_day(&$repeat_days,lang("Thursday ")); if ($cal_info->rpt_fri) - $repeat_days = add_day($repeat_days,lang("Friday ")); + add_day(&$repeat_days,lang("Friday ")); if ($cal_info->rpt_sat) - $repeat_days = add_day($repeat_days,lang("Saturday ")); + add_day(&$repeat_days,lang("Saturday ")); $str .= lang("days repeated").": ".$repeat_days; } if($cal_info->rpt_freq) $str .= lang("frequency")." ".$cal_info->rpt_freq; diff --git a/calendar/year.php b/calendar/year.php index 13bdd0c9b7..74c87f9c78 100755 --- a/calendar/year.php +++ b/calendar/year.php @@ -29,7 +29,7 @@ ?>
- +
query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('admin', 'Administration', 1, 1, NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('addressbook', 'Address Book', 1, 7, 'addressbook', '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('filemanager', 'File manager', 1, 6, NULL, '".$currentver."')"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('calendar', 'Calendar', 1, 9, 'webcal_entry,webcal_entry_users,webcal_entry_groups,webcal_repeats', '".$currentver."')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('calendar', 'Calendar', 1, 9, 'calendar_entry,calendar_entry_users,calendar_entry_repeats', '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('cron_apps', 'cron_apps', 0, 0, NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('email', 'Email', 1, 10,NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('nntp', 'NNTP', 1, 11, 'newsgroups', '".$currentver."')"); @@ -31,4 +31,4 @@ $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('weather', 'Weather', 1, 12, NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('bookmarks', 'Book Marks', 1, 15, NULL, '$currentver')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('manual', 'Manual', 1, 16, NULL, '$currentver')"); -?> \ No newline at end of file +?> diff --git a/setup/sql/default_applications_plus.inc.php b/setup/sql/default_applications_plus.inc.php index 6b6cc276d1..5c830fb938 100644 --- a/setup/sql/default_applications_plus.inc.php +++ b/setup/sql/default_applications_plus.inc.php @@ -16,7 +16,7 @@ $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('admin', 'Administration', 1, 1, NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('addressbook', 'Address Book', 1, 7, 'addressbook', '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('filemanager', 'File manager', 1, 6, NULL, '".$currentver."')"); - $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('calendar', 'Calendar', 1, 9, 'webcal_entry,webcal_entry_users,webcal_entry_groups,webcal_repeats', '".$currentver."')"); + $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('calendar', 'Calendar', 1, 9, 'calendar_entry,calendar_entry_users,calendar_entry_repeats', '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('cron_apps', 'cron_apps', 0, 0, NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('email', 'Email', 1, 10,NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('nntp', 'NNTP', 1, 11, 'newsgroups', '".$currentver."')"); @@ -31,4 +31,4 @@ $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('weather', 'Weather', 1, 12, NULL, '".$currentver."')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('bookmarks', 'Book Marks', 1, 15, NULL, '$currentver')"); $db->query("insert into applications (app_name, app_title, app_enabled, app_order, app_tables, app_version) values ('manual', 'Manual', 1, 16, NULL, '$currentver')"); -?> \ No newline at end of file +?> diff --git a/setup/sql/mysql_newtables.inc.php b/setup/sql/mysql_newtables.inc.php index db2f7c6ee6..bd6afc8df2 100644 --- a/setup/sql/mysql_newtables.inc.php +++ b/setup/sql/mysql_newtables.inc.php @@ -173,47 +173,40 @@ )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry ( - cal_id int(11) DEFAULT '0' NOT NULL auto_increment, - cal_group_id int(11), - cal_owner int(11) NOT NULL, - cal_date int(11) DEFAULT '0' NOT NULL, - cal_time int(11), - cal_mod_date int(11), - cal_mod_time int(11), - cal_duration int(11) DEFAULT '0' NOT NULL, - cal_priority int(11) DEFAULT '2', - cal_type varchar(10), - cal_access char(10), - cal_name varchar(80) NOT NULL, - cal_description text, + $sql = "CREATE TABLE calendar_entry ( + cal_id int(11) DEFAULT '0' NOT NULL auto_increment, + cal_owner int(11) DEFAULT '0' NOT NULL, + cal_group varchar(255), + cal_datetime int(11), + cal_mdatetime int(11), + cal_duration int(11) DEFAULT '0' NOT NULL, + cal_priority int(11) DEFAULT '2' NOT NULL, + cal_type varchar(10), + cal_access varchar(10), + cal_name varchar(80) NOT NULL, + cal_description text, PRIMARY KEY (cal_id) )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry_repeats ( - cal_id int(11) DEFAULT '0' NOT NULL, - cal_type enum('daily','weekly','monthlyByDay','monthlyByDate','yearly') DEFAULT 'daily' NOT NULL, - cal_end int(11), - cal_frequency int(11) DEFAULT '1', - cal_days char(7) + $sql = "CREATE TABLE calendar_entry_repeats ( + cal_id int(11) DEFAULT '0' NOT NULL, + cal_type enum('daily','weekly','monthlyByDay','monthlyByDate','yearly') DEFAULT 'daily' NOT NULL, + cal_use_end int DEFAULT '0', + cal_end int(11), + cal_frequency int(11) DEFAULT '1', + cal_days char(7) )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry_user ( + $sql = "CREATE TABLE calendar_entry_user ( cal_id int(11) DEFAULT '0' NOT NULL, - cal_login varchar(25) NOT NULL, + cal_login int(11) DEFAULT '0' NOT NULL, cal_status char(1) DEFAULT 'A', PRIMARY KEY (cal_id, cal_login) )"; $db->query($sql); - $sql = "create table webcal_entry_groups ( - cal_id int, - groups varchar(255) - )"; - $db->query($sql); - $sql = "CREATE TABLE newsgroups ( con int(11) NOT NULL auto_increment, name varchar(255) NOT NULL, diff --git a/setup/sql/mysql_upgrade_beta.inc.php b/setup/sql/mysql_upgrade_beta.inc.php index 2ade9b7797..4f2412b946 100644 --- a/setup/sql/mysql_upgrade_beta.inc.php +++ b/setup/sql/mysql_upgrade_beta.inc.php @@ -574,15 +574,103 @@ $currentver = "0.9.7pre1"; update_version_table(); } -/* if ($currentver == "0.9.7pre1") { - // upgrade code starts here + $db2 = $db; + $sql = "CREATE TABLE calendar_entry ( + cal_id int(11) DEFAULT '0' NOT NULL auto_increment, + cal_owner int(11) DEFAULT '0' NOT NULL, + cal_group varchar(255), + cal_datetime int(11), + cal_mdatetime int(11), + cal_duration int(11) DEFAULT '0' NOT NULL, + cal_priority int(11) DEFAULT '2' NOT NULL, + cal_type varchar(10), + cal_access varchar(10), + cal_name varchar(80) NOT NULL, + cal_description text, + PRIMARY KEY (cal_id) + )"; + $db->query($sql,__LINE__,__FILE__); + $db->query("SELECT count(*) FROM webcal_entry",__LINE__,__FILE__); + $db->next_record(); + if($db->f(0)) { + $db->query("SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id",__LINE__,__FILE__); + while($db->next_record()) { + $cal_id = $db->f("cal_id"); + $cal_owner = $db->f("cal_owner"); + $cal_duration = $db->f("cal_duration"); + $cal_priority = $db->f("cal_priority"); + $cal_type = $db->f("cal_type"); + $cal_access = $db->f("cal_access"); + $cal_name = $db->f("cal_name"); + $cal_description = $db->f("cal_description"); + $datetime = mktime(intval(strrev(substr(strrev($db->f("cal_time")),4))),intval(strrev(substr(strrev($db->f("cal_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_time")),0,2))),intval(substr($db->f("cal_date"),4,2)),intval(substr($db->f("cal_date"),6,2)),intval(substr($db->f("cal_date"),0,4))); + $moddatetime = mktime(intval(strrev(substr(strrev($db->f("cal_mod_time")),4))),intval(strrev(substr(strrev($db->f("cal_mod_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_mod_time")),0,2))),intval(substr($db->f("cal_mod_date"),4,2)),intval(substr($db->f("cal_mod_date"),6,2)),intval(substr($db->f("cal_mod_date"),0,4))); + $db2->query("SELECT groups FROM webcal_entry_groups WHERE cal_id=".$cal_id,__LINE__,__FILE__); + $db2->next_record(); + $cal_group = $db2->f("groups"); + $db2->query("INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) " + ."VALUES(".$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__); + } + } + $db->query("DROP TABLE webcal_entry_groups"); + $db->query("DROP TABLE webcal_entry"); + + $sql = "CREATE TABLE calendar_entry_user ( + cal_id int(11) DEFAULT '0' NOT NULL, + cal_login int(11) DEFAULT '0' NOT NULL, + cal_status char(1) DEFAULT 'A', + PRIMARY KEY (cal_id, cal_login) + )"; + $db->query($sql,__LINE__,__FILE__); + $db->query("SELECT count(*) FROM webcal_entry_user",__LINE__,__FILE__); + $db->next_record(); + if($db->f(0)) { + $db->query("SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id",__LINE__,__FILE__); + while($db->next_record()) { + $cal_id = $db->f("cal_id"); + $cal_login = $db->f("cal_login"); + $cal_status = $db->f("cal_status"); + $db2->query("INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES(".$cal_id.",".$cal_login.",'".$cal_status."')",__LINE__,__FILE__); + } + } + $db->query("DROP TABLE webcal_entry_user",__LINE__,__FILE__); + + $sql = "CREATE TABLE calendar_entry_repeats ( + cal_id int(11) DEFAULT 0 NOT NULL, + cal_type enum('daily','weekly','monthlyByDay','monthlyByDate','yearly') DEFAULT 'daily' NOT NULL, + cal_use_end int DEFAULT '0', + cal_end int(11), + cal_frequency int DEFAULT '1', + cal_days char(7) + )"; + $db->query($sql,__LINE__,__FILE__); + $db->query("SELECT count(*) FROM webcal_entry_repeats",__LINE__,__FILE__); + $db->next_record(); + if($db->f(0)) { + $db->query("SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id",__LINE__,__FILE__); + while($db->next_record()) { + $cal_id = $db->f("cal_id"); + $cal_type = $db->f("cal_type"); + if(isset($db->Record["cal_end"])) { + $enddate = mktime(0,0,0,intval(substr($db->f("cal_end"),4,2)),intval(substr($db->f("cal_end"),6,2)),intval(substr($db->f("cal_end"),0,4))); + $useend = 1; + } else { + $enddate = 0; + $useend = 0; + } + $cal_frequency = $db->f("cal_frequency"); + $cal_days = $db->f("cal_days"); + $db2->f("INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES(".$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__); + } + } + $db->query("DROP TABLE webcal_entry_repeats",__LINE__,__FILE__); + $db->query("UPDATE applications SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); - // upgrade code ends here $currentver = "0.9.7pre2"; - update_version_table(); + update_version_table(); } -*/ + echo " \n"; echo " \n"; echo " \n"; @@ -680,4 +768,4 @@ v0_9_7to0_9_8(); v0_9_8to0_9_9(); v0_9_9to0_9_10(); -?> \ No newline at end of file +?> diff --git a/setup/sql/pgsql_newtables.inc.php b/setup/sql/pgsql_newtables.inc.php index dacdb5ecb1..7d211cd416 100644 --- a/setup/sql/pgsql_newtables.inc.php +++ b/setup/sql/pgsql_newtables.inc.php @@ -151,42 +151,35 @@ )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry ( - cal_id serial, - cal_group_id int NULL, - cal_owner int NOT NULL, - cal_date int NOT NULL, - cal_time int NULL, - cal_mod_date int, - cal_mod_time int, - cal_duration int NOT NULL, + $sql = "CREATE TABLE calendar_entry ( + cal_id serial, + cal_owner int DEFAULT 0 NOT NULL, + cal_group varchar(255), + cal_datetime int4, + cal_mdatetime int4, + cal_duration int DEFAULT 0 NOT NULL, cal_priority int DEFAULT 2, - cal_type varchar(10), - cal_access varchar(10), - cal_name varchar(80) NOT NULL, - cal_description varchar(255) + cal_type varchar(10), + cal_access varchar(10), + cal_name varchar(80) NOT NULL, + cal_description text )"; $db->query($sql); - $sql = "CREATE TABLE webcal_entry_user ( - cal_id int, - cal_login varchar(25) NOT NULL, - cal_status char(1) DEFAULT 'A' + $sql = "CREATE TABLE calendar_entry_user ( + cal_id int DEFAULT 0 NOT NULL, + cal_login int DEFAULT 0 NOT NULL, + cal_status char(1) DEFAULT 'A' )"; $db->query($sql); $sql = "create table webcal_entry_repeats ( - cal_id int, - cal_type varchar(20), - cal_end int, + cal_id int DEFAULT 0 NOT NULL, + cal_type varchar(20), + cal_use_end int default 0, + cal_end int4, cal_frequency int default 1, - cal_days char(7) - )"; - $db->query($sql); - - $sql = "create table webcal_entry_groups ( - cal_id int, - groups varchar(255) + cal_days char(7) )"; $db->query($sql); diff --git a/setup/sql/pgsql_upgrade_beta.inc.php b/setup/sql/pgsql_upgrade_beta.inc.php index c3fec2edc4..343499c493 100644 --- a/setup/sql/pgsql_upgrade_beta.inc.php +++ b/setup/sql/pgsql_upgrade_beta.inc.php @@ -581,15 +581,98 @@ $currentver = "0.9.7pre1"; update_version_table(); } -/* if ($currentver == "0.9.7pre1") { - // upgrade code starts here + $db2 = $db; + $db3 = $db; + $sql = "CREATE TABLE calendar_entry ( + cal_id serial, + cal_owner int DEFAULT 0 NOT NULL, + cal_group varchar(255) NULL, + cal_datetime int4, + cal_mdatetime int4, + cal_duration int DEFAULT 0 NOT NULL, + cal_priority int DEFAULT 2, + cal_type varchar(10), + cal_access varchar(10), + cal_name varchar(80) NOT NULL, + cal_description text)"; + $db->query($sql,__LINE__,__FILE__); + $db->query("SELECT count(*) FROM webcal_entry",__LINE__,__FILE__); + $db->next_record(); + if($db->f(0)) { + $db->query("SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id",__LINE__,__FILE__); + while($db->next_record()) { + $cal_id = $db->f("cal_id"); + $cal_owner = $db->f("cal_owner"); + $cal_duration = $db->f("cal_duration"); + $cal_priority = $db->f("cal_priority"); + $cal_type = $db->f("cal_type"); + $cal_access = $db->f("cal_access"); + $cal_name = $db->f("cal_name"); + $cal_description = $db->f("cal_description"); + $datetime = mktime(intval(strrev(substr(strrev($db->f("cal_time")),4))),intval(strrev(substr(strrev($db->f("cal_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_time")),0,2))),intval(substr($db->f("cal_date"),4,2)),intval(substr($db->f("cal_date"),6,2)),intval(substr($db->f("cal_date"),0,4))); + $moddatetime = mktime(intval(strrev(substr(strrev($db->f("cal_mod_time")),4))),intval(strrev(substr(strrev($db->f("cal_mod_time")),2,2))),intval(strrev(substr(strrev($db->f("cal_mod_time")),0,2))),intval(substr($db->f("cal_mod_date"),4,2)),intval(substr($db->f("cal_mod_date"),6,2)),intval(substr($db->f("cal_mod_date"),0,4))); + $db2->query("SELECT groups FROM webcal_entry_groups WHERE cal_id=".$cal_id,__LINE__,__FILE__); + $db2->next_record(); + $cal_group = $db2->f("groups"); + $db2->query("INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) " + ."VALUES(".$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__); + } + } + $db->query("DROP TABLE webcal_entry_groups"); + $db->query("DROP TABLE webcal_entry"); + + $sql = "CREATE TABLE calendar_entry_user ( + cal_id int DEFAULT 0 NOT NULL, + cal_login int DEFAULT 0 NOT NULL, + cal_status char(1) DEFAULT 'A')"; + $db->query($sql,__LINE__,__FILE__); + $db->query("SELECT count(*) FROM webcal_entry_user",__LINE__,__FILE__); + $db->next_record(); + if($db->f(0)) { + $db->query("SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id",__LINE__,__FILE__); + while($db->next_record()) { + $cal_id = $db->f("cal_id"); + $cal_login = $db->f("cal_login"); + $cal_status = $db->f("cal_status"); + $db2->query("INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES(".$cal_id.",".$cal_login.",'".$cal_status."')",__LINE__,__FILE__); + } + } + $db->query("DROP TABLE webcal_entry_user",__LINE__,__FILE__); + + $sql = "CREATE TABLE calendar_entry_repeats ( + cal_id int DEFAULT 0 NOT NULL, + cal_type varchar(20), + cal_end int4, + cal_frequency int default 1, + cal_days char(7))"; + $db->query($sql,__LINE__,__FILE__); + $db->query("SELECT count(*) FROM webcal_entry_repeats",__LINE__,__FILE__); + $db->next_record(); + if($db->f(0)) { + $db->query("SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id",__LINE__,__FILE__); + while($db->next_record()) { + $cal_id = $db->f("cal_id"); + $cal_type = $db->f("cal_type"); + if(isset($db->Record["cal_end"])) { + $enddate = mktime(0,0,0,intval(substr($db->f("cal_end"),4,2)),intval(substr($db->f("cal_end"),6,2)),intval(substr($db->f("cal_end"),0,4))); + $useend = 1; + } else { + $enddate = 0; + $useend = 0; + } + $cal_frequency = $db->f("cal_frequency"); + $cal_days = $db->f("cal_days"); + $db2->f("INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES(".$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__); + } + } + $db->query("DROP TABLE webcal_entry_repeats",__LINE__,__FILE__); + $db->query("UPDATE applications SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); - // upgrade code ends here $currentver = "0.9.7pre2"; - update_version_table(); + update_version_table(); } -*/ + echo " \n"; echo " \n"; echo " \n"; @@ -687,4 +770,4 @@ v0_9_7to0_9_8(); v0_9_8to0_9_9(); v0_9_9to0_9_10(); -?> \ No newline at end of file +?> diff --git a/version.inc.php b/version.inc.php index e802d9d8a7..91d0787646 100644 --- a/version.inc.php +++ b/version.inc.php @@ -11,5 +11,5 @@ /* $Id$ */ - $phpgw_info["server"]["version"] = "0.9.7pre1"; + $phpgw_info["server"]["version"] = "0.9.7pre2"; $phpgw_info["server"]["current_header_version"] = "1.4";
Upgrade from $oldversion to $currentver is completed.
Upgrade from $oldversion to $currentver is completed.