cal_modified( $calid ); if (!$modified) $modified = 0; return $modified; } function phpMyCalFiles() { $mycal = new phpMyCal; $calendars = $mycal->cal_list(); $mycalarray = array(); foreach ($calendars as $calinfo) $mycalarray[] = 'phpMyCal:' . $calinfo->calid . ':' . $calinfo->name; return $mycalarray; } // // commented out because phpicalendar version 1.1 now has a similar // function which takes care of this // //function phpMyCalList( $list = "main", $cal_check = '' ) { // global $cal, $current_view, $calendar_lang; // $mycal = new phpMyCal; // $calendars = $mycal->cal_list(); // foreach ($calendars as $calinfo) { // $cal_tmp = urlencode( 'phpMyCal:' . $calinfo->calid . ':' . $calinfo->name ); // $cal_displayname_tmp = $calinfo->name; // if ($list == "main") { // $val = "$current_view.php?cal=$cal_tmp"; // $sel = ($cal_tmp == $cal ? " selected" : ""); // } else if ($list == "import") { // $val = $calinfo->calid; // $sel = ""; // } else { // $val = $cal_tmp; // $sel = ($cal_tmp == $cal_check ? " selected" : ""); // } // print "\n"; // } //} function phpMyCalParse( $calid ) { global $master_array, $calendar_name, $calendar_tz, $calnumber, $this_month, $this_year; $cal = new phpMyCal; list( $calinfo ) = $cal->cal_list( $calid ); if (!$calinfo) die( "error - " . $cal->errormessage ); $todos = $cal->todo_list( $calid ); foreach ($todos as $todo) { $tododata = array( 'uid' => $todo->UID, 'calnumber' => $calnumber, 'class' => '', // not supported by phpMyCal 'categories' => '', // not supported by phpMyCal 'start_date' => date( 'Ymd', $todo->start ), 'start_time' => date( 'Hi', $todo->start ), 'vtodo_text' => htmlentities( urlencode( str_replace( "\n", "
", $todo->summary ) ) ) ); if ($todo->due) { $tododata['due_date'] = date( 'Ymd', $todo->due ); $tododata['due_time'] = date( 'Hi', $todo->due ); } if ($todo->completed) { $tododata['completed_date'] = date( 'Ymd', $todo->completed ); $tododata['completed_time'] = date( 'Hi', $todo->completed ); $tododata['status'] = 'COMPLETED'; } if ($todo->priority) $tododata['priority'] = $todo->priority; if (!$todo->priority && $todo->completed) $topkey = 11; else if (!$todo->priority) $topkey = 10; else $topkey = $todo->priority; $master_array['-2']["$topkey"][$todo->UID] = $tododata; unset( $tododata ); } $master_array['-1'] = 'valid cal file'; $master_array['calendar_name'] = $calendar_name = $calinfo->name; $master_array['calendar_tz'] = $calendar_tz = $calinfo->tzid; // range taken from PHP iCalendar // - beginning of current month minus one month two days to plus two months and two days $month_start = mktime( 0, 0, 0, $this_month, 1, $this_year ); $start_range = strtotime( '-1 month -2 day', $month_start ); $end_range = strtotime( '+2 month +2 day', $month_start ); if (False === ($events = $cal->event_list( $calid ))) { die( "phpMyCal Error " . $cal->errorcode . ": " . $cal->errormessage ); } foreach ($events as $event) { phpMyCalAddEvent( $event ); $recurs = $cal->event_recurs( $event, $start_range, $end_range ); foreach ($recurs as $recur) { $event->start = $recur['start']; $event->end = $recur['end']; phpMyCalAddEvent( $event ); } } // if (isset( $master_array['-2'] ) && is_array( $master_array['-2'] )) { // ksort( $master_array['-2'] ); // reset( $master_array['-2'] ); // } ksort($master_array); reset($master_array); // sort the sub (day) arrays so the times are in order foreach (array_keys($master_array) as $k) { if (isset($master_array[$k]) && is_array($master_array[$k])) { ksort($master_array[$k]); reset($master_array[$k]); } } } // taken from PHP iCalendar 0.9.3 and updated for phpMyCal function phpMyCalOpenEvent($cal, $st, $end, $arr, $lines, $wrap, $clic, $fclic, $linkclass = "psf" ) { $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]; } else { $ev = $arr["event_text"]; $event_text = strip_tags($event_text, ''); } if (isset($arr["organizer"])) { $organizer = urlencode(addslashes($arr["organizer"])); } else { $organizer = ''; } if (isset($arr["attendee"])) { $attendee = urlencode(addslashes($arr["attendee"])); } else { $attendee = ''; } if (isset($arr["location"])) { $location = $arr["location"]; } else { $location = ''; } if (isset($arr["status"])) { $status = $arr["status"]; } else { $status = ''; } if (isset($arr["approved"])) { $approved = $arr["approved"]; } else { $approved = 'no data'; } if (isset($arr["uid"])) { $uid = $arr["uid"]; } else { $uid = ''; } if ($event_text != "") { if ($lines) $event_text = word_wrap($event_text, $wrap, $lines); $dsc =urlencode(addslashes($arr["description"])); echo "\n[:space:]]+)", $ev, $res))) || ($dsc)) { echo "javascript:openEventInfoMy('"; echo "event="; echo urlencode(addslashes($ev)); echo "&cal="; echo urlencode(addslashes($cal)); echo "&uid="; echo urlencode(addslashes($uid)); echo "&start=$st&end=$end&description=$dsc&status=$status&location=$location&organizer=$organizer&attendee=$attendee&approved=$approved')"; } else { echo $res[1]; } echo "\">$clic$event_text$fclic"; } } $caldir = CAL_BASE; $phpMyCalJavaScript = << EOT; function phpMyCalAddEvent( $event ) { global $master_array, $calnumber; if ($event->approved) $confirmed = 1; else $confirmed = 0; $event_text = ($event->summary ? htmlentities( urlencode( str_replace( "\n", "
", $event->summary ) ) ) : ''); $description = ($event->description ? htmlentities( urlencode( str_replace( "\n", "
", $event->description ) ) ) : ''); $eventdata = array( 'calnumber' => $calnumber, 'status' => '', // not supported by phpMyCal 'class' => '', // not supported by phpMyCal 'location' => '', // not supported by phpMyCal 'organizer' => serialize( array() ), // not supported by phpMyCal 'attendee' => serialize( array() ), // not supported by phpMyCal 'event_text' => $event_text, 'description' => $description, 'uid' => $event->UID, 'approved' => $event->approved); // all day events if ($event->allday) { $master_array[date( 'Ymd', $event->start )]['-1'][$event->UID] = $eventdata; $start = strtotime( '+1 day', $event->start ); $end = $event->end; while ($end > $start) { $master_array[date( 'Ymd', $start )]['-1'][$event->UID] = $eventdata; $start = strtotime( '+1 day', $start ); } // normal events } else { $eventdata['start_unixtime'] = $event->start; $eventdata['end_unixtime'] = $event->end; $eventdata['event_length'] = round( ($event->end - $event->start) / 60 ); $start_time = date( 'Hi', $event->start ); $end_time = date( 'Hi', $event->end ); // get hour and minute same as PHP iCalendar $drawKey = drawEventTimes( $start_time, $end_time ); ereg( '([0-9]{2})([0-9]{2})', $drawKey['draw_start'], $time3 ); $hour = $time3[1]; $minute = $time3[2]; // fix for spanning multiple days, based on solution used by PHP iCalendar if (date( 'Ymd', $eventdata['start_unixtime'] ) != date( 'Ymd', $eventdata['end_unixtime'] )) { $eventdata['spans_day'] = true; $start_tmp = strtotime( date( 'Ymd', $eventdata['start_unixtime'] ) ); $end_date_tmp = date( 'Ymd', $eventdata['end_unixtime'] ); while ($start_tmp < $eventdata['end_unixtime']) { $start_date_tmp = date( 'Ymd', $start_tmp ); if ($start_date_tmp == date( 'Ymd', $eventdata['start_unixtime'] )) { $time_tmp = $hour . $minute; $start_time_tmp = $start_time; } else { $time_tmp = $start_time_tmp = '0000'; } if ($start_date_tmp == $end_date_tmp) { $end_time_tmp = $end_time; } else { $end_time_tmp = '2400'; } $eventdata['event_start'] = $start_time_tmp; $eventdata['event_end'] = $end_time_tmp; $eventdata['event_overlap'] = checkOverlap( $start_date_tmp, $start_time_tmp, $end_time_tmp, $event->UID ); $master_array[$start_date_tmp][$time_tmp][$event->UID] = $eventdata; $start_tmp = strtotime('+1 day',$start_tmp); } // doesn't span multiple days } else { $eventdata['spans_day'] = false; $eventdata['event_start'] = $start_time; $eventdata['event_end'] = $end_time; $eventdata['event_overlap'] = checkOverlap( date( 'Ymd', $event->start ), $eventdata['event_start'], $eventdata['event_end'], $event->UID ); $master_array[date( 'Ymd', $event->start )][($hour . $minute)][$event->UID] = $eventdata; } } } ?>