new calendar tables/structures and new code

This commit is contained in:
skeeter 2000-12-01 03:36:39 +00:00
parent 2dacbb8e21
commit 5656ae3514
12 changed files with 297 additions and 148 deletions

View File

@ -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 = "<select name=\"day\">";
for ($i = 1; $i <= 31; $i++)
$day_html .= "<option value=\"$i\"" . ($i == $cal_info->day ? " selected" : "") . ">$i"
. "</option>\n";
$day_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->datetime,"d")) ? " selected" : "") . ">$i</option>\n";
$day_html .= "</select>";
$month_html = "<select name=\"month\">";
for ($i = 1; $i <= 12; $i++) {
$m = lang(date("F", mktime(0,0,0,$i,1,$cal_info->year)));
$month_html .= "<option value=\"$i\"" . ($i == $cal_info->month ? " selected" : "") . ">$m"
. "</option>\n";
$m = lang(date("F",mktime(0,0,0,$i,1,2000)));
$month_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->datetime,"n")) ? " selected" : "") . ">$m</option>\n";
}
$month_html .= "</select>";
$year_html = "<select name=\"year\">";
for ($i = ($cal_info->year - 1); $i < ($cal_info->year + 5); $i++) {
$year_html .= "<option value=\"$i\"" . ($i == $cal_info->year ? " selected" : "") . ">$i"
. "</option>\n";
for ($i = (intval($phpgw->common->show_date($cal_info->datetime,"Y")) - 1); $i < (intval($phpgw->common->show_date($cal_info->datetime,"Y")) + 5); $i++) {
$year_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->datetime,"Y")) ? " selected" : "") . ">$i</option>\n";
}
$year_html .= "</select>";
@ -156,7 +135,7 @@
$amsel = "checked"; $pmsel = "";
}
}
$str = "<input name=\"hour\" size=\"2\" VALUE=\"".$cal_info->hour."\" maxlength=\"2\">:<input name=\"minute\" size=\"2\" value=\"".((int)$cal_info->minute>=0 && (int)$cal_info->minute<=9?"0".(int)$cal_info->minute:$cal_info->minute)."\" maxlength=\"2\">";
$str = "<input name=\"hour\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->datetime,"H")."\" maxlength=\"2\">:<input name=\"minute\" size=\"2\" value=\"".$phpgw->common->show_date($cal_info->datetime,"i")."\" maxlength=\"2\">";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$str .= "<input type=\"radio\" name=\"ampm\" value=\"am\" $amsel>am";
$str .= "<input type=\"radio\" name=\"ampm\" value=\"pm\" $pmsel>pm";
@ -195,7 +174,7 @@
if ($cal_info->access == "public") $str .= " selected";
$str .= ">".lang("Global Public")."</option>";
$str .= "<option value=\"group\"";
if ($cal_info->access == "public" || !strlen($cal_info->access)) $str .= " selected";
if ($cal_info->access == "group" || !strlen($cal_info->access)) $str .= " selected";
$str .= ">".lang("Group Public")."</option>";
$str .= "</select>";
$phpgw->template->set_var("data",$str);
@ -203,12 +182,16 @@
// Groups
$phpgw->template->set_var("field",lang("Groups"));
$str = "<select name=\"n_groups[]\" multiple size=\"5\">";
$str = "<select name=\"groups[]\" multiple size=\"5\">";
$user_groups = $phpgw->accounts->read_group_names();
for ($i=0;$i<count($user_groups);$i++) {
$str .= "<option value=\"" . $user_groups[$i][0] . "\"";
if (ereg(",".$user_groups[$i][0].",",$cal_info->groups))
for($j=0;$j<count($cal_info->groups);$j++) {
if ($user_groups[$i][0] == $cal_info->groups[$j]) {
$str .= " selected";
break;
}
}
$str .= ">" . $user_groups[$i][1] . "</option>";
}
$str .= "</select>";
@ -277,26 +260,25 @@
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("field",lang("Repeat End Date"));
$str = "<input type=\"checkbox\" name=\"rpt_end_use\" value=\"y\"";
if($cal_info->rpt_end_use) $str .= " checked";
$str = "<input type=\"checkbox\" name=\"rpt_use_end\" value=\"y\"";
if($cal_info->rpt_use_end) $str .= " checked";
$str .= ">".lang("Use End Date")." ";
$day_html = "<select name=\"rpt_day\">";
for($i=1;$i<=31;$i++) {
$day_html .= "<option value=\"$i\"".($i == $cal_info->rpt_day ? " selected" : "").">$i</option>\n";
}
for ($i = 1; $i <= 31; $i++)
$day_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->rpt_end,"d")) ? " selected" : "") . ">$i</option>\n";
$day_html .= "</select>";
$month_html = "<select name=\"rpt_month\">";
for ($i = 1; $i <= 12; $i++) {
$m = lang(date("F", mktime(0,0,0,$i,1,$cal_info->rpt_year)));
$month_html .= "<option value=\"$i\"".($i == $cal_info->rpt_month ? " selected" : "").">$m</option>\n";
$m = lang($phpgw->common->show_date($cal_info->rpt_end,"F"));
$month_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->rpt_end,"n")) ? " selected" : "") . ">$m</option>\n";
}
$month_html .= "</select>";
$year_html = "<select name=\"rpt_year\">";
for ($i = ($cal_info->rpt_year - 1); $i < ($cal_info->rpt_year + 5); $i++) {
$year_html .= "<option value=\"$i\"".($i == $cal_info->rpt_year ? " selected" : "").">$i</option>\n";
for ($i = (intval($phpgw->common->show_date($cal_info->rpt_end,"Y")) - 1); $i < (intval($phpgw->common->show_date($cal_info->rpt_end,"Y")) + 5); $i++) {
$year_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->rpt_end,"Y")) ? " selected" : "") . ">$i</option>\n";
}
$year_html .= "</select>";
@ -305,13 +287,13 @@
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("field",lang("Repeat Day")."<br>".lang("(for weekly)"));
$str = "<input type=\"checkbox\" name=\"rpt_sun\" value=\"y\"".($cal_info->rpt_sun?"checked":"")."> ".lang("Sunday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_mon\" value=\"y\"".($cal_info->rpt_mon?"checked":"")."> ".lang("Monday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_tue\" value=\"y\"".($cal_info->rpt_tue?"checked":"")."> ".lang("Tuesday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_wed\" value=\"y\"".($cal_info->rpt_wed?"checked":"")."> ".lang("Wednesday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_thu\" value=\"y\"".($cal_info->rpt_thu?"checked":"")."> ".lang("Thursday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_fri\" value=\"y\"".($cal_info->rpt_fri?"checked":"")."> ".lang("Friday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_sat\" value=\"y\"".($cal_info->rpt_sat?"checked":"")."> ".lang("Saturday")." ";
$str = "<input type=\"checkbox\" name=\"rpt_sun\" value=\"1\"".($cal_info->rpt_sun?"checked":"")."> ".lang("Sunday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_mon\" value=\"1\"".($cal_info->rpt_mon?"checked":"")."> ".lang("Monday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_tue\" value=\"1\"".($cal_info->rpt_tue?"checked":"")."> ".lang("Tuesday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_wed\" value=\"1\"".($cal_info->rpt_wed?"checked":"")."> ".lang("Wednesday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_thu\" value=\"1\"".($cal_info->rpt_thu?"checked":"")."> ".lang("Thursday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_fri\" value=\"1\"".($cal_info->rpt_fri?"checked":"")."> ".lang("Friday")." ";
$str .= "<input type=\"checkbox\" name=\"rpt_sat\" value=\"1\"".($cal_info->rpt_sat?"checked":"")."> ".lang("Saturday")." ";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);

View File

@ -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);

View File

@ -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();

View File

@ -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 .= "<br>";
$cal_grps .= $cal_groups[$i];
for($i=0;$i<count($cal_info->groups);$i++) {
if($i>0) $cal_grps .= "<br>";
$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;

View File

@ -29,7 +29,7 @@
?>
<center>
<table border="0" cellspacing="4" cellpadding="4">
<table border="0" cellspacing="3" cellpadding="4">
<tr>
<?php
if (!$friendly)

View File

@ -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."')");

View File

@ -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."')");

View File

@ -173,47 +173,40 @@
)";
$db->query($sql);
$sql = "CREATE TABLE webcal_entry (
$sql = "CREATE TABLE calendar_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_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',
cal_priority int(11) DEFAULT '2' NOT NULL,
cal_type varchar(10),
cal_access char(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 (
$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,

View File

@ -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();
}
*/
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Upgrade from $oldversion to $currentver is completed.</td>\n";
echo " </tr>\n";

View File

@ -151,45 +151,38 @@
)";
$db->query($sql);
$sql = "CREATE TABLE webcal_entry (
$sql = "CREATE TABLE calendar_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,
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_description text
)";
$db->query($sql);
$sql = "CREATE TABLE webcal_entry_user (
cal_id int,
cal_login varchar(25) NOT NULL,
$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_id int DEFAULT 0 NOT NULL,
cal_type varchar(20),
cal_end int,
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)
)";
$db->query($sql);
$sql = "CREATE TABLE newsgroups (
con serial,
name varchar(255) NOT NULL,

View File

@ -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();
}
*/
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Upgrade from $oldversion to $currentver is completed.</td>\n";
echo " </tr>\n";

View File

@ -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";