function write_updated_zone($vtimezone, $tzid) { global $new_zones, $modified_zones; if (empty($vtimezone)) { dbg_error_log('tz/updatecheck', 'Skipping zone "%s" - no data from server', $tzid); return; } $tzrow = fetch_db_zone($tzid); if (isset($tzrow) && $vtimezone == $tzrow->vtimezone) { dbg_error_log('tz/updatecheck', 'Skipping zone "%s" - no change', $tzid); return; } $vtz = new vCalendar($vtimezone); $last_modified = $vtz->GetPValue('LAST-MODIFIED'); if (empty($last_modified)) { $last_modified = gmdate('Ymd\\THis\\Z'); // Then it was probably that way when we last updated the data, too :-( if (!empty($tzrow)) { $old_vtz = new vCalendar($tzrow->vtimezone); $old_vtz->ClearProperties('LAST-MODIFIED'); // We need to add & remove this property so the Render is equivalent. $vtz->AddProperty('LAST-MODIFIED', $last_modified); $vtz->ClearProperties('LAST-MODIFIED'); if ($vtz->Render() == $old_vtz->Render()) { dbg_error_log('tz/updatecheck', 'Skipping zone "%s" - no change', $tzid); return; } } $vtz->AddProperty('LAST-MODIFIED', $last_modified); } dbg_error_log('tz/updatecheck', 'Writing %s zone for "%s"', empty($tzrow) ? "new" : "updated", $tzid); printf("Writing %s zone for '%s'\n", empty($tzrow) ? "new" : "updated", $tzid); $params = array(':tzid' => $tzid, ':olson_name' => $tzid, ':vtimezone' => $vtz->Render(), ':last_modified' => $last_modified, ':etag' => md5($vtz->Render())); if (empty($tzrow)) { $new_zones++; $sql = 'INSERT INTO timezones(tzid,active,olson_name,last_modified,etag,vtimezone) '; $sql .= 'VALUES(:tzid,TRUE,:olson_name,:last_modified,:etag,:vtimezone)'; } else { $modified_zones++; $sql = 'UPDATE timezones SET active=TRUE, olson_name=:olson_name, last_modified=:last_modified, '; $sql .= 'etag=:etag, vtimezone=:vtimezone WHERE tzid=:tzid'; } $qry = new AwlQuery($sql, $params); $qry->Exec('tz/update', __LINE__, __FILE__); }
$response = $reply->NewXMLElement("schedule-response", $responses, $reply->GetXmlNsArray(), 'urn:ietf:params:xml:ns:caldav'); $request->XMLResponse(200, $response); } function handle_cancel_request($ic) { global $c, $session, $request; $request->NeedPrivilege('CALDAV:schedule-send-reply'); $reply = new XMLDocument(array("DAV:" => "", "urn:ietf:params:xml:ns:caldav" => "C")); $response = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:caldav'); $reply->CalDAVElement($response, "request-status", "2.0;Success"); // Cargo-cult setting $response = $reply->NewXMLElement("schedule-response", $response, $reply->GetXmlNsArray()); $request->XMLResponse(200, $response); } $ical = new vCalendar($request->raw_post); $method = $ical->GetPValue('METHOD'); $resources = $ical->GetComponents('VTIMEZONE', false); $first = $resources[0]; switch ($method) { case 'REQUEST': dbg_error_log('POST', 'Handling iTIP "REQUEST" method with "%s" component.', $method, $first->GetType()); if ($first->GetType() == 'VFREEBUSY') { handle_freebusy_request($first); } elseif ($first->GetType() == 'VEVENT') { $request->NeedPrivilege('CALDAV:schedule-send-invite'); handle_schedule_request($ical); } else { dbg_error_log('POST', 'Ignoring iTIP "REQUEST" with "%s" component.', $first->GetType()); } break; case 'REPLY':