From 731677d623ad2f39e836d532719f3d811eb8a75d Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 14 Sep 2011 23:02:34 +1200 Subject: [PATCH] Roughing out implementation of timezone server. --- htdocs/tz.php | 32 +++++++++++++++++ htdocs/well-known.php | 4 +++ testing/tests/timezone/5000-capabilities.test | 7 ++++ testing/tests/timezone/5010-list.test | 7 ++++ .../tests/timezone/Restore-Database.result | 35 +++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 htdocs/tz.php create mode 100644 testing/tests/timezone/5000-capabilities.test create mode 100644 testing/tests/timezone/5010-list.test create mode 100644 testing/tests/timezone/Restore-Database.result diff --git a/htdocs/tz.php b/htdocs/tz.php new file mode 100644 index 00000000..9b7cdddb --- /dev/null +++ b/htdocs/tz.php @@ -0,0 +1,32 @@ + +* @copyright Morphoss Ltd +* @license http://gnu.org/copyleft/gpl.html GNU GPL v3 or later +*/ +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('changesince'); +param_to_global('start'); +param_to_global('end'); +param_to_global('lang'); +$returnall = isset($_GET['returnall']); +param_to_global('tzid'); + +$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->DoResponse( 500, translate("The application failed to understand that request.") ); + diff --git a/htdocs/well-known.php b/htdocs/well-known.php index 62348035..e44b0db1 100644 --- a/htdocs/well-known.php +++ b/htdocs/well-known.php @@ -20,6 +20,10 @@ switch ( $request->path ) { header('Location: ' . ConstructURL('/',true) ); $request->DoResponse(301); // Moved permanently // does not return. + case '/.well-known/timezone': + header('Location: ' . ConstructURL('/tz.php',true) ); + $request->DoResponse(301); // Moved permanently + // does not return. } diff --git a/testing/tests/timezone/5000-capabilities.test b/testing/tests/timezone/5000-capabilities.test new file mode 100644 index 00000000..e91490c3 --- /dev/null +++ b/testing/tests/timezone/5000-capabilities.test @@ -0,0 +1,7 @@ +# +# Request timezone server capabilities +# +TYPE=GET +URL=http://regression.host/tz.php?action=capabilities +HEAD + diff --git a/testing/tests/timezone/5010-list.test b/testing/tests/timezone/5010-list.test new file mode 100644 index 00000000..882dba7c --- /dev/null +++ b/testing/tests/timezone/5010-list.test @@ -0,0 +1,7 @@ +# +# List timezone server timezones +# +TYPE=GET +URL=http://regression.host/tz.php?action=list +HEAD + diff --git a/testing/tests/timezone/Restore-Database.result b/testing/tests/timezone/Restore-Database.result new file mode 100644 index 00000000..2ab0dfda --- /dev/null +++ b/testing/tests/timezone/Restore-Database.result @@ -0,0 +1,35 @@ + setval +-------- + 1649 +(1 row) + + setval +-------- + 1 +(1 row) + + setval +-------- + 10 +(1 row) + + setval +-------- + 10 +(1 row) + + setval +-------- + 1 +(1 row) + + setval +-------- + 7 +(1 row) + + setval +-------- + 1000 +(1 row) +