various calendar fixes

This commit is contained in:
skeeter 2000-12-09 04:08:54 +00:00
parent 6720b21d68
commit 3bf10a62ee
5 changed files with 78 additions and 131 deletions

View File

@ -39,8 +39,10 @@
}
} else if(isset($readsess)) {
$cal_info = $phpgw->common->appsession();
if(!$cal_info->owner) $cal_info->owner = $phpgw_info["user"]["account_id"];
$can_edit = true;
} else {
$cal_info->id = 0;
$cal_info->owner = $phpgw_info["user"]["account_id"];
$can_edit = true;
@ -82,9 +84,6 @@
$phpgw->template->set_block("edit_entry_begin","list","edit_entry_end","form_button");
$phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]);
$phpgw->template->set_var("name_error",lang("You have not entered a\\nBrief Description").".");
$phpgw->template->set_var("time_error",lang("You have not entered a\\nvalid time of day."));
$phpgw->template->set_var("date_error",lang("You have not entered a\\nvalid date."));
if($id)
$phpgw->template->set_var("calendar_action",lang("Calendar - Edit"));
else
@ -93,7 +92,7 @@
if($can_edit) {
$phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php"));
$common_hidden = "<input type=\"hidden\" name=\"id\" value=\"".$cal_info->id."\">\n";
$common_hidden = "<input type=\"hidden\" name=\"cal[id]\" value=\"".$cal_info->id."\">\n";
$phpgw->template->set_var("common_hidden",$common_hidden);
@ -101,30 +100,30 @@
// Brief Description
$phpgw->template->set_var("field",lang("Brief Description"));
$phpgw->template->set_var("data","<input name=\"name\" size=\"25\" value=\"".$cal_info->name."\">");
$phpgw->template->set_var("data","<input name=\"cal[name]\" size=\"25\" value=\"".$cal_info->name."\">");
$phpgw->template->parse("output","list",True);
// Full Description
$phpgw->template->set_var("field",lang("Full Description"));
$phpgw->template->set_var("data","<textarea name=\"description\" rows=\"5\" cols=\"40\" wrap=\"virtual\">".$cal_info->description."</textarea>");
$phpgw->template->set_var("data","<textarea name=\"cal[description]\" rows=\"5\" cols=\"40\" wrap=\"virtual\">".$cal_info->description."</textarea>");
$phpgw->template->parse("output","list",True);
// Date
$phpgw->template->set_var("field",lang("Start Date"));
$day_html = "<select name=\"day\">";
$day_html = "<select name=\"cal[day]\">";
for ($i = 1; $i <= 31; $i++)
$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\">";
$month_html = "<select name=\"cal[month]\">";
for ($i = 1; $i <= 12; $i++) {
$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\">";
$year_html = "<select name=\"cal[year]\">";
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";
}
@ -144,10 +143,10 @@
$amsel = "checked"; $pmsel = "";
}
}
$str = "<input name=\"hour\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->datetime,$hourformat)."\" maxlength=\"2\">:<input name=\"minute\" size=\"2\" value=\"".$phpgw->common->show_date($cal_info->datetime,"i")."\" maxlength=\"2\">";
$str = "<input name=\"cal[hour]\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->datetime,$hourformat)."\" maxlength=\"2\">:<input name=\"cal[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";
$str .= "<input type=\"radio\" name=\"cal[ampm]\" value=\"am\" $amsel>am";
$str .= "<input type=\"radio\" name=\"cal[ampm]\" value=\"pm\" $pmsel>pm";
}
// End Date
@ -156,19 +155,19 @@
$phpgw->template->set_var("field",lang("End Date"));
$day_html = "<select name=\"end_day\">";
$day_html = "<select name=\"cal[end_day]\">";
for ($i = 1; $i <= 31; $i++)
$day_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->edatetime,"d")) ? " selected" : "") . ">$i</option>\n";
$day_html .= "</select>";
$month_html = "<select name=\"end_month\">";
$month_html = "<select name=\"cal[end_month]\">";
for ($i = 1; $i <= 12; $i++) {
$m = lang(date("F",mktime(0,0,0,$i,1,2000)));
$month_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->edatetime,"n")) ? " selected" : "") . ">$m</option>\n";
}
$month_html .= "</select>";
$year_html = "<select name=\"end_year\">";
$year_html = "<select name=\"cal[end_year]\">";
for ($i = (intval($phpgw->common->show_date($cal_info->edatetime,"Y")) - 1); $i < (intval($phpgw->common->show_date($cal_info->edatetime,"Y")) + 5); $i++) {
$year_html .= "<option value=\"$i\"" . ($i == intval($phpgw->common->show_date($cal_info->edatetime,"Y")) ? " selected" : "") . ">$i</option>\n";
}
@ -188,10 +187,10 @@
$amsel = "checked"; $pmsel = "";
}
}
$str = "<input name=\"end_hour\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->edatetime,$hourformat)."\" maxlength=\"2\">:<input name=\"end_minute\" size=\"2\" value=\"".$phpgw->common->show_date($cal_info->edatetime,"i")."\" maxlength=\"2\">";
$str = "<input name=\"cal[end_hour]\" size=\"2\" VALUE=\"".$phpgw->common->show_date($cal_info->edatetime,$hourformat)."\" maxlength=\"2\">:<input name=\"cal[end_minute]\" size=\"2\" value=\"".$phpgw->common->show_date($cal_info->edatetime,"i")."\" maxlength=\"2\">";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$str .= "<input type=\"radio\" name=\"end_ampm\" value=\"am\" $amsel>am";
$str .= "<input type=\"radio\" name=\"end_ampm\" value=\"pm\" $pmsel>pm";
$str .= "<input type=\"radio\" name=\"cal[end_ampm]\" value=\"am\" $amsel>am";
$str .= "<input type=\"radio\" name=\"cal[end_ampm]\" value=\"pm\" $pmsel>pm";
}
$phpgw->template->set_var("data",$str);
@ -199,7 +198,7 @@
// Priority
$phpgw->template->set_var("field",lang("Priority"));
$str = "<select name=\"priority\">";
$str = "<select name=\"cal[priority]\">";
$str .= "<option value=\"1\"";
if($cal_info->priority == 1) $str .= " selected";
$str .= ">".lang("Low")."</option>";
@ -214,7 +213,7 @@
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("field",lang("Access"));
$str = "<select name=\"access\">";
$str = "<select name=\"cal[access]\">";
$str .= "<option value=\"private\"";
if ($cal_info->access == "private" || ! $id) $str .= " selected";
$str .= ">".lang("Private")."</option>";
@ -230,7 +229,7 @@
// Groups
$phpgw->template->set_var("field",lang("Groups"));
$str = "<select name=\"groups[]\" multiple size=\"5\">";
$str = "<select name=\"cal[groups[]]\" multiple size=\"5\">";
$db2 = $phpgw->db;
$db2->query("SELECT account_lid FROM accounts WHERE account_id=".$cal_info->owner,__LINE__,__FILE__);
$db2->next_record();
@ -264,7 +263,7 @@
$size = 5;
else
$size = $db2->num_rows();
$str = "<select name=\"participants[]\" multiple size=\"5\">";
$str = "<select name=\"cal[participants[]]\" multiple size=\"5\">";
for ($l=0;$l<count($cal_info->participants);$l++)
$parts[$cal_info->participants[$l]] = True;
while ($db2->next_record()) {
@ -274,7 +273,7 @@
$str .= ">".$phpgw->common->grab_owner_name($db2->f("account_id"))."</option>";
}
$str .= "</select>";
// $str .= "<input type=\"hidden\" name=\"participants[]\" value=\"".$phpgw_info["user"]["account_id"]."\">";
// $str .= "<input type=\"hidden\" name=\"cal[participants][]\" value=\"".$phpgw_info["user"]["account_id"]."\">";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
@ -288,7 +287,7 @@
}
}
}
$str = "<input type=\"checkbox\" name=\"participants[]\" value=\"".$phpgw_info["user"]["account_id"]."\"";
$str = "<input type=\"checkbox\" name=\"cal[participants][]\" value=\"".$phpgw_info["user"]["account_id"]."\"";
if(($id && $participate) || !$id) {
$str .= " checked";
}
@ -298,7 +297,7 @@
// Repeat Type
$phpgw->template->set_var("field",lang("Repeat Type"));
$str = "<select name=\"rpt_type\">";
$str = "<select name=\"cal[rpt_type]\">";
$rpt_type_str = Array("none","daily","weekly","monthlybyday","monthlybydate","yearly");
$rpt_type_out = Array("none" => "None", "daily" => "Daily", "weekly" => "Weekly", "monthlybyday" => "Monthly (by day)", "monthlybydate" => "Monthly (by date)", "yearly" => "yearly");
for($l=0;$l<count($rpt_type_str);$l++) {
@ -311,23 +310,23 @@
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("field",lang("Repeat End Date"));
$str = "<input type=\"checkbox\" name=\"rpt_use_end\" value=\"y\"";
$str = "<input type=\"checkbox\" name=\"cal[rpt_use_end]\" value=\"y\"";
if($cal_info->rpt_use_end) $str .= " checked";
$str .= ">".lang("Use End Date")." ";
$day_html = "<select name=\"rpt_day\">";
$day_html = "<select name=\"cal[rpt_day]\">";
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\">";
$month_html = "<select name=\"cal[rpt_month]\">";
for ($i = 1; $i <= 12; $i++) {
$m = lang(date("F",mktime(0,0,0,$i,1,2000)));
$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\">";
$year_html = "<select name=\"cal[rpt_year]\">";
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";
}
@ -338,18 +337,18 @@
$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=\"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")." ";
$str = "<input type=\"checkbox\" name=\"cal[rpt_sun]\" value=\"1\"".($cal_info->rpt_sun?"checked":"")."> ".lang("Sunday")." ";
$str .= "<input type=\"checkbox\" name=\"cal[rpt_mon]\" value=\"1\"".($cal_info->rpt_mon?"checked":"")."> ".lang("Monday")." ";
$str .= "<input type=\"checkbox\" name=\"cal[rpt_tue]\" value=\"1\"".($cal_info->rpt_tue?"checked":"")."> ".lang("Tuesday")." ";
$str .= "<input type=\"checkbox\" name=\"cal[rpt_wed]\" value=\"1\"".($cal_info->rpt_wed?"checked":"")."> ".lang("Wednesday")." ";
$str .= "<input type=\"checkbox\" name=\"cal[rpt_thu]\" value=\"1\"".($cal_info->rpt_thu?"checked":"")."> ".lang("Thursday")." ";
$str .= "<input type=\"checkbox\" name=\"cal[rpt_fri]\" value=\"1\"".($cal_info->rpt_fri?"checked":"")."> ".lang("Friday")." ";
$str .= "<input type=\"checkbox\" name=\"cal[rpt_sat]\" value=\"1\"".($cal_info->rpt_sat?"checked":"")."> ".lang("Saturday")." ";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("field",lang("Frequency"));
$phpgw->template->set_var("data","<input name=\"rpt_freq\" size=\"4\" maxlength=\"4\" value=\"".$cal_info->rpt_freq."\">");
$phpgw->template->set_var("data","<input name=\"cal[rpt_freq]\" size=\"4\" maxlength=\"4\" value=\"".$cal_info->rpt_freq."\">");
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("submit_button",lang("Submit"));

