From 19cac1259321933ee407ed6b077ef3d2aa9e9e58 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Wed, 19 Nov 2003 07:54:09 +0000 Subject: Checked in a new popup system. Also added calname to calendar for popup reference. --- functions/date_functions.php | 75 +++++++++++++++++++++++++------------------- functions/ical_parser.php | 26 +++++++-------- functions/init.inc.php | 2 +- 3 files changed, 55 insertions(+), 48 deletions(-) (limited to 'functions') diff --git a/functions/date_functions.php b/functions/date_functions.php index f14147b..8745c1a 100644 --- a/functions/date_functions.php +++ b/functions/date_functions.php @@ -160,54 +160,63 @@ function chooseOffset($time) { return $offset; } -function openevent($cal, $st, $end, $arr, $lines, $wrap, $clic, $fclic, $class) { +function openevent($calendar_name, $start, $end, $arr, $lines, $wrap, $pre_text, $post_text, $link_class) { $event_text = stripslashes(urldecode($arr["event_text"])); # for iCal pseudo tag comptability - if (ereg("<([[:alpha:]]+://)([^<>[:space:]]+)>",$event_text,$reg)) { - $ev = $reg[1] . $reg[2]; - $event_text = $reg[2]; + if (ereg("<([[:alpha:]]+://)([^<>[:space:]]+)>",$event_text,$matches)) { + $full_event_text = $matches[1] . $matches[2]; + $event_text = $matches[2]; } else { - $ev = $arr["event_text"]; + $full_event_text = $event_text; $event_text = strip_tags($event_text, ''); } + if (isset($arr["organizer"])) { - $organizer = urlencode(addslashes($arr["organizer"])); - } else { - $organizer = ''; + $organizer = addslashes($arr["organizer"]); } + if (isset($arr["attendee"])) { - $attendee = urlencode(addslashes($arr["attendee"])); - } else { - $attendee = ''; + $attendee = addslashes($arr["attendee"]); } + if (isset($arr["location"])) { - $location = $arr["location"]; - } else { - $location = ''; + $location = addslashes($arr["location"]); } + if (isset($arr["status"])) { - $status = $arr["status"]; - } else { - $status = ''; + $status = addslashes($arr["status"]); } - if ($event_text != "") { - if ($lines) $event_text = word_wrap($event_text, $wrap, $lines); - $dsc = urlencode(addslashes($arr["description"])); - echo '[:space:]]+)", $ev, $res))) || ($dsc)) { - echo "javascript:w=window.open('"; - echo "includes/event.php?event="; - echo urlencode(addslashes($ev)); - echo "&cal="; - echo urlencode(addslashes($cal)); - echo "&start=$st&end=$end&description=$dsc&status=$status&location=$location&organizer=$organizer&attendee=$attendee"; - echo "','Popup','"; - echo "scrollbars=yes,width=460,height=275"; - echo "');w.focus()"; + + if (isset($arr["description"])) { + $description = addslashes(stripslashes(urldecode($arr["description"]))); + } + + if (!empty($event_text)) { + if ($lines > 0) { + $event_text = word_wrap($event_text, $wrap, $lines); + } + + if ((!(ereg("([[:alpha:]]+://[^<>[:space:]]+)", $full_event_text, $res))) || ($description)) { + $escaped_event = addslashes($full_event_text); + $escaped_calendar = addslashes($calendar_name); + $escaped_start = addslashes($start); + $escaped_end = addslashes($end); + // fix for URL-length bug in IE: populate and submit a hidden form on click + static $popup_data_index = 0; +echo << + +END; + echo ""; + $popup_data_index++; } else { - echo $res[1]; + echo ""; } - echo '">'.$clic.$event_text.$fclic.''; + echo "{$pre_text}{$event_text}{$post_text}\n"; } } diff --git a/functions/ical_parser.php b/functions/ical_parser.php index 2928263..1383a21 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -51,20 +51,18 @@ if (($is_webcal == false) && ($save_parsed_cals == 'yes') && ($cal != $ALL_CALEN } if ($parse_file) { -// some initializations, that have to be outside the calnumber loop - // auxiliary array for determining overlaps of events $overlap_array = array (); - - // using $uid to set specific points in array, if $uid is not in the - // .ics file, we need to have some unique place in the array $uid_counter = 0; } $calnumber = 1; foreach ($cal_filelist as $filename) { - + + // Find the real name of the calendar. + $actual_calname = str_replace($calendar_path, '', $filename); + $actual_calname = str_replace('/', '', str_replace('.ics', '', $actual_calname)); + if ($parse_file) { - // patch to speed up parser $ifile = fopen($filename, "r"); if ($ifile == FALSE) exit(error($error_invalidcal_lang, $filename)); @@ -231,7 +229,7 @@ foreach ($cal_filelist as $filename) { if (($end > $mArray_begin) && ($end < $mArray_end)) { while ($start != $end) { $start_date2 = date('Ymd', $start); - $master_array[($start_date2)][('-1')][$uid]= array ('event_text' => $summary, 'description' => $description, 'calnumber' => $calnumber); + $master_array[($start_date2)][('-1')][$uid]= array ('event_text' => $summary, 'description' => $description, 'calnumber' => $calnumber, 'calname' => $actual_calname ); $start = strtotime('+1 day', $start); } if (!$write_processed) $master_array[($start_date)]['-1'][$uid]['exception'] = true; @@ -258,7 +256,7 @@ foreach ($cal_filelist as $filename) { $end_time_tmp = '0000'; } $nbrOfOverlaps = checkOverlap($start_date_tmp, $start_time_tmp, $end_time_tmp, $uid); - $master_array[$start_date_tmp][$time_tmp][$uid] = array ('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime, 'end_unixtime' => $end_unixtime, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => true, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee) ); + $master_array[$start_date_tmp][$time_tmp][$uid] = array ('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime, 'end_unixtime' => $end_unixtime, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => true, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname ); $start_tmp = strtotime('+1 day',$start_tmp); } if (!$write_processed) $master_array[$start_date][($hour.$minute)][$uid]['exception'] = true; @@ -273,7 +271,7 @@ foreach ($cal_filelist as $filename) { // This if statement should prevent writing of an excluded date if its the first recurrance - CL if (!in_array($start_date, $except_dates)) { $nbrOfOverlaps = checkOverlap($start_date, $start_time, $end_time_tmp1, $uid); - $master_array[($start_date)][($hour.$minute)][$uid] = array ('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime, 'end_unixtime' => $end_unixtime, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber ); + $master_array[($start_date)][($hour.$minute)][$uid] = array ('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime, 'end_unixtime' => $end_unixtime, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname ); if (!$write_processed) $master_array[($start_date)][($hour.$minute)][$uid]['exception'] = true; } } @@ -575,7 +573,7 @@ foreach ($cal_filelist as $filename) { $end_time2 = strtotime('+'.$diff_allday_days.' days', $recur_data_time); while ($start_time2 < $end_time2) { $start_date2 = date('Ymd', $start_time2); - $master_array[($start_date2)][('-1')][]= array ('event_text' => $summary, 'description' => $description, 'calnumber' => $calnumber); + $master_array[($start_date2)][('-1')][]= array ('event_text' => $summary, 'description' => $description, 'calnumber' => $calnumber, 'calname' => $actual_calname ); $start_time2 = strtotime('+1 day', $start_time2); } } else { @@ -600,7 +598,7 @@ foreach ($cal_filelist as $filename) { $end_time_tmp = '0000'; } $nbrOfOverlaps = checkOverlap($start_date_tmp, $start_time_tmp, $end_time_tmp, $uid); - $master_array[$start_date_tmp][$time_tmp][$uid] = array ('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => true, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber); + $master_array[$start_date_tmp][$time_tmp][$uid] = array ('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => true, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname); $start_tmp = strtotime('+1 day',$start_tmp); } } else { @@ -615,7 +613,7 @@ foreach ($cal_filelist as $filename) { $until_check = $recur_data_date.$hour.$minute.'00'; if ($abs_until > $until_check) { $nbrOfOverlaps = checkOverlap($recur_data_date, $start_time, $end_time_tmp1, $uid); - $master_array[($recur_data_date)][($hour.$minute)][$uid] = array ('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber); + $master_array[($recur_data_date)][($hour.$minute)][$uid] = array ('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname); } } } @@ -657,7 +655,7 @@ foreach ($cal_filelist as $filename) { } else { $vtodo_sort = $vtodo_priority; } - $master_array['-2']["$vtodo_sort"]["$uid"] = array ('start_date' => $start_date, 'start_time' => $start_time, 'vtodo_text' => $summary, 'due_date'=> $due_date, 'due_time'=> $due_time, 'completed_date' => $completed_date, 'completed_time' => $completed_time, 'priority' => $vtodo_priority, 'status' => $status, 'class' => $class, 'categories' => $vtodo_categories, 'description' => $description); + $master_array['-2']["$vtodo_sort"]["$uid"] = array ('start_date' => $start_date, 'start_time' => $start_time, 'vtodo_text' => $summary, 'due_date'=> $due_date, 'due_time'=> $due_time, 'completed_date' => $completed_date, 'completed_time' => $completed_time, 'priority' => $vtodo_priority, 'status' => $status, 'class' => $class, 'categories' => $vtodo_categories, 'description' => $description, 'calname' => $actual_calname); unset ($start_date, $start_time, $due_date, $due_time, $completed_date, $completed_time, $vtodo_priority, $status, $class, $vtodo_categories, $summary, $description); $vtodo_set = FALSE; } elseif ($line == 'BEGIN:VTODO') { diff --git a/functions/init.inc.php b/functions/init.inc.php index 5bae3c7..3be7abb 100644 --- a/functions/init.inc.php +++ b/functions/init.inc.php @@ -6,7 +6,7 @@ //chmod(BASE.'calendars/School.ics',0666); // uncomment when developing, comment for shipping version -error_reporting (0); +error_reporting (E_ALL); $ALL_CALENDARS_COMBINED = 'all_calendars_combined971'; if (!defined('BASE')) define('BASE', './'); -- cgit v1.2.3