mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-09-23 06:39:18 +00:00
Start to support 'get' action.
This commit is contained in:
parent
1e81d0325e
commit
64e98acd1a
48
inc/tz/get.php
Normal file
48
inc/tz/get.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('vCalendar.php');
|
||||||
|
|
||||||
|
|
||||||
|
$sql = 'SELECT our_tzno, tzid, active, olson_name, vtimezone, etag, ';
|
||||||
|
$sql .= 'to_char(last_modified AT TIME ZONE \'UTC\',\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified ';
|
||||||
|
$sql .= 'FROM timezones WHERE tzid=:tzid';
|
||||||
|
$params = array( ':tzid' => $tzid );
|
||||||
|
$qry = new AwlQuery($sql,$params);
|
||||||
|
if ( !$qry->Exec() ) exit(1);
|
||||||
|
if ( $qry->rows() < 1 ) {
|
||||||
|
$sql = 'SELECT our_tzno, tzid, active, olson_name, vtimezone, etag, ';
|
||||||
|
$sql .= 'to_char(last_modified AT TIME ZONE \'UTC\',\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified ';
|
||||||
|
$sql .= 'FROM timezones JOIN tz_aliases USING(our_tzno) WHERE tzalias=:tzid';
|
||||||
|
if ( !$qry->Exec() ) exit(1);
|
||||||
|
if ( $qry->rows() < 1 ) $request->DoResponse(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tz = $qry->Fetch();
|
||||||
|
|
||||||
|
$vtz = new vCalendar($tz->vtimezone);
|
||||||
|
$vtz->AddProperty('TZ-URL', ConstructURL($_SERVER['REQUEST_URI']));
|
||||||
|
$vtz->AddProperty('TZNAME', $tz->olson_name );
|
||||||
|
if ( $qry->QDo('SELECT * FROM tz_localnames WHERE our_tzno = :our_tzno', array(':our_tzno'=>$tz->our_tzno)) && $qry->rows() ) {
|
||||||
|
while( $name = $qry->Fetch() ) {
|
||||||
|
if ( strpos($_SERVER['QUERY_STRING'], 'lang='.$name->locale) !== false ) {
|
||||||
|
$vtz->AddProperty('TZNAME',$name->localised_name, array('LANGUAGE',str_replace('_','-',$name->locale)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
header( 'Etag: "'.$tz->dav_etag.'"' );
|
||||||
|
header( 'Last-Modified', $tz->last_modified );
|
||||||
|
|
||||||
|
$request->DoResponse(200, $vtz->Render(), 'text/calendar');
|
||||||
|
|
||||||
|
exit(0);
|
||||||
32
testing/tests/timezone/5030-get.result
Normal file
32
testing/tests/timezone/5030-get.result
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
HTTP/1.1 200 OK
|
||||||
|
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||||
|
Etag: ""
|
||||||
|
Content-Length: 605
|
||||||
|
Content-Type: text/calendar
|
||||||
|
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
PRODID:-//Morphoss Ltd//NONSGML aCal//EN
|
||||||
|
VERSION:2.0
|
||||||
|
LAST-MODIFIED:all good
|
||||||
|
TZ-URL:
|
||||||
|
/tz.php/tz.php%3Faction%3Dget%26tzid%3DPacific/Auckland%26lang%3Den_US
|
||||||
|
TZNAME:Pacific/Auckland
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Pacific/Auckland
|
||||||
|
X-LIC-LOCATION:Pacific/Auckland
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+1200
|
||||||
|
TZOFFSETTO:+1300
|
||||||
|
TZNAME:NZDT
|
||||||
|
DTSTART:19700927T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=-1SU
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+1300
|
||||||
|
TZOFFSETTO:+1200
|
||||||
|
TZNAME:NZST
|
||||||
|
DTSTART:19700405T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
END:VCALENDAR
|
||||||
8
testing/tests/timezone/5030-get.test
Normal file
8
testing/tests/timezone/5030-get.test
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#
|
||||||
|
# List timezone server timezones
|
||||||
|
#
|
||||||
|
TYPE=GET
|
||||||
|
URL=http://regression.host/tz.php?action=get&tzid=Pacific/Auckland&lang=en_US
|
||||||
|
HEAD
|
||||||
|
|
||||||
|
REPLACE=/LAST-MODIFIED:[0-9TZ]{16}/LAST-MODIFIED:all good/
|
||||||
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
Supported locales updated.
|
|
||||||
Updated view: dav_principal.sql applied.
|
|
||||||
CalDAV functions updated.
|
|
||||||
RRULE functions updated.
|
|
||||||
Database permissions updated.
|
|
||||||
NOTE
|
|
||||||
====
|
|
||||||
* The password for the 'admin' user has been set to 'nimda'
|
|
||||||
|
|
||||||
Thanks for trying DAViCal! Check in /usr/share/doc/davical/examples/ for
|
|
||||||
some configuration examples. For help, visit #davical on irc.oftc.net.
|
|
||||||
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
Supported locales updated.
|
|
||||||
Updated view: dav_principal.sql applied.
|
|
||||||
CalDAV functions updated.
|
|
||||||
RRULE functions updated.
|
|
||||||
Database permissions updated.
|
|
||||||
Loading…
x
Reference in New Issue
Block a user