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); }
} break; } if ($utc < $start_utc) { continue; } $onsets[$utc] = array('from' => $comp->GetPValue('TZOFFSETFROM'), 'to' => $comp->GetPValue('TZOFFSETTO'), 'name' => $comp->GetPValue('TZNAME'), 'type' => $comp->GetType()); } return $onsets; } header('ETag: "' . $tz->etag . '"'); header('Last-Modified', $tz->last_modified); header('Content-Type: application/xml; charset="utf-8"'); $vtz = new vCalendar($tz->vtimezone); $response = new XMLDocument(array("urn:ietf:params:xml:ns:timezone-service" => "")); $timezones = $response->NewXMLElement('urn:ietf:params:xml:ns:timezone-service:timezones'); $qry = new AwlQuery('SELECT to_char(max(last_modified),\'YYYY-MM-DD"T"HH24:MI:SS"Z"\') AS dtstamp FROM timezones'); if ($qry->Exec('tz/list', __LINE__, __FILE__) && $qry->rows() > 0) { $row = $qry->Fetch(); $timezones->NewElement('dtstamp', $row->dtstamp); } else { $timezones->NewElement('dtstamp', gmdate('Y-m-d\\TH:i:s\\Z')); } $from = new RepeatRuleDateTime($start); $until = new RepeatRuleDateTime($end); $observances = expand_timezone_onsets($vtz, $from, $until); $tzdata = array(); $tzdata[] = new XMLElement('tzid', $tzid); $tzdata[] = new XMLElement('calscale', 'Gregorian'); foreach ($observances as $onset => $details) { $tzdata[] = new XMLElement('observance', array(new XMLElement('name', empty($details['name']) ? $details['type'] : $details['name']), new XMLElement('onset', $onset), new XMLElement('utc-offset-from', substr($details['from'], 0, -2) . ':' . substr($details['from'], -2)), new XMLElement('utc-offset-to', substr($details['to'], 0, -2) . ':' . substr($details['to'], -2))));
/** * Applies a properties change to a DAV resource * * @return boolean TRUE on successful creation, i18n array (msg, * [params]) otherwise */ function proppatch($user, $passwd, $calendar = '', $props = array()) { $this->prepare_client($user, $passwd, ''); // Preconditions $logmsg = ''; $usermsg = ''; $params = array(); // Empty calendar? if (empty($calendar)) { $logmsg = 'no internal name specified'; $usermsg = 'error_internalcalnamemissing'; } if (!isset($props['displayname'])) { $logmsg = 'no display name specified'; $usermsg = 'error_calnamemissing'; } if (!isset($props['color'])) { $logmsg = 'no color specified'; $usermsg = 'error_calcolormissing'; } if (!empty($logmsg)) { $this->CI->extended_logs->message('ERROR', 'Invalid call to proppatch(): ' . $logmsg); return array($usermsg, $params); } $url = $this->build_calendar_url($user, $calendar); // Create XML body $ns = array('DAV:' => '', 'urn:ietf:params:xml:ns:caldav' => 'C', 'http://apple.com/ns/ical/' => 'ical'); $xml = new XMLDocument($ns); $set = $xml->NewXMLElement('set'); $prop = $set->NewElement('prop'); $xml->NSElement($prop, 'displayname', $props['displayname']); $xml->NSElement($prop, 'http://apple.com/ns/ical/:calendar-color', $props['color']); // TODO: associate timezone? AWL doesn't like <CDATA, // gets replaced by html entity $xml_text = $xml->Render('propertyupdate', $set, null, 'http://apple.com/ns/ical/:calendar-color'); $result = $this->client->DoPROPPATCH($xml_text, $url); $success = FALSE; $logmsg = ''; $usermsg = ''; if ($result === TRUE) { $success = TRUE; } else { $logmsg = $result; $usermsg = 'error_modfailed'; } if ($success === FALSE) { $this->CI->extended_logs->message('INTERNALS', 'Calendar ' . $calendar . ' not modified.' . ' Found unexpected status on some properties: ' . $logmsg); return array($usermsg, $params); } else { $this->CI->extended_logs->message('INTERNALS', 'Calendar ' . $calendar . ' successfully modified'); return TRUE; } }
<?php /** * DAViCal Timezone Service handler - capabilitis * * @package davical * @subpackage tzservice * @author Andrew McMillan <*****@*****.**> * @copyright Morphoss Ltd * @license http://gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once 'vComponent.php'; $response = new XMLDocument(array("urn:ietf:params:xml:ns:timezone-service" => "")); $tzlist = $response->NewXMLElement('timezone-list'); $qry = new AwlQuery('SELECT to_char(max(last_modified),\'YYYY-MM-DD"T"HH24:MI:SS"Z"\') AS dtstamp FROM timezones'); if ($qry->Exec('tz/list', __LINE__, __FILE__) && $qry->rows() > 0) { $row = $qry->Fetch(); $tzlist->NewElement('dtstamp', $row->dtstamp); } else { $tzlist->NewElement('dtstamp', gmdate('Y-m-d\\TH:i:s\\Z')); } $sql = 'SELECT our_tzno, tzid, active, to_char(last_modified,\'YYYY-MM-DD"T"HH24:MI:SS"Z"\') AS last_modified, olson_name, vtimezone FROM timezones'; $params = array(); $where = ''; if ($returnall !== true) { $where = 'active'; } if (!empty($changedsince)) { if (!empty($where)) { $where .= ' AND '; }
function ischedule_cancel($ic, $attendees, $attendees_fail) { global $c, $session, $request; $reply = new XMLDocument(array("DAV:" => "", "urn:ietf:params:xml:ns:caldav" => "C", "urn:ietf:params:xml:ns:ischedule" => "I")); $responses = array(); $ical = $ic->GetComponents('VEVENT'); $ical = $ical[0]; foreach ($attendees as $k => $attendee) { $XMLresponse = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:ischedule'); dbg_error_log('ischedule', 'scheduling event for ' . $attendee->email); $schedule_target = new Principal('email', $attendee->email); $response = '3.7'; // Attendee was not found on server. if ($schedule_target->Exists()) { $attendee_calendar = new WritableCollection(array('path' => $schedule_target->internal_url('schedule-default-calendar'))); if (!$attendee_calendar->Exists()) { dbg_error_log('ERROR', 'Default calendar at "%s" does not exist for user "%s"', $attendee_calendar->dav_name(), $schedule_target->username()); $response = '5.3;cannot schedule this user, unknown or access denied'; // No scheduling support for user } else { $attendee_inbox = new WritableCollection(array('path' => $schedule_target->internal_url('schedule-inbox'))); if (!$attendee_inbox->HavePrivilegeTo('schedule-deliver-invite')) { $response = '3.8;denied'; // No authority to deliver invitations to user. } else { if ($attendee_inbox->WriteCalendarMember($ic, false) !== false) { $response = '2.0;delivered'; // Scheduling invitation delivered successfully } } } } dbg_error_log('PUT', 'Status for attendee <%s> set to "%s"', $attendee->email, $response); $XMLresponse->NewElement("recipient", $reply->href('mailto:' . $attendee->email), false, 'urn:ietf:params:xml:ns:ischedule'); $XMLresponse->NewElement("request-status", $response, false, 'urn:ietf:params:xml:ns:ischedule'); $responses[] = $XMLresponse; } foreach ($attendees_fail as $k => $attendee) { $XMLresponse = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:ischedule'); $XMLresponse->NewElement("recipient", $reply->href('mailto:' . $attendee->email), false, 'urn:ietf:params:xml:ns:ischedule'); $XMLresponse->NewElement("request-status", '5.3;cannot schedule this user, unknown or access denied', false, 'urn:ietf:params:xml:ns:ischedule'); $responses[] = $XMLresponse; } $response = $reply->NewXMLElement("schedule-response", $responses, $reply->GetXmlNsArray(), 'urn:ietf:params:xml:ns:ischedule'); $request->XMLResponse(200, $response); }