fix for buttons

This commit is contained in:
skeeter 2000-11-23 13:28:37 +00:00
parent 00fdbec533
commit 51869a8ebf
5 changed files with 212 additions and 233 deletions

View File

@ -99,11 +99,7 @@
if($can_edit) { if($can_edit) {
$phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php")); $phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php"));
if($id) { $common_hidden = "<input type=\"hidden\" name=\"id\" value=\"".$id."\">\n";
$common_hidden = "<input type=\"hidden\" name=\"id\" value=\"$id\">\n";
} else {
$common_hidden = "";
}
$phpgw->template->set_var("common_hidden",$common_hidden); $phpgw->template->set_var("common_hidden",$common_hidden);
@ -295,8 +291,9 @@
$phpgw->template->set_var("submit_button",lang("Submit")); $phpgw->template->set_var("submit_button",lang("Submit"));
if ($id > 0) { if ($id > 0) {
$phpgw->template->set_var("action_url",$phpgw->link("delete.php","id=$id")); $phpgw->template->set_var("action_url_button",$phpgw->link("delete.php","id=$id"));
$phpgw->template->set_var("action_text",lang("Delete")); $phpgw->template->set_var("action_text_button",lang("Delete"));
$phpgw->template->set_var("action_confirm_button","onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"");
$phpgw->template->parse("delete_button","form_button"); $phpgw->template->parse("delete_button","form_button");
$phpgw->template->pparse("out","edit_entry_end"); $phpgw->template->pparse("out","edit_entry_end");
} else { } else {

View File

@ -1,4 +1,3 @@
<?php php_track_vars?>
<?php <?php
/**************************************************************************\ /**************************************************************************\
* phpGroupWare - Calendar * * phpGroupWare - Calendar *
@ -14,220 +13,208 @@
/* $Id$ */ /* $Id$ */
$phpgw_info["flags"]["noheader"]="True";
$phpgw_info["flags"] = array("currentapp" => "calendar", "noheader" => True, "nonavbar" => True, "enable_calendar_class" => True, "enable_nextmatchs_class" => True); $phpgw_info["flags"] = array("currentapp" => "calendar", "noheader" => True, "nonavbar" => True, "enable_calendar_class" => True, "enable_nextmatchs_class" => True);
include("../header.inc.php"); include("../header.inc.php");
if($REQUEST_METHOD <> "POST") {
}
$cal_info = new calendar_item;
for(reset($HTTP_POST_VARS);$key=key($HTTP_POST_VARS);next($HTTP_POST_VARS)) {
$data = $HTTP_POST_VARS[$key];
$cal_info->set($key,$data);
}
$phpgw->calendar->add($cal_info,$cal_info->id);
// Input time format "2359" // Input time format "2359"
function add_duration($time, $duration) // function add_duration($time, $duration)
{ // {
$hour = (int)($time / 10000); // $hour = (int)($time / 10000);
$min = $time % 100; // $min = $time % 100;
$minutes = $hour * 60 + $min + $duration; // $minutes = $hour * 60 + $min + $duration;
$h = $minutes / 60; // $h = $minutes / 60;
$m = $minutes % 60; // $m = $minutes % 60;
$ret = sprintf ("%d%02d",$h,$m); // $ret = sprintf ("%d%02d",$h,$m);
//echo "add_duration ( $time, $duration ) = $ret <BR>"; // //echo "add_duration ( $time, $duration ) = $ret <BR>";
return $ret; // return $ret;
} // }
// check to see if two events overlap // // check to see if two events overlap
function times_overlap($time1, $duration1, $time2, $duration2) // function times_overlap($time1, $duration1, $time2, $duration2)
{ // {
//echo "times_overlap ( $time1, $duration1, $time2, $duration2 )<BR>"; // //echo "times_overlap ( $time1, $duration1, $time2, $duration2 )<BR>";
$hour1 = (int) ($time1 / 100); // $hour1 = (int) ($time1 / 100);
$min1 = $time1 % 100; // $min1 = $time1 % 100;
$hour2 = (int) ($time2 / 100); // $hour2 = (int) ($time2 / 100);
$min2 = $time2 % 100; // $min2 = $time2 % 100;
// convert to minutes since midnight // // convert to minutes since midnight
$tmins1start = $hour1 * 60 + $min1; // $tmins1start = $hour1 * 60 + $min1;
$tmins1end = $tmins1start + $duration1; // $tmins1end = $tmins1start + $duration1;
$tmins2start = $hour2 * 60 + $min2; // $tmins2start = $hour2 * 60 + $min2;
$tmins2end = $tmins2start + $duration2; // $tmins2end = $tmins2start + $duration2;
//echo "tmins1start=$tmins1start, tmins1end=$tmins1end, tmins2start=" // //echo "tmins1start=$tmins1start, tmins1end=$tmins1end, tmins2start="
// . "$tmins2start, tmins2end=$tmins2end<BR>"; // // . "$tmins2start, tmins2end=$tmins2end<BR>";
//
if ($tmins1start >= $tmins2start && $tmins1start <= $tmins2end) // if ($tmins1start >= $tmins2start && $tmins1start <= $tmins2end)
return true; // return true;
if ($tmins1end >= $tmins2start && $tmins1end <= $tmins2end) // if ($tmins1end >= $tmins2start && $tmins1end <= $tmins2end)
return true; // return true;
if ($tmins2start >= $tmins1start && $tmins2start <= $tmins1end) // if ($tmins2start >= $tmins1start && $tmins2start <= $tmins1end)
return true; // return true;
if ($tmins2end >= $tmins1start && $tmins2end <= $tmins1end) // if ($tmins2end >= $tmins1start && $tmins2end <= $tmins1end)
return true; // return true;
return false; // return false;
} // }
//
$phpgw->db->lock(array('webcal_entry','webcal_entry_user','webcal_entry_groups', // $phpgw->db->lock(array('webcal_entry','webcal_entry_user','webcal_entry_groups',
'webcal_entry_repeats')); // 'webcal_entry_repeats'));
//
// first check for any schedule conflicts // // first check for any schedule conflicts
if (strlen($hour) > 0) { // if (strlen($hour) > 0) {
$date = mktime(0,0,0,$month,$day,$year); // $date = mktime(0,0,0,$month,$day,$year);
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { // if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$hour %= 12; // $hour %= 12;
if ($ampm == "pm") // if ($ampm == "pm")
$hour += 12; // $hour += 12;
} // }
//
$sql = "SELECT webcal_entry_user.cal_login, webcal_entry.cal_time," . // $sql = "SELECT webcal_entry_user.cal_login, webcal_entry.cal_time," .
"webcal_entry.cal_duration, webcal_entry.cal_name, " . // "webcal_entry.cal_duration, webcal_entry.cal_name, " .
"webcal_entry.cal_id, webcal_entry.cal_access " . // "webcal_entry.cal_id, webcal_entry.cal_access " .
"FROM webcal_entry, webcal_entry_user " . // "FROM webcal_entry, webcal_entry_user " .
"WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . // "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " .
"AND webcal_entry.cal_date = " . date("Ymd", $date) . " AND ( "; // "AND webcal_entry.cal_date = " . date("Ymd", $date) . " AND ( ";
//
for ($i = 0; $i < count($participants); $i++) { // for ($i = 0; $i < count($participants); $i++) {
if ($i) $sql .= " OR "; // if ($i) $sql .= " OR ";
$sql .= " webcal_entry_user.cal_login = '" . $participants[$i] . "'"; // $sql .= " webcal_entry_user.cal_login = '" . $participants[$i] . "'";
} // }
$sql .= " )"; // $sql .= " )";
//
$phpgw->db->query($sql); // $phpgw->db->query($sql);
$time1 = sprintf("%d:%02d", $hour, $minute); // $time1 = sprintf("%d:%02d", $hour, $minute);
$duration1 = sprintf("%d", $duration); // $duration1 = sprintf("%d", $duration);
//
while ($phpgw->db->next_record()) { // while ($phpgw->db->next_record()) {
// see if either event overlaps one another // // see if either event overlaps one another
if ($phpgw->db->f(4) != $id) { // if ($phpgw->db->f(4) != $id) {
$time2 = $phpgw->db->f(1); // $time2 = $phpgw->db->f(1);
$duration2 = $phpgw->db->f(2); // $duration2 = $phpgw->db->f(2);
if (times_overlap($time1, $duration1, $time2, $duration2)) { // if (times_overlap($time1, $duration1, $time2, $duration2)) {
$overlap .= "<LI>"; // $overlap .= "<LI>";
if ($phpgw->db->f(5) == 'R' && $phpgw->db->f(0) != $login) // if ($phpgw->db->f(5) == 'R' && $phpgw->db->f(0) != $login)
$overlap .= "(PRIVATE)"; // $overlap .= "(PRIVATE)";
else { // else {
$overlap .= "<A HREF=\"".$phpgw->link("view.php", // $overlap .= "<A HREF=\"".$phpgw->link("view.php",
"id=".$phpgw->db->f(4))."\">" // "id=".$phpgw->db->f(4))."\">"
. $phpgw->db->f(3) . "</A>"; // . $phpgw->db->f(3) . "</A>";
} // }
$overlap .= " (" . display_time($time2); // $overlap .= " (" . display_time($time2);
if ($duration2 > 0) // if ($duration2 > 0)
$overlap .= "-" . display_time(add_duration($time2,$duration2)) // $overlap .= "-" . display_time(add_duration($time2,$duration2))
. ")"; // . ")";
} // }
} // }
} // }
} // }
//
if ($overlap) //if ($overlap)
$error = lang("The following conflicts with the suggested time:<ul>x</ul>", // $error = lang("The following conflicts with the suggested time:<ul>x</ul>",
$overlap); // $overlap);
//
if (! $error) { //if (! $error) {
// now add the entries // // now add the entries
//
if ($id != 0) { // if ($id != 0) {
$phpgw->db->query("DELETE FROM webcal_entry WHERE cal_id = $id"); // $phpgw->db->query("DELETE FROM webcal_entry WHERE cal_id = $id");
$phpgw->db->query("DELETE FROM webcal_entry_user WHERE cal_id = $id"); // $phpgw->db->query("DELETE FROM webcal_entry_user WHERE cal_id = $id");
$phpgw->db->query("DELETE FROM webcal_entry_repeats WHERE cal_id = $id"); // $phpgw->db->query("DELETE FROM webcal_entry_repeats WHERE cal_id = $id");
$phpgw->db->query("DELETE FROM webcal_entry_groups WHERE cal_id = $id"); // $phpgw->db->query("DELETE FROM webcal_entry_groups WHERE cal_id = $id");
} // }
//
$sql = "INSERT INTO webcal_entry (cal_owner, cal_date, " . // $sql = "INSERT INTO webcal_entry (cal_owner, cal_date, " .
"cal_time, cal_mod_date, cal_mod_time, cal_duration, cal_priority, " . // "cal_time, cal_mod_date, cal_mod_time, cal_duration, cal_priority, " .
"cal_access, cal_type, cal_name, cal_description ) " . // "cal_access, cal_type, cal_name, cal_description ) " .
"VALUES ('" . $phpgw_info["user"]["account_id"] . "', "; // "VALUES ('" . $phpgw_info["user"]["account_id"] . "', ";
//
$date = mktime(0,0,0,$month,$day,$year); // $date = mktime(0,0,0,$month,$day,$year);
$sql .= date("Ymd", $date) . ", "; // $sql .= date("Ymd", $date) . ", ";
if (strlen($hour) > 0) { // if (strlen($hour) > 0) {
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { // if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$hour %= 12; // $hour %= 12;
if ($ampm == "pm") // if ($ampm == "pm")
$hour += 12; // $hour += 12;
} // }
$sql .= sprintf("%02d%02d00, ",$hour,$minute); // $sql .= sprintf("%02d%02d00, ",$hour,$minute);
} else // } else
$sql .= "'-1', "; // $sql .= "'-1', ";
//
$sql .= date("Ymd") . ", " . date("Gis") . ", "; // $sql .= date("Ymd") . ", " . date("Gis") . ", ";
$sql .= sprintf("%d, ",$duration); // $sql .= sprintf("%d, ",$duration);
$sql .= sprintf("%d, ",$priority); // $sql .= sprintf("%d, ",$priority);
$sql .= "'$access', "; // $sql .= "'$access', ";
//
if ($rpt_type != 'none') // if ($rpt_type != 'none')
$sql .= "'M', "; // $sql .= "'M', ";
else // else
$sql .= "'E', "; // $sql .= "'E', ";
//
if (strlen($name) == 0) // if (strlen($name) == 0)
$name = "Unnamed Event"; // $name = "Unnamed Event";
//
$sql .= "'" . addslashes($name) . "', "; // $sql .= "'" . addslashes($name) . "', ";
if (! $description) // if (! $description)
$sql .= "'" . addslashes($name) . "')"; // $sql .= "'" . addslashes($name) . "')";
else // else
$sql .= "'" . addslashes($description) . "' )"; // $sql .= "'" . addslashes($description) . "' )";
//
$error = ""; // $error = "";
$phpgw->db->query($sql); // $phpgw->db->query($sql);
//
$phpgw->db->query("SELECT MAX(cal_id) FROM webcal_entry"); // $phpgw->db->query("SELECT MAX(cal_id) FROM webcal_entry");
$phpgw->db->next_record(); // $phpgw->db->next_record();
$id = $phpgw->db->f(0); // $id = $phpgw->db->f(0);
//
while ($participant = each($participants)) { // while ($participant = each($participants)) {
$phpgw->db->query("INSERT INTO webcal_entry_user (cal_id,cal_login,cal_status ) " // $phpgw->db->query("INSERT INTO webcal_entry_user (cal_id,cal_login,cal_status ) "
. "VALUES ($id, '" . $participant[1] . "', 'A')"); // . "VALUES ($id, '" . $participant[1] . "', 'A')");
} // }
//
if (strlen($rpt_type) || ! strcmp($rpt_type,'none') == 0) { // if (strlen($rpt_type) || ! strcmp($rpt_type,'none') == 0) {
// clearly, we want to delete the old repeats, before inserting new... // // clearly, we want to delete the old repeats, before inserting new...
$phpgw->db->query("delete from webcal_entry_repeats where cal_id='$id'"); // $phpgw->db->query("delete from webcal_entry_repeats where cal_id='$id'");
$freq = ($rpt_freq?$rpt_freq:1); // $freq = ($rpt_freq?$rpt_freq:1);
//
if ($rpt_end_use) { // if ($rpt_end_use) {
$end = "'" . date("Ymd",mktime(0,0,0,$rpt_month,$rpt_day,$rpt_year)) // $end = "'" . date("Ymd",mktime(0,0,0,$rpt_month,$rpt_day,$rpt_year))
. "'"; // . "'";
} else // } else
$end = 0; // $end = 0;
//
if ($rpt_type == 'weekly') { // if ($rpt_type == 'weekly') {
$days = ($rpt_sun?'y':'n') // $days = ($rpt_sun?'y':'n')
. ($rpt_mon?'y':'n') // . ($rpt_mon?'y':'n')
. ($rpt_tue?'y':'n') // . ($rpt_tue?'y':'n')
. ($rpt_wed?'y':'n') // . ($rpt_wed?'y':'n')
. ($rpt_thu?'y':'n') // . ($rpt_thu?'y':'n')
. ($rpt_fri?'y':'n') // . ($rpt_fri?'y':'n')
. ($rpt_sat?'y':'n'); // . ($rpt_sat?'y':'n');
} else { // } else {
$days = "nnnnnnn"; // $days = "nnnnnnn";
} // }
//
$phpgw->db->query("insert into webcal_entry_repeats (cal_id,cal_type," // $phpgw->db->query("insert into webcal_entry_repeats (cal_id,cal_type,"
. "cal_end,cal_days,cal_frequency) values($id,'$rpt_type'," // . "cal_end,cal_days,cal_frequency) values($id,'$rpt_type',"
. "$end,'$days',$freq)"); // . "$end,'$days',$freq)");
} // }
$phpgw->db->query("insert into webcal_entry_groups values ($id,'" // $phpgw->db->query("insert into webcal_entry_groups values ($id,'"
. $phpgw->accounts->array_to_string($access,$n_groups) . "') "); // . $phpgw->accounts->array_to_string($access,$n_groups) . "') ");
//
//
Header("Location: ".$phpgw->link("index.php","year=$year&month=$month&cd=14")); Header("Location: ".$phpgw->link("index.php","year=$year&month=$month&cd=14"));
} $phpgw->common->phpgw_footer();
$phpgw->common->phpgw_header();
?> ?>
<?php if (strlen($overlap)) { ?>
<H2><FONT COLOR="<?php echo $H2COLOR;?>">Scheduling Conflict</H2></FONT>
<?php
$time = sprintf("%d:%02d",$hour,$minute);
echo lang("Your suggested time of <B> x - x </B> conflicts with the following existing calendar entries:", display_time($time),display_time(add_duration($time,$duration))); ?>
?>
<UL>
<?php echo $overlap; ?>
</UL>
<?php } else { ?>
<H2><FONT COLOR="<?php echo $H2COLOR;?>">Error</H2></FONT>
<BLOCKQUOTE>
<?php echo $error; ?>
</BLOCKQUOTE>
<?php
}
$phpgw->db->unlock();
$phpgw->common->phpgw_footer();
?>

View File

@ -32,13 +32,8 @@ function validate_and_submit() {
<!-- BEGIN edit_entry_end --> <!-- BEGIN edit_entry_end -->
</table> </table>
<script language="JavaScript"> <!-- <input type="hidden" name="participant_list" value=""> -->
document.writeln ('<INPUT TYPE="button" VALUE="{submit_button}" ONCLICK="validate_and_submit()">'); <input type="submit" value="{submit_button}" onClick="validate_and_submit()">
</script>
<noscript>
<input type="submit" value="{submit_button}">
</noscript>
<input type="hidden" name="participant_list" value="">
</form> </form>
{delete_button} {delete_button}

View File

@ -1,6 +1,6 @@
<!-- $Id$ --> <!-- $Id$ -->
<!-- BEGIN form_button --> <!-- BEGIN form_button -->
<form action="{action_url}" method="post" name="{action_text}form"> <form action="{action_url_button}" method="post" name="{action_text_button}form">
<input type="submit" value="{action_text}" {action_confirm}> <input type="submit" value="{action_text_button}" {action_confirm_button}>
</form> </form>
<!-- END form_button --> <!-- END form_button -->

View File

@ -53,7 +53,7 @@
$phpgw->template->set_block("view_begin","list","view_end","form_button"); $phpgw->template->set_block("view_begin","list","view_end","form_button");
$phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]); $phpgw->template->set_var("bg_text",$phpgw_info["theme"]["bg_text"]);
$phpgw->template->set_var("name",$cal_info->name); $phpgw->template->set_var("name",$cal_info->name);
$phpgw->template->parse("out","view_begin"); $phpgw->template->parse("out","view_begin");
@ -156,14 +156,14 @@
} }
if ($is_my_event) { if ($is_my_event) {
$phpgw->template->set_var("action_url",$phpgw->link("edit_entry.php","id=$id")); $phpgw->template->set_var("action_url_button",$phpgw->link("edit_entry.php","id=$id"));
$phpgw->template->set_var("action_text"," ".lang("Edit")." "); $phpgw->template->set_var("action_text_button"," ".lang("Edit")." ");
$phpgw->template->set_var("action_confirm",""); $phpgw->template->set_var("action_confirm_button","");
$phpgw->template->parse("edit_button","form_button"); $phpgw->template->parse("edit_button","form_button");
$phpgw->template->set_var("action_url",$phpgw->link("delete.php","id=$id")); $phpgw->template->set_var("action_url_button",$phpgw->link("delete.php","id=$id"));
$phpgw->template->set_var("action_text",lang("Delete")); $phpgw->template->set_var("action_text_button",lang("Delete"));
$phpgw->template->set_var("action_confirm","onClick=\"confirm(".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."\")"); $phpgw->template->set_var("action_confirm_button","onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"");
$phpgw->template->parse("delete_button","form_button"); $phpgw->template->parse("delete_button","form_button");
// $phpgw->template->set_var("edit","<a href=\"".$phpgw->link("edit_entry.php","id=$id")."\">".lang("Edit")."</a>"); // $phpgw->template->set_var("edit","<a href=\"".$phpgw->link("edit_entry.php","id=$id")."\">".lang("Edit")."</a>");