diff --git a/inc/tz/get.php b/inc/tz/get.php new file mode 100644 index 00000000..f014e2ca --- /dev/null +++ b/inc/tz/get.php @@ -0,0 +1,48 @@ + +* @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); \ No newline at end of file diff --git a/testing/tests/timezone/5030-get.result b/testing/tests/timezone/5030-get.result new file mode 100644 index 00000000..f2c0e737 --- /dev/null +++ b/testing/tests/timezone/5030-get.result @@ -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 diff --git a/testing/tests/timezone/5030-get.test b/testing/tests/timezone/5030-get.test new file mode 100644 index 00000000..e6b215e5 --- /dev/null +++ b/testing/tests/timezone/5030-get.test @@ -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/ diff --git a/testing/tests/timezones/Create-Database.result b/testing/tests/timezones/Create-Database.result deleted file mode 100644 index 0852a23a..00000000 --- a/testing/tests/timezones/Create-Database.result +++ /dev/null @@ -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. - diff --git a/testing/tests/timezones/Upgrade-Database.result b/testing/tests/timezones/Upgrade-Database.result deleted file mode 100644 index a34c672b..00000000 --- a/testing/tests/timezones/Upgrade-Database.result +++ /dev/null @@ -1,5 +0,0 @@ -Supported locales updated. -Updated view: dav_principal.sql applied. -CalDAV functions updated. -RRULE functions updated. -Database permissions updated.