various little fixes - now using sbox

This commit is contained in:
skeeter 2000-12-23 16:33:22 +00:00
parent bdd8b39637
commit 943a5229a4
4 changed files with 68 additions and 172 deletions

View File

@ -1,4 +1,3 @@
<?php_track_vars?>
<?php
/**************************************************************************\
* phpGroupWare - Calendar *
@ -17,9 +16,19 @@
$phpgw_info["flags"] = array("currentapp" => "calendar", "enable_calendar_class" => True, "enable_nextmatchs_class" => True);
include("../header.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_sbox.inc.php");
$sb = new sbox;
$cal_info = new calendar_item;
function display_item($field,$data) {
global $phpgw;
$phpgw->template->set_var("field",$field);
$phpgw->template->set_var("data",$data);
$phpgw->template->parse("output","list",True);
}
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$hourformat = "h";
} else {
@ -72,6 +81,7 @@
$cal_info->edatetime = $cal_info->datetime;
$cal_info->name = "";
$cal_info->description = "";
$cal_info->priority = 2;
$cal_info->rpt_end = $cal_info->datetime + 86400;
}
@ -99,42 +109,18 @@
$phpgw->template->parse("out","edit_entry_begin");
// Brief Description
$phpgw->template->set_var("field",lang("Brief Description"));
$phpgw->template->set_var("data","<input name=\"cal[name]\" size=\"25\" value=\"".$cal_info->name."\">");
$phpgw->template->parse("output","list",True);
display_item(lang("Brief Description"),"<input name=\"cal[name]\" size=\"25\" value=\"".$cal_info->name."\">");
// Full Description
$phpgw->template->set_var("field",lang("Full Description"));
$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);
display_item(lang("Full Description"),"<textarea name=\"cal[description]\" rows=\"5\" cols=\"40\" wrap=\"virtual\">".$cal_info->description."</textarea>");
// Date
$phpgw->template->set_var("field",lang("Start Date"));
$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=\"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=\"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";
}
$year_html .= "</select>";
$phpgw->template->set_var("data",$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
$phpgw->template->parse("output","list",True);
$day_html = $sb->getDays("cal[day]",intval($phpgw->common->show_date($cal_info->datetime,"d")));
$month_html = $sb->getMonthText("cal[month]",intval($phpgw->common->show_date($cal_info->datetime,"n")));
$year_html = $sb->getYears("cal[year]",intval($phpgw->common->show_date($cal_info->datetime,"Y")),intval($phpgw->common->show_date($cal_info->datetime,"Y")));
display_item(lang("Start Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
// Time
$phpgw->template->set_var("field",lang("Time"));
$amsel = "checked"; $pmsel = "";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
if ($cal_info->ampm == "pm") {
@ -149,36 +135,16 @@
$str .= "<input type=\"radio\" name=\"cal[ampm]\" value=\"pm\" $pmsel>pm";
}
display_item(lang("Start Time"),$str);
// End Date
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("field",lang("End Date"));
$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=\"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=\"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";
}
$year_html .= "</select>";
$phpgw->template->set_var("data",$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
$phpgw->template->parse("output","list",True);
$day_html = $sb->getDays("cal[end_day]",intval($phpgw->common->show_date($cal_info->edatetime,"d")));
$month_html = $sb->getMonthText("cal[end_month]",intval($phpgw->common->show_date($cal_info->edatetime,"n")));
$year_html = $sb->getYears("cal[end_year]",intval($phpgw->common->show_date($cal_info->edatetime,"Y")),intval($phpgw->common->show_date($cal_info->edatetime,"Y")));
display_item(lang("End Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html));
// End Time
$phpgw->template->set_var("field",lang("End Time"));
$amsel = "checked"; $pmsel = "";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
if ($cal_info->end_ampm == "pm") {
@ -193,63 +159,23 @@
$str .= "<input type=\"radio\" name=\"cal[end_ampm]\" value=\"pm\" $pmsel>pm";
}
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
display_item(lang("End Time"),$str);
// Priority
$phpgw->template->set_var("field",lang("Priority"));
$str = "<select name=\"cal[priority]\">";
$str .= "<option value=\"1\"";
if($cal_info->priority == 1) $str .= " selected";
$str .= ">".lang("Low")."</option>";
$str .= "<option value=\"2\"";
if($cal_info->priority == 2 || $cal_info->priority == 0) $str .= " selected";
$str .= ">".lang("Medium")."</option>";
$str .= "<option value=\"3\"";
if($cal_info->priority == 3) $str .= " selected";
$str .= ">".lang("High")."</option>";
$str .= "</select>";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
display_item(lang("Priority"),$sb->getPriority("cal[priority]",$cal_info->priority));
$phpgw->template->set_var("field",lang("Access"));
$str = "<select name=\"cal[access]\">";
$str .= "<option value=\"private\"";
if ($cal_info->access == "private" || ! $id) $str .= " selected";
$str .= ">".lang("Private")."</option>";
$str .= "<option value=\"public\"";
if ($cal_info->access == "public") $str .= " selected";
$str .= ">".lang("Global Public")."</option>";
$str .= "<option value=\"group\"";
if ($cal_info->access == "group" || !strlen($cal_info->access)) $str .= " selected";
$str .= ">".lang("Group Public")."</option>";
$str .= "</select>";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
// Access
display_item(lang("Access"),$sb->getAccessList("cal[access]",$cal_info->access));
// Groups
$phpgw->template->set_var("field",lang("Groups"));
$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();
$user_groups = $phpgw->accounts->read_group_names($db2->f("account_lid"));
for ($i=0;$i<count($user_groups);$i++) {
$str .= "<option value=\"" . $user_groups[$i][0] . "\"";
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>";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
display_item(lang("Groups"),$sb->getGroups($user_groups,$cal_info->groups,"cal[groups][]"));
// Participants
$phpgw->template->set_var("field",lang("Participants"));
$db2 = $phpgw->db;
$db2->query("select account_id,account_lastname,account_firstname,account_lid "
. "from accounts where account_status !='L' and "
@ -273,12 +199,9 @@
$str .= ">".$phpgw->common->grab_owner_name($db2->f("account_id"))."</option>";
}
$str .= "</select>";
// $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);
display_item(lang("Participants"),$str);
// I Participate
$phpgw->template->set_var("field",lang("I Participate"));
$participate = False;
if($id) {
for($i=0;$i<count($cal_info->participants);$i++) {
@ -292,11 +215,9 @@
$str .= " checked";
}
$str .= ">";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
display_item(lang("I Participate"),$str);
// Repeat Type
$phpgw->template->set_var("field",lang("Repeat 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");
@ -306,37 +227,20 @@
$str .= ">".lang($rpt_type_out[$rpt_type_str[$l]])."</option>";
}
$str .= "</select>";
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
display_item(lang("Repeat Type"),$str);
$phpgw->template->set_var("field",lang("Repeat End Date"));
$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=\"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=\"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=\"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";
}
$year_html .= "</select>";
$day_html = $sb->getDays("cal[rpt_day]",intval($phpgw->common->show_date($cal_info->rpt_end,"d")));
$month_html = $sb->getMonthText("cal[rpt_month]",intval($phpgw->common->show_date($cal_info->rpt_end,"n")));
$year_html = $sb->getYears("cal[rpt_year]",intval($phpgw->common->show_date($cal_info->rpt_end,"Y")),intval($phpgw->common->show_date($cal_info->rpt_end,"Y")));
$str .= $phpgw->common->dateformatorder($year_html,$month_html,$day_html);
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
$phpgw->template->set_var("field",lang("Repeat Day")."<br>".lang("(for weekly)"));
display_item(lang("Repeat End Date"),$str);
$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")." ";
@ -344,12 +248,10 @@
$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=\"cal[rpt_freq]\" size=\"4\" maxlength=\"4\" value=\"".$cal_info->rpt_freq."\">");
$phpgw->template->parse("output","list",True);
display_item(lang("Repeat Day")."<br>".lang("(for weekly)"),$str);
display_item(lang("Frequency"),"<input name=\"cal[rpt_freq]\" size=\"4\" maxlength=\"4\" value=\"".$cal_info->rpt_freq."\">");
$phpgw->template->set_var("submit_button",lang("Submit"));

View File

@ -9,7 +9,7 @@
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $ Id $ */
/* $Id$ */
{
echo "<p>\n";

View File

@ -26,11 +26,20 @@
$repeat_days .= $day;
}
function display_item($field,$data) {
global $phpgw;
$phpgw->template->set_var("field",$field);
$phpgw->template->set_var("data",$data);
$phpgw->template->parse("output","list",True);
}
if ($year) $thisyear = $year;
if ($month) $thismonth = $month;
$pri[1] = lang("Low");
$pri[2] = lang("Medium");
$pri[2] = lang("Normal");
$pri[3] = lang("High");
$db = $phpgw->db;
@ -62,27 +71,19 @@
// Some browser add a \n when its entered in the database. Not a big deal
// this will be printed even though its not needed.
if (nl2br($cal_info->description)) {
$phpgw->template->set_var("field",lang("Description"));
$phpgw->template->set_var("data",nl2br($cal_info->description));
$phpgw->template->parse("output","list",True);
display_item(lang("Description"),nl2br($cal_info->description));
}
$phpgw->template->set_var("field",lang("Start Date/Time"));
$phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->datetime));
$phpgw->template->parse("output","list",True);
display_item(lang("Start Date/Time"),$phpgw->common->show_date($cal_info->datetime));
// save date so the trailer links are for the same time period
$thisyear = (int)$cal_info->year;
$thismonth = (int)$cal_info->month;
$thisday = (int)$cal_info->day;
$phpgw->template->set_var("field",lang("End Date/Time"));
$phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->edatetime));
$phpgw->template->parse("output","list",True);
display_item(lang("End Date/Time"),$phpgw->common->show_date($cal_info->edatetime));
$phpgw->template->set_var("field",lang("Priority"));
$phpgw->template->set_var("data",$pri[$cal_info->priority]);
$phpgw->template->parse("output","list",True);
display_item(lang("Priority"),$pri[$cal_info->priority]);
$phpgw->template->set_var("field",lang("Created by"));
$participate = False;
@ -92,16 +93,13 @@
}
}
if($is_my_event && $participate)
$phpgw->template->set_var("data","<a href=\""
display_item(lang("Created by"),"<a href=\""
.$phpgw->link("viewmatrix.php","participants=".$cal_info->owner."&date=".$cal_info->year.$cal_info->month.$cal_info->day."&matrixtype=free/busy")
."\">".$phpgw->common->grab_owner_name($cal_info->owner)."</a>");
else
$phpgw->template->set_var("data",$phpgw->common->grab_owner_name($cal_info->owner));
$phpgw->template->parse("output","list",True);
display_item(lang("Created by"),$phpgw->common->grab_owner_name($cal_info->owner));
$phpgw->template->set_var("field",lang("Updated"));
$phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->mdatetime));
$phpgw->template->parse("output","list",True);
display_item(lang("Updated"),$phpgw->common->show_date($cal_info->mdatetime));
if($cal_info->groups[0]) {
$cal_grps = "";
@ -111,9 +109,7 @@
$db->next_record();
$cal_grps .= $db->f("group_name");
}
$phpgw->template->set_var("field",lang("Groups"));
$phpgw->template->set_var("data",$cal_grps);
$phpgw->template->parse("output","list",True);
display_item(lang("Groups"),$cal_grps);
}
$str = "";
@ -121,9 +117,7 @@
if($i) $str .= "<br>";
$str .= $phpgw->common->grab_owner_name($cal_info->participants[$i]);
}
$phpgw->template->set_var("field",lang("Participants"));
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
display_item(lang("Participants"),$str);
// Repeated Events
$str = $cal_info->rpt_type;
@ -152,9 +146,7 @@
if($cal_info->rpt_freq) $str .= lang("frequency")." ".$cal_info->rpt_freq;
$str .= ")";
$phpgw->template->set_var("field",lang("Repetition"));
$phpgw->template->set_var("data",$str);
$phpgw->template->parse("output","list",True);
display_item(lang("Repetition"),$str);
}
if ($is_my_event) {

View File

@ -270,10 +270,12 @@
$sql = "SELECT DISTINCT calendar_entry.cal_id "
. "FROM calendar_entry, calendar_entry_user, calendar_entry_repeats "
. "WHERE calendar_entry.cal_id = calendar_entry_user.cal_id "
. "AND (((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_datetime) AND (".$endtime." <= calendar_entry.cal_edatetime)) "
. "WHERE ((calendar_entry_user.cal_id = calendar_entry.cal_id) AND "
. "(calendar_entry_repeats.cal_id = calendar_entry.cal_id)) AND "
. " (((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_datetime) AND (".$endtime." <= calendar_entry.cal_edatetime)) "
. "OR ((".$starttime." >= calendar_entry.cal_datetime) AND (".$starttime." <= calendar_entry.cal_edatetime) AND (".$endtime." >= calendar_entry.cal_edatetime)) "
. "OR ((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_edatetime)))";
. "OR ((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_edatetime))) AND "
. "(calendar_entry_repeats.cal_type <> 'monthlyByDay') ";
if(count($participants) || is_array($groups)) {
$p_g = "";
@ -588,7 +590,7 @@
if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % intval($rep_events->rpt_freq)) continue;
if (($start["dow"] == $date["dow"]) &&
(floor($start["day"]/7) == floor($date["day"]/7))) {
(ceil($start["day"]/7) == ceil($date["day"]/7))) {
$link[$this->checked_re] = $i;
$this->checked_re++;
}