View File

@ -18,10 +18,35 @@
$cal_info = new calendar_item;
function validate($cal_info) {
$error = 0;
// do a little form verifying
if ($cal_info->name == "") {
$error = 40;
} elseif (($cal_info->hour < 0 || $cal_info->hour > 23) || ($cal_info->end_hour < 0 || $cal_info->end_hour > 23)) {
$error = 41;
} elseif (($cal_info->minute < 0 || $cal_info->minute > 59) || ($cal_info->end_minute < 0 || $cal_info->minute > 59)) {
$error = 41;
} elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month == $cal_info->end_month) && ($cal_info->day == $cal_info->end_day)) {
if ($cal_info->hour > $cal_info->end_hour) {
$error = 42;
} elseif (($cal_info->hour == $cal_info->end_hour) && ($cal_info->minute > $cal_info->end_minute)) {
$error = 42;
}
} elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month == $cal_info->end_month) && ($cal_info->day > $cal_info->end_day)) {
$error = 42;
} elseif (($cal_info->year == $cal_info->end_year) && ($cal_info->month > $cal_info->end_month)) {
$error = 42;
} elseif ($cal_info->year > $cal_info->end_year) {
$error = 42;
}
return $error;
}
if(!isset($readsess)) {
$groups = Array();
for(reset($HTTP_POST_VARS);$key=key($HTTP_POST_VARS);next($HTTP_POST_VARS)) {
$data = $HTTP_POST_VARS[$key];
for(reset($cal);$key=key($cal);next($cal)) {
$data = $cal[$key];
$cal_info->set($key,$data);
}
@ -33,11 +58,15 @@
$cal_info->owner = $cal_info->participants[0];
}
$phpgw->common->appsession($cal_info);
$datetime_check = validate($cal_info);
$overlapping_events = $phpgw->calendar->overlap($cal_info->month,$cal_info->day,$cal_info->year,$cal_info->hour,$cal_info->minute,$cal_info->ampm,$cal_info->end_month,$cal_info->end_day,$cal_info->end_year,$cal_info->end_hour,$cal_info->end_minute,$cal_info->end_ampm,$cal_info->participants,$cal_info->owner,$cal_info->id);
} else {
$cal_info = $phpgw->common->appsession();
}
if($overlapping_events) {
if($datetime_check) {
Header("Location: ".$phpgw->link("edit_entry.php","readsess=".$cal_info->id."&cd=".$datetime_check));
} elseif($overlapping_events) {
$phpgw->common->phpgw_header();
$phpgw->common->navbar();
$phpgw->template->set_file(array("overlap" => "overlap.tpl",

View File

@ -1,87 +1,5 @@
<!-- $Id$ -->
<!-- BEGIN edit_entry_begin -->
<script language="JavaScript">
// do a little form verifying
function validate_and_submit() {
if (document.addform.name.value == "") {
alert("{name_error}");
document.addform.name.select();
document.addform.name.focus();
return false;
}
sh = parseInt(document.addform.hour.value);
sm = parseInt(document.addform.minute.value);
if (sh < 0 || sh > 23) {
alert ("{time_error}");
document.addform.hour.select();
document.addform.hour.focus();
return false;
}
if (sm < 0 || sm > 59) {
alert ("{time_error}");
document.addform.minute.select();
document.addform.minute.focus();
return false;
}
eh = parseInt(document.addform.end_hour.value);
em = parseInt(document.addform.end_minute.value);
if (eh < 0 || eh > 23) {
alert ("{time_error}");
document.addform.end_hour.select();
document.addform.end_hour.focus();
return false;
}
if (em < 0 || em > 59) {
alert ("{time_error}");
document.addform.end_minute.select();
document.addform.end_minute.focus();
return false;
}
// so = parseInt(document.addform.month.value);
// sd = parseInt(document.addform.day.value);
// sy = parseInt(document.addform.year.value);
// eo = parseInt(document.addform.end_month.value);
// ed = parseInt(document.addform.end_day.value);
// ey = parseInt(document.addform.end_year.value);
// if (sy == ey && so == eo && sd == ed) {
// if (sh > eh) {
// alert ("{time_error}");
// document.addform.end_hour.select();
// document.addform.end_hour.focus();
// return false;
// }
// if (sh == eh && sm > em) {
// alert ("{time_error}");
// document.addform.end_hour.select();
// document.addform.end_hour.focus();
// return false;
// }
// }
// if (sy == ey && so == eo && sd > ed) {
// alert ("{date_error}");
// document.addform.end_day.select();
// document.addform.end_day.focus();
// return false;
// }
// if (sy == ey && so > eo) {
// alert ("{date_error}");
// document.addform.end_month.select();
// document.addform.end_month.focus();
// return false;
// }
// if (sy > ey) {
// alert ("{date_error}");
// document.addform.end_year.select();
// document.addform.end_year.focus();
// return false;
// }
// would be nice to also check date to not allow Feb 31, etc...
document.addform.submit();
// return true;
}
</script>
</head>
<body bgcolor="#C0C0C0">
<center>
<h2><font color="#000000">{calendar_action}</font></h2>
@ -95,8 +13,7 @@ function validate_and_submit() {
<!-- BEGIN edit_entry_end -->
</table>
<input type="button" value="{submit_button}" onClick="validate_and_submit();">
<noscript><input type="submit" value="{submit_button}"></noscript>
<input type="submit" value="{submit_button}">
</form>
{delete_button}

View File

@ -148,19 +148,19 @@
if($cal_info->rpt_type == "weekly" || $cal_info->rpt_type == "daily") {
$repeat_days = "";
if ($cal_info->rpt_sun)
add_day(&$repeat_days,lang("Sunday "));
add_day($repeat_days,lang("Sunday "));
if ($cal_info->rpt_mon)
add_day(&$repeat_days,lang("Monday "));
add_day($repeat_days,lang("Monday "));
if ($cal_info->rpt_tue)
add_day(&$repeat_days,lang("Tuesay "));
add_day($repeat_days,lang("Tuesay "));
if ($cal_info->rpt_wed)
add_day(&$repeat_days,lang("Wednesday "));
add_day($repeat_days,lang("Wednesday "));
if ($cal_info->rpt_thu)
add_day(&$repeat_days,lang("Thursday "));
add_day($repeat_days,lang("Thursday "));
if ($cal_info->rpt_fri)
add_day(&$repeat_days,lang("Friday "));
add_day($repeat_days,lang("Friday "));
if ($cal_info->rpt_sat)
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

@ -15,6 +15,8 @@
- Fixed proxy server support for headlines and check for new version on main screen.
- Fixed headlines preferences and converted headline preferences to a template
- Fixed pgsql upgrade from beta path.
- Fixed chronological ordering of calendar events.
- Changed javascript validation to server side upon submitting calendar events.
[0.9.7] - Fixed SQL error in tts
- Fixed table locking in admin -> edit account