Basic 'capabilities' response for timezone protocol.

This commit is contained in:
Andrew McMillan 2011-09-17 17:59:36 +12:00
parent 93b790cd52
commit b160ead5a0
2 changed files with 130 additions and 4 deletions

View File

@ -3,7 +3,7 @@
* DAViCal Timezone Service handler
*
* @package davical
* @subpackage caldav
* @subpackage tzservice
* @author Andrew McMillan <andrew@morphoss.com>
* @copyright Morphoss Ltd
* @license http://gnu.org/copyleft/gpl.html GNU GPL v3 or later
@ -12,8 +12,8 @@ require("./always.php");
require("PublicSession.php");
$session = new PublicSession();
param_to_global('action','{(capabilities|list|get|expand|update)}');
param_to_global('format','{(text/calendar|application/calendar+xml)}');
param_to_global('action','{[a-z_-]+}');
param_to_global('format','{[a-z]+/[a-zA-Z0-9.+_-]+}');
param_to_global('changesince');
param_to_global('start');
param_to_global('end');
@ -21,11 +21,12 @@ param_to_global('lang');
$returnall = isset($_GET['returnall']);
param_to_global('tzid');
require_once('CalDAVRequest.php');
$request = new CalDAVRequest();
$code_file = sprintf( 'tz/%s.php', $action );
if ( ! @include_once( $code_file ) ) {
$request->PreconditionFailed(400, "supported-action", 'The action "'+$_GET['action']+'" is not understood.' );
$request->PreconditionFailed(400, "supported-action", 'The action "'.$_GET['action'].'" is not understood.' );
}
$request->DoResponse( 500, translate("The application failed to understand that request.") );

125
inc/tz/capabilities.php Normal file
View File

@ -0,0 +1,125 @@
<?php
/**
* DAViCal Timezone Service handler - capabilitis
*
* @package davical
* @subpackage tzservice
* @author Andrew McMillan <andrew@morphoss.com>
* @copyright Morphoss Ltd
* @license http://gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
header('Content-Type: application/xml; charset="utf-8"');
?>
<?xml version="1.0" encoding="utf-8" ?>
<capabilities xmlns="urn:ietf:params:xml:ns:timezone-service">
<info>
<primary-source>Olson:2011m</primary-source>
<contact>mailto:tzs@example.org</contact>
</info>
<operation>
<action>list</action>
<description>List timezone identifiers and localized forms
</description>
<accept-parameter>
<name>lang</name>
<required>false</required>
<multi>true</multi>
<description>Specify desired localized form(s)</description>
</accept-parameter>
<accept-parameter>
<name>changedsince</name>
<required>false</required>
<multi>false</multi>
<description>Limit result to timezones changed since the
given date
</description>
</accept-parameter>
<accept-parameter>
<name>returnall</name>
<required>false</required>
<multi>false</multi>
<description>If present inactive timezones will be returned.
</description>
</accept-parameter>
</operation>
<operation>
<action>get</action>
<description>
Returns one or more timezones as specified by the
tzid parameter.
</description>
<accept-parameter>
<name>format</name>
<required>false</required>
<multi>false</multi>
<value>text/calendar</value>
<value>application/calendar+xml</value>
<description>Specify required format for timezone.
</description>
</accept-parameter>
<accept-parameter>
<name>lang</name>
<required>false</required>
<multi>true</multi>
<description>Specify desired localized form(s)</description>
</accept-parameter>
<accept-parameter>
<name>tzid</name>
<required>true</required>
<multi>true</multi>
<description>Specify desired timezone identifiers
</description>
</accept-parameter>
</operation>
<operation>
<action>expand</action>
<description>
Expands the specified timezone(s) into local onset and UTC
offsets
</description>
<accept-parameter>
<name>tzid</name>
<required>true</required>
<multi>true</multi>
<description>Specify desired timezone identifiers</description>
</accept-parameter>
<accept-parameter>
<name>start</name>
<required>false</required>
<multi>false</multi>
<description>
Specify start of the period of interest. If omitted the
current year is assumed.
</description>
</accept-parameter>
<accept-parameter>
<name>end</name>
<required>false</required>
<multi>false</multi>
<description>
Specify end of the period of interest.
If omitted the current year + 10 is assumed.
</description>
</accept-parameter>
</operation>
<operation>
<action>capabilities</action>
<description>Gets the capabilities of the server</description>
</operation>
</capabilities>
<?php
exit(0);