From 56968d48651518dd386a53bcd28c408ffe313aeb Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer Date: Wed, 20 Mar 2013 00:48:02 +0100 Subject: [PATCH 01/13] set line endings of most text files to LF * Changed the end-of-line encodings of all non-Windows-related and non-autogenerated text files to use UNIX LF (lots of them had mixed LF/CRLF). --- ChangeLog | 5 + config/imap_pam_conf_php.txt | 22 +- docs/api/phpdoc.ini | 178 ++++----- docs/website/style.css | 502 +++++++++++++------------- docs/website/wikiheader.css | 134 +++---- htdocs/caldav.php | 4 +- htdocs/setup.php | 10 +- inc/CalDAVRequest.php | 12 +- inc/DAViCalSession.php | 22 +- inc/WritableCollection.php | 42 +-- inc/caldav-BIND.php | 6 +- inc/caldav-DELETE.php | 6 +- inc/caldav-GET-functions.php | 4 +- inc/caldav-MKCOL.php | 2 +- inc/caldav-POST.php | 16 +- inc/caldav-PROPPATCH.php | 40 +- inc/caldav-PUT-functions.php | 46 +-- inc/caldav-PUT-vcalendar.php | 14 +- inc/caldav-PUT-vcard.php | 36 +- inc/caldav-REPORT-calquery.php | 2 +- inc/caldav-REPORT-cardquery.php | 2 +- inc/caldav-REPORT-multiget.php | 2 +- inc/caldav-REPORT-sync-collection.php | 2 +- inc/caldav-REPORT.php | 6 +- inc/drivers_imap_pam.php | 214 +++++------ inc/drivers_ldap.php | 26 +- inc/drivers_rimap.php | 224 ++++++------ inc/schedule-functions.php | 6 +- inc/ui/collection-edit.php | 6 +- inc/ui/principal-edit.php | 6 +- 30 files changed, 801 insertions(+), 796 deletions(-) diff --git a/ChangeLog b/ChangeLog index f38afc7f..ed20829b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-03-20 Christoph Anton Mitterer + * Changed the end-of-line encodings of all non-Windows-related and + non-autogenerated text files to use UNIX LF (lots of them had mixed + LF/CRLF). + 2013-03-06 Andrew McMillan * Fix capitalisation of 'plpgsql' & 'sql' for Postgres 9.2. (debbug #702403) diff --git a/config/imap_pam_conf_php.txt b/config/imap_pam_conf_php.txt index a4e026f4..b7574782 100644 --- a/config/imap_pam_conf_php.txt +++ b/config/imap_pam_conf_php.txt @@ -1,11 +1,11 @@ -/** - * Authentication against IMAP using the imap_open function. - */ -$c->authenticate_hook['call'] = 'IMAP_PAM_check'; -$c->authenticate_hook['config'] = array( - 'imap_url' => '{localhost:993/imap/ssl/novalidate-cert}', - 'email_base' => 'example.com' -); - -include('drivers_imap_pam.php'); - +/** + * Authentication against IMAP using the imap_open function. + */ +$c->authenticate_hook['call'] = 'IMAP_PAM_check'; +$c->authenticate_hook['config'] = array( + 'imap_url' => '{localhost:993/imap/ssl/novalidate-cert}', + 'email_base' => 'example.com' +); + +include('drivers_imap_pam.php'); + diff --git a/docs/api/phpdoc.ini b/docs/api/phpdoc.ini index e5a12811..c1c7c2f1 100644 --- a/docs/api/phpdoc.ini +++ b/docs/api/phpdoc.ini @@ -1,89 +1,89 @@ -;; phpDocumentor configuration file for DAViCal API documentation -;; - -[Parse Data] -;; title of all the documentation -;; legal values: any string -title = DAViCal - -;; parse files that start with a . like .bash_profile -;; legal values: true, false -hidden = false - -;; show elements marked @access private in documentation by setting this to on -;; legal values: on, off -parseprivate = off - -;; parse with javadoc-like description (first sentence is always the short description) -;; legal values: on, off -javadocdesc = off - -;; add any custom @tags separated by commas here -;; legal values: any legal tagname separated by commas. -;customtags = mytag1,mytag2 - -;; This is only used by the XML:DocBook/peardoc2 converter -defaultcategoryname = Documentation - -;; what is the main package? -;; legal values: alphanumeric string plus - and _ -defaultpackagename = davical - -;; output any parsing information? set to on for cron jobs -;; legal values: on -quiet = on - -;; parse a PEAR-style repository. Do not turn this on if your project does -;; not have a parent directory named "pear" -;; legal values: on/off -;pear = on - -;; where should the documentation be written? -;; legal values: a legal path -target = docs/api - -;; Which files should be parsed out as special documentation files, such as README, -;; INSTALL and CHANGELOG? This overrides the default files found in -;; phpDocumentor.ini (this file is not a user .ini file, but the global file) -readmeinstallchangelog = README, INSTALL, CHANGELOG, NEWS, FAQ, LICENSE - -;; limit output to the specified packages, even if others are parsed -;; legal values: package names separated by commas -;packageoutput = package1,package2 -packageoutput = davical,awl - -;; comma-separated list of files to parse -;; legal values: paths separated by commas -;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory - -;; comma-separated list of directories to parse -;; legal values: directory paths separated by commas -;directory = /path1,/path2,.,..,subdirectory -;directory = /home/jeichorn/cvs/pear -directory = inc,htdocs - -;; template base directory (the equivalent directory of /phpDocumentor) -;templatebase = /path/to/my/templates - -;; directory to find any example files in through @example and {@example} tags -;examplesdir = /path/to/my/templates -examplesdir = examples - -;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore -;; legal values: any wildcard strings separated by commas -;ignore = /path/to/ignore*,*list.php,myfile.php,subdirectory/ -ignore = htdocs/css/,htdocs/images/,htdocs/js/, - -;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format -;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib, -;; HTML:frames:earthli, -;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de, -;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli -;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS -;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default -output=HTML:frames:earthli - -;; turn this option on if you want highlighted source code for every file -;; legal values: on/off -sourcecode = off - +;; phpDocumentor configuration file for DAViCal API documentation +;; + +[Parse Data] +;; title of all the documentation +;; legal values: any string +title = DAViCal + +;; parse files that start with a . like .bash_profile +;; legal values: true, false +hidden = false + +;; show elements marked @access private in documentation by setting this to on +;; legal values: on, off +parseprivate = off + +;; parse with javadoc-like description (first sentence is always the short description) +;; legal values: on, off +javadocdesc = off + +;; add any custom @tags separated by commas here +;; legal values: any legal tagname separated by commas. +;customtags = mytag1,mytag2 + +;; This is only used by the XML:DocBook/peardoc2 converter +defaultcategoryname = Documentation + +;; what is the main package? +;; legal values: alphanumeric string plus - and _ +defaultpackagename = davical + +;; output any parsing information? set to on for cron jobs +;; legal values: on +quiet = on + +;; parse a PEAR-style repository. Do not turn this on if your project does +;; not have a parent directory named "pear" +;; legal values: on/off +;pear = on + +;; where should the documentation be written? +;; legal values: a legal path +target = docs/api + +;; Which files should be parsed out as special documentation files, such as README, +;; INSTALL and CHANGELOG? This overrides the default files found in +;; phpDocumentor.ini (this file is not a user .ini file, but the global file) +readmeinstallchangelog = README, INSTALL, CHANGELOG, NEWS, FAQ, LICENSE + +;; limit output to the specified packages, even if others are parsed +;; legal values: package names separated by commas +;packageoutput = package1,package2 +packageoutput = davical,awl + +;; comma-separated list of files to parse +;; legal values: paths separated by commas +;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory + +;; comma-separated list of directories to parse +;; legal values: directory paths separated by commas +;directory = /path1,/path2,.,..,subdirectory +;directory = /home/jeichorn/cvs/pear +directory = inc,htdocs + +;; template base directory (the equivalent directory of /phpDocumentor) +;templatebase = /path/to/my/templates + +;; directory to find any example files in through @example and {@example} tags +;examplesdir = /path/to/my/templates +examplesdir = examples + +;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore +;; legal values: any wildcard strings separated by commas +;ignore = /path/to/ignore*,*list.php,myfile.php,subdirectory/ +ignore = htdocs/css/,htdocs/images/,htdocs/js/, + +;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format +;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib, +;; HTML:frames:earthli, +;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de, +;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli +;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS +;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default +output=HTML:frames:earthli + +;; turn this option on if you want highlighted source code for every file +;; legal values: on/off +sourcecode = off + diff --git a/docs/website/style.css b/docs/website/style.css index 5e059868..d42f19b2 100644 --- a/docs/website/style.css +++ b/docs/website/style.css @@ -1,251 +1,251 @@ -* { - margin: 0px; - padding: 0px; - } - -body { - margin: 0px; - padding: 0px; - background-color: #FFFFFF; - color: #333333; - } - -hr { - height: 0.4em; - width: 100%; - background-color: #000000; - border: none; - color:#000000; - margin-bottom: 0.5em; - } - -#pageContainer { - width: 740px; - margin-left: auto; - margin-right: auto; - } - -#header { - width: 740px; - height: 80px; - background: url(images/logo.gif) #bb1f1f no-repeat center left; - margin-top: 10px; - border-bottom: #d2d2d2 solid 5px; - text-align: right; - margin-bottom: 20px; - } - -#headerLinks { - color: #FFFFFF; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 80%; - padding-top: 64px; - padding-right: 5px; - display:block; - text-decoration: none; - } - -.hlink { - color: #FFFFFF; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 80%; - text-decoration: none; -} -.hlink:link, .hlink:active, .hlink:visited { - color: #FFFFFF; -} - -.hlink:hover { - color: #FFFFFF; - text-decoration: underline; -} - -#pageContent { - /* Not used for anything at present */ - } - -h1 { - color: #600000; - font-family: helvetica, arial, sans-serif; - font-size: 135%; - margin-top: 1em; - margin-bottom: 0.3em; - } - -h2, h3 { - color: black; - font-family: helvetica, arial, sans-serif; - font-size: 115%; - margin-top: 1em; - margin-bottom: 0.3em; - } - -h3 { - font-size: 100%; -} - -.showcase { - margin: 2px; - padding: 2px; - border: 2px #000000 solid; - } - -p { - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 90%; - margin-bottom: 20px; - } - -ol, ul { - margin-bottom: 20px; -} - -ul { - list-style-type: square; - font-family: helvetica, arial, sans-serif; -} - -li { - list-style-position: outside; - font-family: helvetica, arial, sans-serif; - font-size: 90%; - margin: 0.1em 2em; - } - -code { - font-family: courier, courier new, fixed; - font-size: inherit; -} - -pre { - font-family: courier, courier new, fixed; - font-size: 90%; - padding: 1em; - margin-bottom: 1em; - background-color: #eee; -} - -#footer { - clear: both; - width: 740px; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 80%; - border-top: 2px #000000 solid; - } - -#title { - float: left; - color: #FFFFFF; - padding-left: 100px; - margin-top: 1px; - font-family: helvetica, arial, sans-serif; - font-size: 190%; - } - -#subTitle { - float: left; - clear: left; - color: #FFFFFF; - padding-left: 102px; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 75%; -} - -.right { - float: right; - margin: 0px; - } - -.left { - float: left; - margin: 0px; - } - -.flink:link { - color: #333333; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 80%; - text-decoration: none; - vertical-align: text-top; - } - -.flink:active { - color: #333333; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 80%; - text-decoration: none; - vertical-align: text-top; - } - -.flink:hover { - color: #333333; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 80%; - text-decoration: underline; - vertical-align: text-top; - } - -.flink:visited { - color: #333333; - font-family: helvetica, arial, sans-serif; - font-size: 8pt; - font-size: 80%; - text-decoration: none; - vertical-align: text-top; - } - -.gone { - width: 0.01em; - height: 0.01em; -} - -.prompt { - font-weight: 700; - width: 4em; - } - -#leftSide { - width: 170px; - float: left; -} - -#leftSide p { - text-align: center; - margin-bottom: 1em; - padding:0.3em 0; - font-weight: bold; - background-color: #d2d2d2; -} - -#leftSide p.selected { - background-color: #bb1f1f; - color: white; -} - -#leftSide img { - border: none; -} - -#leftSide a, #leftSide a:link, #leftSide a:hover, #leftSide a:active, #leftSide a:visited { - text-decoration: none; - color: black; -} - -#leftSide a.selected, #leftSide a.selected:link, #leftSide a.selected:hover, #leftSide a.selected:active, #leftSide a.selected:visited { - text-decoration: none; - color: white; -} - -#rightSide { - width: 530px; - float: right; -} - +* { + margin: 0px; + padding: 0px; + } + +body { + margin: 0px; + padding: 0px; + background-color: #FFFFFF; + color: #333333; + } + +hr { + height: 0.4em; + width: 100%; + background-color: #000000; + border: none; + color:#000000; + margin-bottom: 0.5em; + } + +#pageContainer { + width: 740px; + margin-left: auto; + margin-right: auto; + } + +#header { + width: 740px; + height: 80px; + background: url(images/logo.gif) #bb1f1f no-repeat center left; + margin-top: 10px; + border-bottom: #d2d2d2 solid 5px; + text-align: right; + margin-bottom: 20px; + } + +#headerLinks { + color: #FFFFFF; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 80%; + padding-top: 64px; + padding-right: 5px; + display:block; + text-decoration: none; + } + +.hlink { + color: #FFFFFF; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 80%; + text-decoration: none; +} +.hlink:link, .hlink:active, .hlink:visited { + color: #FFFFFF; +} + +.hlink:hover { + color: #FFFFFF; + text-decoration: underline; +} + +#pageContent { + /* Not used for anything at present */ + } + +h1 { + color: #600000; + font-family: helvetica, arial, sans-serif; + font-size: 135%; + margin-top: 1em; + margin-bottom: 0.3em; + } + +h2, h3 { + color: black; + font-family: helvetica, arial, sans-serif; + font-size: 115%; + margin-top: 1em; + margin-bottom: 0.3em; + } + +h3 { + font-size: 100%; +} + +.showcase { + margin: 2px; + padding: 2px; + border: 2px #000000 solid; + } + +p { + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 90%; + margin-bottom: 20px; + } + +ol, ul { + margin-bottom: 20px; +} + +ul { + list-style-type: square; + font-family: helvetica, arial, sans-serif; +} + +li { + list-style-position: outside; + font-family: helvetica, arial, sans-serif; + font-size: 90%; + margin: 0.1em 2em; + } + +code { + font-family: courier, courier new, fixed; + font-size: inherit; +} + +pre { + font-family: courier, courier new, fixed; + font-size: 90%; + padding: 1em; + margin-bottom: 1em; + background-color: #eee; +} + +#footer { + clear: both; + width: 740px; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 80%; + border-top: 2px #000000 solid; + } + +#title { + float: left; + color: #FFFFFF; + padding-left: 100px; + margin-top: 1px; + font-family: helvetica, arial, sans-serif; + font-size: 190%; + } + +#subTitle { + float: left; + clear: left; + color: #FFFFFF; + padding-left: 102px; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 75%; +} + +.right { + float: right; + margin: 0px; + } + +.left { + float: left; + margin: 0px; + } + +.flink:link { + color: #333333; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 80%; + text-decoration: none; + vertical-align: text-top; + } + +.flink:active { + color: #333333; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 80%; + text-decoration: none; + vertical-align: text-top; + } + +.flink:hover { + color: #333333; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 80%; + text-decoration: underline; + vertical-align: text-top; + } + +.flink:visited { + color: #333333; + font-family: helvetica, arial, sans-serif; + font-size: 8pt; + font-size: 80%; + text-decoration: none; + vertical-align: text-top; + } + +.gone { + width: 0.01em; + height: 0.01em; +} + +.prompt { + font-weight: 700; + width: 4em; + } + +#leftSide { + width: 170px; + float: left; +} + +#leftSide p { + text-align: center; + margin-bottom: 1em; + padding:0.3em 0; + font-weight: bold; + background-color: #d2d2d2; +} + +#leftSide p.selected { + background-color: #bb1f1f; + color: white; +} + +#leftSide img { + border: none; +} + +#leftSide a, #leftSide a:link, #leftSide a:hover, #leftSide a:active, #leftSide a:visited { + text-decoration: none; + color: black; +} + +#leftSide a.selected, #leftSide a.selected:link, #leftSide a.selected:hover, #leftSide a.selected:active, #leftSide a.selected:visited { + text-decoration: none; + color: white; +} + +#rightSide { + width: 530px; + float: right; +} + diff --git a/docs/website/wikiheader.css b/docs/website/wikiheader.css index 868a60f9..39c040b7 100644 --- a/docs/website/wikiheader.css +++ b/docs/website/wikiheader.css @@ -1,67 +1,67 @@ - -#logo { - height: 80px; - width: 99.9%; - background: url(images/logo.gif) #bb1f1f no-repeat center left; - margin-left: 0px; - margin-top: 0px; - border-bottom: #d2d2d2 solid 5px; - text-align: right; - margin-bottom: 5px; - font-family: helvetica, arial, serif; - font-weight: normal; - font-size: 1em; - color: #FFFFFF; - display:block; -} - -#title { - float: left; - color: #FFFFFF; - padding-left: 100px; - margin-top: 10px; - font-size: 190%; - } - -#subTitle { - float: left; - clear: left; - color: #FFFFFF; - padding-left: 102px; - padding-top: 3px; - margin-top: 5px; - font-size: 75%; -} - - -#headerLinks { - color: #FFFFFF; - font-family: helvetica, arial, sans-serif; - font-size: 65%; - padding-top: 60px; - padding-right: 5px; - } - -#headerLinks .hlink { - color: #FFFFFF; - } - -#headerLinks .hlink:link { - color: #FFFFFF; - text-decoration: none; - } - -#headerLinks .hlink:active { - color: #FFFFFF; - text-decoration: none; - } - -#headerLinks .hlink:hover { - color: #FFFFFF; - text-decoration: underline; - } - -#headerLinks .hlink:visited { - color: #FFFFFF; - } - + +#logo { + height: 80px; + width: 99.9%; + background: url(images/logo.gif) #bb1f1f no-repeat center left; + margin-left: 0px; + margin-top: 0px; + border-bottom: #d2d2d2 solid 5px; + text-align: right; + margin-bottom: 5px; + font-family: helvetica, arial, serif; + font-weight: normal; + font-size: 1em; + color: #FFFFFF; + display:block; +} + +#title { + float: left; + color: #FFFFFF; + padding-left: 100px; + margin-top: 10px; + font-size: 190%; + } + +#subTitle { + float: left; + clear: left; + color: #FFFFFF; + padding-left: 102px; + padding-top: 3px; + margin-top: 5px; + font-size: 75%; +} + + +#headerLinks { + color: #FFFFFF; + font-family: helvetica, arial, sans-serif; + font-size: 65%; + padding-top: 60px; + padding-right: 5px; + } + +#headerLinks .hlink { + color: #FFFFFF; + } + +#headerLinks .hlink:link { + color: #FFFFFF; + text-decoration: none; + } + +#headerLinks .hlink:active { + color: #FFFFFF; + text-decoration: none; + } + +#headerLinks .hlink:hover { + color: #FFFFFF; + text-decoration: underline; + } + +#headerLinks .hlink:visited { + color: #FFFFFF; + } + diff --git a/htdocs/caldav.php b/htdocs/caldav.php index f6ddf918..0ea34be6 100644 --- a/htdocs/caldav.php +++ b/htdocs/caldav.php @@ -99,8 +99,8 @@ if ( ! ($request->IsPrincipal() || isset($request->collection) || $request->meth @ob_flush(); exit(0); } } -param_to_global('add_member','.*'); -$add_member = isset($add_member); +param_to_global('add_member','.*'); +$add_member = isset($add_member); switch ( $request->method ) { case 'OPTIONS': include_once('caldav-OPTIONS.php'); break; diff --git a/htdocs/setup.php b/htdocs/setup.php index 77a846cc..54345f39 100644 --- a/htdocs/setup.php +++ b/htdocs/setup.php @@ -25,9 +25,9 @@ function catch_setup_errors($errno , $errstr , $errfile , $errline , $errcontext return true; } else if ( $errno == 256 ) { - // This will (probably) be a database connection error, which will throw an exception if we return. - log_setup_error($errno , $errstr , $errfile , $errline); - return true; + // This will (probably) be a database connection error, which will throw an exception if we return. + log_setup_error($errno , $errstr , $errfile , $errline); + return true; } if ( !headers_sent() ) header("Content-type: text/plain"); else echo "
\n";
   try {
@@ -207,7 +207,7 @@ catch( Exception $e ) {
       return true;
     }
   }
-  $session = new FakeSession(1);
+  $session = new FakeSession(1);
 }
 
 
@@ -261,7 +261,7 @@ function check_davical_version() {
       $result->setDescription( sprintf(i18n('Stable: %s, We have: %s !'), $current_version, $c->version_string) );
     }
     else {
-      $result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), $current_version, $c->version_string) );
+      $result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), $current_version, $c->version_string) );
     }
   }
   return $result;
diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php
index c89fd96a..d6003a6a 100644
--- a/inc/CalDAVRequest.php
+++ b/inc/CalDAVRequest.php
@@ -122,7 +122,7 @@ class CalDAVRequest
     if ( !isset($this->options['allow_by_email']) ) $this->options['allow_by_email'] = false;
 
     if ( isset($_SERVER['HTTP_PREFER']) ) {
-      $this->prefer = explode( ',', $_SERVER['HTTP_PREFER']);
+      $this->prefer = explode( ',', $_SERVER['HTTP_PREFER']);
     }
     else if ( isset($_SERVER['HTTP_BRIEF']) && (strtoupper($_SERVER['HTTP_BRIEF']) == 'T') ) {
       $this->prefer = array( 'return-minimal');
@@ -1268,9 +1268,9 @@ EOSQL;
     exit(0);  // Unecessary, but might clarify things
   }
 
-  public static function kill_on_exit() {
-    posix_kill( getmypid(), 28 );
-  }
+  public static function kill_on_exit() {
+    posix_kill( getmypid(), 28 );
+  }
   
   /**
   * Utility function we call when we have a simple status-based response to
@@ -1330,8 +1330,8 @@ EOSQL;
     if ( isset($c->exit_after_memory_exceeds) && function_exists('memory_get_peak_usage') && memory_get_peak_usage(true) > $c->exit_after_memory_exceeds ) { // 64M
       @dbg_error_log("statistics", "Peak memory use exceeds %d bytes (%d) - killing process %d", $c->exit_after_memory_exceeds, memory_get_peak_usage(true), getmypid());
       register_shutdown_function( 'CalDAVRequest::kill_on_exit' );
-    }
-    
+    }
+    
     
     exit(0);
   }
diff --git a/inc/DAViCalSession.php b/inc/DAViCalSession.php
index 09bf9fd5..a6398f2a 100644
--- a/inc/DAViCalSession.php
+++ b/inc/DAViCalSession.php
@@ -35,7 +35,7 @@ EOSQL;
 * We extend the AWL Session class.
 */
 require('Session.php');
-include_once('DAVResource.php');
+include_once('DAVResource.php');
 
 
 @Session::_CheckLogout();
@@ -101,26 +101,26 @@ class DAViCalSession extends Session
   }
 
 
-  /**
-   * Does the user have the privileges to do what is requested.
-   * @param $do_what mixed The request privilege name, or array of privilege names, to be checked.
+  /**
+   * Does the user have the privileges to do what is requested.
+   * @param $do_what mixed The request privilege name, or array of privilege names, to be checked.
    * @param $path string The path we want that permission for
-   * @param $any boolean Whether we accept any of the privileges. The default is true, unless the requested privilege is 'all', when it is false.
-   * @return boolean Whether they do have one of those privileges against the specified path.
-   */
+   * @param $any boolean Whether we accept any of the privileges. The default is true, unless the requested privilege is 'all', when it is false.
+   * @return boolean Whether they do have one of those privileges against the specified path.
+   */
   function HavePrivilegeTo( $do_what, $path, $any = null ) {
     if ( $this->AllowedTo('Admin') ) return true;
     if ( !isset($this->privilege_resources[$path]) ) {
       $this->privilege_resources[$path] = new DAVResource($path);
     }
-    $resource = $this->privilege_resources[$path];
+    $resource = $this->privilege_resources[$path];
     if ( isset($resource) && $resource->Exists() ) {
       return $resource->HavePrivilegeTo($do_what,$any);
     }
     return false;
-  }
-
-
+  }
+
+
 
   /**
   * Checks that this user is logged in, and presents a login screen if they aren't.
diff --git a/inc/WritableCollection.php b/inc/WritableCollection.php
index 76832c06..267d3897 100644
--- a/inc/WritableCollection.php
+++ b/inc/WritableCollection.php
@@ -450,33 +450,33 @@ EOSQL;
    */
   public function whatChangedSince( $some_old_token ) {
     $params = array( ':collection_id' => $this->collection_id() );
-    if ( $some_old_token == 0 || empty($some_old_token) ) {
-      $sql = <<= (SELECT modification_time FROM sync_tokens WHERE sync_token = :sync_token)
+         COALESCE(addressbook_resource.uid,calendar_item.uid) AS uid
+      FROM sync_changes
+      LEFT JOIN caldav_data USING (collection_id,dav_id)
+      LEFT JOIN calendar_item USING (collection_id,dav_id)
+      LEFT JOIN addressbook_resource USING (dav_id)
+      WHERE sync_changes.collection_id = :collection_id
+            AND sync_time >= (SELECT modification_time FROM sync_tokens WHERE sync_token = :sync_token)
       ORDER BY sync_changes.collection_id, sync_changes.dav_id, sync_changes.sync_time
-EOSQL;
-
-    }
-    $qry = new AwlQuery($sql, $params );
+EOSQL;
+
+    }
+    $qry = new AwlQuery($sql, $params );
 
     $changes = array();
     if ( $qry->Exec('WritableCollection') && $qry->rows() ) {
diff --git a/inc/caldav-BIND.php b/inc/caldav-BIND.php
index 4736d157..0e3d8b8c 100644
--- a/inc/caldav-BIND.php
+++ b/inc/caldav-BIND.php
@@ -99,9 +99,9 @@ else {
     $request->PreconditionFailed(403,'DAV::binding-allowed',translate('DAViCal only allows BIND requests for collections at present.'));
   }
   
-  if ( $source->IsBinding() )
-    $source = new DAVResource( $source->bound_from() );
-
+  if ( $source->IsBinding() )
+    $source = new DAVResource( $source->bound_from() );
+
 
   /*
     bind_id INT8 DEFAULT nextval('dav_id_seq') PRIMARY KEY,
diff --git a/inc/caldav-DELETE.php b/inc/caldav-DELETE.php
index 52add374..ac3715ec 100644
--- a/inc/caldav-DELETE.php
+++ b/inc/caldav-DELETE.php
@@ -86,9 +86,9 @@ else {
     && $qry->QDo("DELETE FROM locks WHERE dav_name = (SELECT dav_name FROM caldav_data WHERE dav_id = :dav_id)", $params )
     && $qry->QDo("SELECT write_sync_change(collection_id, 404, caldav_data.dav_name) FROM caldav_data WHERE dav_id = :dav_id", $params )
     && $qry->QDo("DELETE FROM caldav_data WHERE dav_id = :dav_id", $params ) ) {
-    if ( function_exists('log_caldav_action') ) {
-      log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $collection_id, $request->path );
-    }
+    if ( function_exists('log_caldav_action') ) {
+      log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $collection_id, $request->path );
+    }
     
     $qry->Commit();
     @dbg_error_log( "DELETE", "DELETE: User: %d, ETag: %s, Path: %s", $session->user_no, $request->etag_if_match, $request->path);
diff --git a/inc/caldav-GET-functions.php b/inc/caldav-GET-functions.php
index 1f45cb38..d91c233f 100644
--- a/inc/caldav-GET-functions.php
+++ b/inc/caldav-GET-functions.php
@@ -76,10 +76,10 @@ function export_iCalendar( DAVResource $dav_resource ) {
     $vcal->AddProperty("X-WR-CALNAME", $displayname);
   }
   if ( !empty($c->auto_refresh_duration) ) {
-    $vcal->AddProperty("X-APPLE-AUTO-REFRESH-INTERVAL", $c->auto_refresh_duration);
+    $vcal->AddProperty("X-APPLE-AUTO-REFRESH-INTERVAL", $c->auto_refresh_duration);
     $vcal->AddProperty("AUTO-REFRESH", $c->auto_refresh_duration);
     $vcal->AddProperty("X-PUBLISHED-TTL", $c->auto_refresh_duration);
-  }
+  }
   
   $need_zones = array();
   $timezones = array();
diff --git a/inc/caldav-MKCOL.php b/inc/caldav-MKCOL.php
index 261f3d86..79cae799 100644
--- a/inc/caldav-MKCOL.php
+++ b/inc/caldav-MKCOL.php
@@ -65,7 +65,7 @@ if ( isset($request->xml_tags) ) {
 
   foreach( $setprops AS $k => $setting ) {
     $tag = $setting->GetNSTag();
-    $content = $setting->RenderContent(0,null,true);
+    $content = $setting->RenderContent(0,null,true);
     
     dbg_error_log( 'MKCOL', 'Processing tag "%s"', $tag);
 
diff --git a/inc/caldav-POST.php b/inc/caldav-POST.php
index 58323a8b..26629a63 100644
--- a/inc/caldav-POST.php
+++ b/inc/caldav-POST.php
@@ -15,14 +15,14 @@ include_once('caldav-PUT-functions.php');
 include_once('freebusy-functions.php');
 include_once('iSchedule.php');
 
-if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['post'])) ) {
-  $fh = fopen('/tmp/POST.txt','w');
-  if ( $fh ) {
-    fwrite($fh,$request->raw_post);
-    fclose($fh);
-  }
-}
-
+if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['post'])) ) {
+  $fh = fopen('/tmp/POST.txt','w');
+  if ( $fh ) {
+    fwrite($fh,$request->raw_post);
+    fclose($fh);
+  }
+}
+
 
 function handle_freebusy_request( $ic ) {
   global $c, $session, $request, $ical;
diff --git a/inc/caldav-PROPPATCH.php b/inc/caldav-PROPPATCH.php
index 1daebb8c..b47a6c49 100644
--- a/inc/caldav-PROPPATCH.php
+++ b/inc/caldav-PROPPATCH.php
@@ -45,7 +45,7 @@ $rmprops  = $xmltree->GetPath("/DAV::propertyupdate/DAV::remove/DAV::prop/*");
 $failure   = array();
 $success   = array();
 
-$reply = new XMLDocument( array( 'DAV:' => '') );
+$reply = new XMLDocument( array( 'DAV:' => '') );
 
 /**
  * Small utility function to add propstat for one failure
@@ -55,19 +55,19 @@ $reply = new XMLDocument( array( 'DAV:' => '') );
  * @param unknown_type $error_tag
  */
 function add_failure( $type, $tag, $status, $description=null, $error_tag = null) {
-  global $failure, $reply;
+  global $failure, $reply;
   $prop = new XMLElement('prop');
   $reply->NSElement($prop, $tag);
   $propstat = array($prop,new XMLElement( 'status', $status ));
-
-  if ( isset($description))
-    $propstat[] = new XMLElement( 'responsedescription', $description );
-  if ( isset($error_tag) )
-    $propstat[] = new XMLElement( 'error', new XMLElement( $error_tag ) );
+
+  if ( isset($description))
+    $propstat[] = new XMLElement( 'responsedescription', $description );
+  if ( isset($error_tag) )
+    $propstat[] = new XMLElement( 'error', new XMLElement( $error_tag ) );
 
   $failure[$type.'-'.$tag] = new XMLElement('propstat', $propstat ); 
-}
-
+}
+
 
 /**
 * Not much for it but to process the incoming settings in a big loop, doing
@@ -139,8 +139,8 @@ foreach( $setprops AS $k => $setting ) {
         $success[$tag] = 1;
       }
       else if ( $setcalendar && $setaddressbook ) {
-        add_failure('set', $tag, 'HTTP/1.1 409 Conflict',
-            translate("A collection may not be both a calendar and an addressbook."));
+        add_failure('set', $tag, 'HTTP/1.1 409 Conflict',
+            translate("A collection may not be both a calendar and an addressbook."));
       }
       else if ( $setother ) {
         add_failure('set', $tag, 'HTTP/1.1 403 Forbidden',
@@ -285,20 +285,20 @@ foreach( $rmprops AS $k => $setting ) {
 */
 if ( count($failure) > 0 ) {
 
-  $qry->Rollback();
+  $qry->Rollback();
   
   $url = ConstructURL($request->path);
   $multistatus = new XMLElement('multistatus');
-  array_unshift($failure,new XMLElement('responsedescription', translate("Some properties were not able to be changed.") ));
+  array_unshift($failure,new XMLElement('responsedescription', translate("Some properties were not able to be changed.") ));
   array_unshift($failure,new XMLElement('href', $url));
-  $response = $reply->DAVElement($multistatus,'response', $failure);
+  $response = $reply->DAVElement($multistatus,'response', $failure);
   
   if ( !empty($success) ) { 
-    $prop = new XMLElement('prop');
-    foreach( $success AS $tag => $v ) {
-      $reply->NSElement($prop, $tag);
-    }
-    $reply->DAVElement($response, 'propstat', array( $prop, new XMLElement( 'status', 'HTTP/1.1 424 Failed Dependency' )) );
+    $prop = new XMLElement('prop');
+    foreach( $success AS $tag => $v ) {
+      $reply->NSElement($prop, $tag);
+    }
+    $reply->DAVElement($response, 'propstat', array( $prop, new XMLElement( 'status', 'HTTP/1.1 424 Failed Dependency' )) );
   }  
   $request->DoResponse( 207, $reply->Render($multistatus), 'text/xml; charset="utf-8"' );
 
@@ -334,7 +334,7 @@ if ( $qry->Commit() ) {
   foreach( $success AS $tag => $v ) {
     $reply->NSElement($prop, $tag);
   }
-  $reply->DAVElement($multistatus, 'propstat', array( $prop, new XMLElement( 'status', 'HTTP/1.1 200 OK' )) );
+  $reply->DAVElement($multistatus, 'propstat', array( $prop, new XMLElement( 'status', 'HTTP/1.1 200 OK' )) );
   
   $url = ConstructURL($request->path);
   array_unshift( $failure, new XMLElement('href', $url ) );
diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php
index 5825cb43..79d48499 100644
--- a/inc/caldav-PUT-functions.php
+++ b/inc/caldav-PUT-functions.php
@@ -20,7 +20,7 @@ require_once('vComponent.php');
 require_once('vCalendar.php');
 require_once('WritableCollection.php');
 include_once('iSchedule.php');
-include_once('RRule-v2.php');
+include_once('RRule-v2.php');
 
 $bad_events = null;
 
@@ -842,8 +842,8 @@ INSERT INTO caldav_data ( user_no, dav_name, dav_etag, caldav_data, caldav_type,
 EOSQL;
 
   $dav_data_update = << 0 )
-    $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')');
+    $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')');
   
   foreach( $resources AS $uid => $resource ) {
 
@@ -885,10 +885,10 @@ EOSQL;
       unset($current_data[$dav_name]);
       $inserting = false;
     }
-    else
-      $sync_change = 201;
+    else
+      $sync_change = 201;
     
-    if ( isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import ) $qry->Begin();
+    if ( isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import ) $qry->Begin();
     
     /** As ever, we mostly deal with the first resource component */
     $first = $resource[0];
@@ -947,7 +947,7 @@ EOSQL;
         $dtstart_prop = $first->GetProperty('DTSTART');
         if ( empty($dtstart_prop) ) {
           dbg_error_log('PUT','Invalid VEVENT without DTSTART, UID="%s" in collection %d', $uid, $collection_id);
-          continue;
+          continue;
         } 
         $value_type = $dtstart_prop->GetParameterValue('VALUE');
         dbg_error_log('PUT','DTSTART without DTEND. DTSTART value type is %s', $value_type );
@@ -1024,13 +1024,13 @@ EOSQL;
     write_alarms($dav_id, $first);
     write_attendees($dav_id, $vcal);
 
-    $qry->QDo("SELECT write_sync_change( $collection_id, $sync_change, :dav_name)", array(':dav_name' => $dav_name ) );
+    $qry->QDo("SELECT write_sync_change( $collection_id, $sync_change, :dav_name)", array(':dav_name' => $dav_name ) );
     
     do_scheduling_requests( $vcal, true );
     if ( isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import ) $qry->Commit();
   }
 
-  if ( !$appending && count($current_data) > 0 ) {
+  if ( !$appending && count($current_data) > 0 ) {
     $params = array( ':collection_id' => $collection_id );
     if ( isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import ) $qry->Begin();
     foreach( $current_data AS $dav_name => $data ) {
@@ -1039,7 +1039,7 @@ EOSQL;
       $qry->QDo('SELECT write_sync_change(:collection_id, 404, :dav_name)', $params);
     }
     if ( isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import ) $qry->Commit();
-  }
+  }
   
   if ( !(isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import) ) {
     if ( ! $qry->Commit() ) rollback_on_error( $caldav_context, $user_no, $path);
@@ -1341,7 +1341,7 @@ function write_resource( DAVResource $resource, $caldav_data, DAVResource $colle
 
   }
 
-  $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')');
+  $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')');
 
   $calitem_params[':tzid'] = $tzid;
   $calitem_params[':uid'] = $first->GetPValue('UID');
@@ -1431,9 +1431,9 @@ EOSQL;
   $qry->QDo("SELECT write_sync_change( $collection_id, $sync_change, :dav_name)", array(':dav_name' => $path ) );
   $qry->Commit();
 
-  if ( function_exists('post_commit_action') ) {
-    post_commit_action( $put_action_type, $first->GetPValue('UID'), $user_no, $collection_id, $path );
-  }
+  if ( function_exists('post_commit_action') ) {
+    post_commit_action( $put_action_type, $first->GetPValue('UID'), $user_no, $collection_id, $path );
+  }
   
   // Uncache anything to do with the collection
   $cache = getCacheInstance();
diff --git a/inc/caldav-PUT-vcalendar.php b/inc/caldav-PUT-vcalendar.php
index b683d929..1d130531 100644
--- a/inc/caldav-PUT-vcalendar.php
+++ b/inc/caldav-PUT-vcalendar.php
@@ -14,12 +14,12 @@ require_once('DAVResource.php');
 
 include_once('caldav-PUT-functions.php');
 
-$vcalendar = new vCalendar( $request->raw_post );
-$uid = $vcalendar->GetUID();
-if ( empty($uid) ) {
-  $uid = uuid();
-  $vcalendar->SetUID($uid);
-}
+$vcalendar = new vCalendar( $request->raw_post );
+$uid = $vcalendar->GetUID();
+if ( empty($uid) ) {
+  $uid = uuid();
+  $vcalendar->SetUID($uid);
+}
 
 if ( $add_member ) {
   $request->path = $request->dav_name() . $uid . '.ics';
@@ -76,7 +76,7 @@ if ( $dav_resource->IsCollection()  ) {
 
 $etag = md5($request->raw_post);
 
-$request->CheckEtagMatch( $dav_resource->Exists(), $dav_resource->unique_tag() );
+$request->CheckEtagMatch( $dav_resource->Exists(), $dav_resource->unique_tag() );
 
 $put_action_type = ($dav_resource->Exists() ? 'UPDATE' : 'INSERT');
 $collection = $dav_resource->GetParentContainer();
diff --git a/inc/caldav-PUT-vcard.php b/inc/caldav-PUT-vcard.php
index a579d5f1..0ced7ec3 100644
--- a/inc/caldav-PUT-vcard.php
+++ b/inc/caldav-PUT-vcard.php
@@ -22,20 +22,20 @@ if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put'
 
 $lock_opener = $request->FailIfLocked();
 
-require_once('vcard.php');
-$vcard = new vCard( $request->raw_post );
-$uid = $vcard->GetPValue('UID');
-if ( empty($uid) ) {
-  $uid = uuid();
-  $vcard->AddProperty('UID',$uid);
-}
+require_once('vcard.php');
+$vcard = new vCard( $request->raw_post );
+$uid = $vcard->GetPValue('UID');
+if ( empty($uid) ) {
+  $uid = uuid();
+  $vcard->AddProperty('UID',$uid);
+}
 
 if ( $add_member ) {
   $request->path = $request->dav_name() . $uid . '.vcf';
   $dest = new DAVResource($request->path);
   if ( $dest->Exists() ) {
-    $uid = uuid();
-    $vcard->AddProperty('UID',$uid);
+    $uid = uuid();
+    $vcard->AddProperty('UID',$uid);
     $request->path = $request->dav_name() . $uid . '.vcf';
     $dest = new DAVResource($request->path);
     if ( $dest->Exists() ) throw new Exception("Failed to generate unique segment name for add-member!");
@@ -124,7 +124,7 @@ else {
   $params[':collection_id'] = $collection_id;
   $response_code = 201;
   $qry->QDo( $sql, $params );
-  $put_action_type = 'INSERT';
+  $put_action_type = 'INSERT';
   
   $qry->QDo("SELECT currval('dav_id_seq') AS dav_id" );
 }
@@ -134,14 +134,14 @@ $vcard->Write( $row->dav_id, $dest->Exists() );
 
 $qry->QDo("SELECT write_sync_change( $collection_id, $response_code, :dav_name)", array(':dav_name' => $dest->bound_from() ) );
 
-if ( isset($log_action) && $log_action && function_exists('log_caldav_action') ) {
-  log_caldav_action( $put_action_type, $uid, $user_no, $collection_id, $request->path );
-}
-else if ( isset($log_action) && $log_action  ) {
-  dbg_error_log( 'PUT', 'No log_caldav_action( %s, %s, %s, %s, %s) can be called.',
-      $put_action_type, $uid, $user_no, $collection_id, $request->path );
-}
-
+if ( isset($log_action) && $log_action && function_exists('log_caldav_action') ) {
+  log_caldav_action( $put_action_type, $uid, $user_no, $collection_id, $request->path );
+}
+else if ( isset($log_action) && $log_action  ) {
+  dbg_error_log( 'PUT', 'No log_caldav_action( %s, %s, %s, %s, %s) can be called.',
+      $put_action_type, $uid, $user_no, $collection_id, $request->path );
+}
+
 
 if ( !$qry->Commit() ) {
    $qry->Rollback();
diff --git a/inc/caldav-REPORT-calquery.php b/inc/caldav-REPORT-calquery.php
index 6d09f093..9914d44a 100644
--- a/inc/caldav-REPORT-calquery.php
+++ b/inc/caldav-REPORT-calquery.php
@@ -318,7 +318,7 @@ if ( ! ($target_collection->IsCalendar() || $target_collection->IsSchedulingColl
 }
 else {
   $where = ' WHERE caldav_data.collection_id = ' . $target_collection->resource_id();
-  $distinct = '';
+  $distinct = '';
 }
 
 if ( is_array($qry_filters) ) {
diff --git a/inc/caldav-REPORT-cardquery.php b/inc/caldav-REPORT-cardquery.php
index 25cfb71b..8d02ea1d 100644
--- a/inc/caldav-REPORT-cardquery.php
+++ b/inc/caldav-REPORT-cardquery.php
@@ -41,7 +41,7 @@ switch( $proptype ) {
   default:
     $properties[$proptype] = 1;
 }
-if ( empty($properties) ) $properties['DAV::allprop'] = 1;
+if ( empty($properties) ) $properties['DAV::allprop'] = 1;
 
 /**
  * There can only be *one* FILTER element.
diff --git a/inc/caldav-REPORT-multiget.php b/inc/caldav-REPORT-multiget.php
index 87207c9a..bdb1151e 100644
--- a/inc/caldav-REPORT-multiget.php
+++ b/inc/caldav-REPORT-multiget.php
@@ -50,7 +50,7 @@ switch( $proptype ) {
   default:
     $properties[$proptype] = 1;
 }
-if ( empty($properties) ) $properties['DAV::allprop'] = 1;
+if ( empty($properties) ) $properties['DAV::allprop'] = 1;
 
 $collection = new DAVResource($request->path);
 $bound_from = $collection->bound_from();
diff --git a/inc/caldav-REPORT-sync-collection.php b/inc/caldav-REPORT-sync-collection.php
index f0a12cad..b5a0c9bd 100644
--- a/inc/caldav-REPORT-sync-collection.php
+++ b/inc/caldav-REPORT-sync-collection.php
@@ -81,7 +81,7 @@ if ( $sync_token == $new_token ) {
 }
 else {
   $hide_older = '';
-  if ( isset($c->hide_older_than) && intval($c->hide_older_than) > 0 )
+  if ( isset($c->hide_older_than) && intval($c->hide_older_than) > 0 )
     $hide_older = " AND (CASE WHEN caldav_data.caldav_type<>'VEVENT' OR calendar_item.dtstart IS NULL THEN true ELSE calendar_item.dtstart > (now() - interval '".intval($c->hide_older_than)." days') END)";
 
   if ( $sync_token == 0 ) {
diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php
index 57a5c332..8d0e4355 100644
--- a/inc/caldav-REPORT.php
+++ b/inc/caldav-REPORT.php
@@ -189,11 +189,11 @@ function component_to_xml( $properties, $item ) {
   if ( $need_resource ) {
     if ( !isset($dav_resource) ) $dav_resource = new DAVResource($item->dav_name);
     $elements = $dav_resource->GetPropStat(array_keys($properties), $reply);
-    array_unshift($elements, $href);
+    array_unshift($elements, $href);
   }
   else {
     $elements = array($href);
-    $status = new XMLElement("status", "HTTP/1.1 200 OK" );
+    $status = new XMLElement("status", "HTTP/1.1 200 OK" );
     $elements[] = new XMLElement( "propstat", array( $prop, $status) );
     if ( count($denied) > 0 ) {
       $status = new XMLElement("status", "HTTP/1.1 403 Forbidden" );
@@ -224,7 +224,7 @@ if ( $target->IsExternal() ) {
 	update_external ( $target );
 }
 
-// These reports are always allowed to see the resource_data because they are special
+// These reports are always allowed to see the resource_data because they are special
 $c->sync_resource_data_ok = true;
 
 if ( $xmltree->GetNSTag() == "urn:ietf:params:xml:ns:caldav:calendar-query" ) {
diff --git a/inc/drivers_imap_pam.php b/inc/drivers_imap_pam.php
index f2cdfcf3..f3260657 100644
--- a/inc/drivers_imap_pam.php
+++ b/inc/drivers_imap_pam.php
@@ -1,107 +1,107 @@
-,
-*   		 Andrew McMillan 
-* @copyright Based on Eric Seigne script drivers_squid_pam.php
-* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
-*/
-
-// The PHP interpreter will die quietly unless satisfied. This provides user feedback instead.
-if (!function_exists('imap_open')) {
-  die("drivers_imap_pam: php5-imap required.");
-}
-
-require_once("auth-functions.php");
-
-class imapPamDrivers
-{
-  /**#@+
-  * @access private
-  */
-
-  /**#@-*/
-
-
-  /**
-  * The constructor
-  *
-  * @param string $imap_url formated for imap_open()
-  */
-  function __construct($imap_url)
-  {
-      global $c;
-      if (empty($imap_url)){
-          $c->messages[] = sprintf(i18n('drivers_imap_pam : imap_url parameter not configured in /etc/davical/*-conf.php'));
-          $this->valid=false;
-          return ;
-      }
-  }
-}
-
-
-/**
-* Check the username / password against the PAM system
-*/
-function IMAP_PAM_check($username, $password ){
-  global $c;
-
-  $imap_username = $username;
-  if ( function_exists('mb_convert_encoding') ) {
-    $imap_username = mb_convert_encoding($imap_username, "UTF7-IMAP",mb_detect_encoding($imap_username));
-  }
-  else {
-    $imap_username = imap_utf7_encode($imap_username);
-  }
-
-  //$imap_url = '{localhost:143/imap/notls}';
-  //$imap_url = '{localhost:993/imap/ssl/novalidate-cert}';
-  $imap_url = $c->authenticate_hook['config']['imap_url'];
-  $auth_result = "ERR";
-  
-  $imap_stream = @imap_open($imap_url, $imap_username, $password, OP_HALFOPEN);
-  //print_r(imap_errors());
-  if ( $imap_stream ) {
-    // disconnect
-    imap_close($imap_stream);
-    // login ok
-    $auth_result = "OK";
-  }
-
-  if ( $auth_result == "OK") {
-    $principal = new Principal('username',$username);
-    if ( ! $principal->Exists() ) {
-      dbg_error_log( "PAM", "Principal '%s' doesn't exist in local DB, we need to create it",$username );
-      $cmd = "getent passwd '$username'";
-      $getent_res = exec($cmd);
-      $getent_arr = explode(":", $getent_res);
-      $fullname = $getent_arr[4];
-      if(empty($fullname)) {
-        $fullname = $username;
-      }
-
-      $principal->Create( array(
-                      'username' => $username,
-                      'user_active' => true,
-                      'email' => $username . "@" . $c->authenticate_hook['config']['email_base'],
-                      'modified' => date('c'),
-                      'fullname' => $fullname
-              ));
-      if ( ! $principal->Exists() ) {
-        dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username );
-        return false;
-      }
-      CreateHomeCalendar($username);
-    }
-    return $principal;
-  }
-  else {
-    dbg_error_log( "PAM", "User %s is not a valid username (or password was wrong)", $username );
-    return false;
-  }
-
-}
+,
+*   		 Andrew McMillan 
+* @copyright Based on Eric Seigne script drivers_squid_pam.php
+* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
+*/
+
+// The PHP interpreter will die quietly unless satisfied. This provides user feedback instead.
+if (!function_exists('imap_open')) {
+  die("drivers_imap_pam: php5-imap required.");
+}
+
+require_once("auth-functions.php");
+
+class imapPamDrivers
+{
+  /**#@+
+  * @access private
+  */
+
+  /**#@-*/
+
+
+  /**
+  * The constructor
+  *
+  * @param string $imap_url formated for imap_open()
+  */
+  function __construct($imap_url)
+  {
+      global $c;
+      if (empty($imap_url)){
+          $c->messages[] = sprintf(i18n('drivers_imap_pam : imap_url parameter not configured in /etc/davical/*-conf.php'));
+          $this->valid=false;
+          return ;
+      }
+  }
+}
+
+
+/**
+* Check the username / password against the PAM system
+*/
+function IMAP_PAM_check($username, $password ){
+  global $c;
+
+  $imap_username = $username;
+  if ( function_exists('mb_convert_encoding') ) {
+    $imap_username = mb_convert_encoding($imap_username, "UTF7-IMAP",mb_detect_encoding($imap_username));
+  }
+  else {
+    $imap_username = imap_utf7_encode($imap_username);
+  }
+
+  //$imap_url = '{localhost:143/imap/notls}';
+  //$imap_url = '{localhost:993/imap/ssl/novalidate-cert}';
+  $imap_url = $c->authenticate_hook['config']['imap_url'];
+  $auth_result = "ERR";
+  
+  $imap_stream = @imap_open($imap_url, $imap_username, $password, OP_HALFOPEN);
+  //print_r(imap_errors());
+  if ( $imap_stream ) {
+    // disconnect
+    imap_close($imap_stream);
+    // login ok
+    $auth_result = "OK";
+  }
+
+  if ( $auth_result == "OK") {
+    $principal = new Principal('username',$username);
+    if ( ! $principal->Exists() ) {
+      dbg_error_log( "PAM", "Principal '%s' doesn't exist in local DB, we need to create it",$username );
+      $cmd = "getent passwd '$username'";
+      $getent_res = exec($cmd);
+      $getent_arr = explode(":", $getent_res);
+      $fullname = $getent_arr[4];
+      if(empty($fullname)) {
+        $fullname = $username;
+      }
+
+      $principal->Create( array(
+                      'username' => $username,
+                      'user_active' => true,
+                      'email' => $username . "@" . $c->authenticate_hook['config']['email_base'],
+                      'modified' => date('c'),
+                      'fullname' => $fullname
+              ));
+      if ( ! $principal->Exists() ) {
+        dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username );
+        return false;
+      }
+      CreateHomeCalendar($username);
+    }
+    return $principal;
+  }
+  else {
+    dbg_error_log( "PAM", "User %s is not a valid username (or password was wrong)", $username );
+    return false;
+  }
+
+}
diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php
index caf09bcc..d2c80147 100644
--- a/inc/drivers_ldap.php
+++ b/inc/drivers_ldap.php
@@ -295,19 +295,19 @@ function sync_user_from_LDAP( Principal &$principal, $mapping, $ldap_values ) {
   }
 }
 
-/*
-* explode the multipart mapping
-*/
-function array_values_mapping($mapping){
-  $attributes=array();
-  foreach ( $mapping as $field ) {
-    $tab_part_field = explode(",",$field);
-    foreach( $tab_part_field as $part_field ) {
-      $attributes[] = $part_field;
-    }
-  }
-  return $attributes;
-}
+/*
+* explode the multipart mapping
+*/
+function array_values_mapping($mapping){
+  $attributes=array();
+  foreach ( $mapping as $field ) {
+    $tab_part_field = explode(",",$field);
+    foreach( $tab_part_field as $part_field ) {
+      $attributes[] = $part_field;
+    }
+  }
+  return $attributes;
+}
 
 /**
 * Check the username / password against the LDAP server
diff --git a/inc/drivers_rimap.php b/inc/drivers_rimap.php
index a599df5a..323f4483 100644
--- a/inc/drivers_rimap.php
+++ b/inc/drivers_rimap.php
@@ -1,112 +1,112 @@
-,
-*   		 Andrew McMillan 
-* @copyright Based on Eric Seigne script drivers_squid_pam.php
-* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
-*/
-
-require_once("auth-functions.php");
-
-class imapPamDrivers
-{
-  /**#@+
-  * @access private
-  */
-
-  /**#@-*/
-
-
-  /**
-  * Constructor.
-  * @param string $imap_url formated for imap_open()
-  */
-  function imapPamDrivers($imap_url){
-      $this->__construct($imap_url);
-  }
-
-
-  /**
-  * The constructor
-  *
-  * @param string $imap_url formated for imap_open()
-  */
-  function __construct($imap_url)
-  {
-      global $c;
-      if (empty($imap_url)){
-          $c->messages[] = sprintf(i18n('drivers_imap_pam : imap_url parameter not configured in /etc/davical/*-conf.php'));
-          $this->valid=false;
-          return ;
-      }
-  }
-}
-
-
-/**
-* Check the username / password against the IMAP server
-*/
-function RIMAP_check($username, $password ){
-  global $c;
-
-  $imap_username = $username;
-  if ( function_exists('mb_convert_encoding') ) {
-    $imap_username = mb_convert_encoding($imap_username, "UTF7-IMAP",mb_detect_encoding($imap_username));
-  }
-  else {
-    $imap_username = imap_utf7_encode($imap_username);
-  }
-
-  //$imap_url = '{localhost:143/imap/notls}';
-  //$imap_url = '{localhost:993/imap/ssl/novalidate-cert}';
-  $imap_url = $c->authenticate_hook['config']['imap_url'];
-  $auth_result = "ERR";
-  
-  $imap_stream = @imap_open($imap_url, $imap_username, $password, OP_HALFOPEN);
-  //print_r(imap_errors());
-  if ( $imap_stream ) {
-    // disconnect
-    imap_close($imap_stream);
-    // login ok
-    $auth_result = "OK";
-  }
-
-  if ( $auth_result == "OK") {
-    $principal = new Principal('username',$username);
-    if ( ! $principal->Exists() ) {
-      dbg_error_log( "PAM", "Principal '%s' doesn't exist in local DB, we need to create it",$username );
-      if ( strstr($username, '@') ) {
-        $name_arr = explode('@', $username);
-        $fullname = ucfirst(strtolower($name_arr[0]));
-        $email = $username;
-      }
-      else {
-        $fullname = ucfirst(strtolower($username));
-        $email = $username . "@" . $c->authenticate_hook['config']['email_base'];
-      }
-
-      $principal->Create( array(
-                      'username' => $username,
-                      'user_active' => true,
-                      'email' => $email,
-                      'fullname' => ucfirst($fullname)
-              ));
-      if ( ! $principal->Exists() ) {
-        dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username );
-        return false;
-      }
-      CreateHomeCollections($username);
-    }
-    return $principal;
-  }
-  else {
-    dbg_error_log( "PAM", "User %s is not a valid username (or password was wrong)", $username );
-    return false;
-  }
-
-}
+,
+*   		 Andrew McMillan 
+* @copyright Based on Eric Seigne script drivers_squid_pam.php
+* @license   http://gnu.org/copyleft/gpl.html GNU GPL v2 or later
+*/
+
+require_once("auth-functions.php");
+
+class imapPamDrivers
+{
+  /**#@+
+  * @access private
+  */
+
+  /**#@-*/
+
+
+  /**
+  * Constructor.
+  * @param string $imap_url formated for imap_open()
+  */
+  function imapPamDrivers($imap_url){
+      $this->__construct($imap_url);
+  }
+
+
+  /**
+  * The constructor
+  *
+  * @param string $imap_url formated for imap_open()
+  */
+  function __construct($imap_url)
+  {
+      global $c;
+      if (empty($imap_url)){
+          $c->messages[] = sprintf(i18n('drivers_imap_pam : imap_url parameter not configured in /etc/davical/*-conf.php'));
+          $this->valid=false;
+          return ;
+      }
+  }
+}
+
+
+/**
+* Check the username / password against the IMAP server
+*/
+function RIMAP_check($username, $password ){
+  global $c;
+
+  $imap_username = $username;
+  if ( function_exists('mb_convert_encoding') ) {
+    $imap_username = mb_convert_encoding($imap_username, "UTF7-IMAP",mb_detect_encoding($imap_username));
+  }
+  else {
+    $imap_username = imap_utf7_encode($imap_username);
+  }
+
+  //$imap_url = '{localhost:143/imap/notls}';
+  //$imap_url = '{localhost:993/imap/ssl/novalidate-cert}';
+  $imap_url = $c->authenticate_hook['config']['imap_url'];
+  $auth_result = "ERR";
+  
+  $imap_stream = @imap_open($imap_url, $imap_username, $password, OP_HALFOPEN);
+  //print_r(imap_errors());
+  if ( $imap_stream ) {
+    // disconnect
+    imap_close($imap_stream);
+    // login ok
+    $auth_result = "OK";
+  }
+
+  if ( $auth_result == "OK") {
+    $principal = new Principal('username',$username);
+    if ( ! $principal->Exists() ) {
+      dbg_error_log( "PAM", "Principal '%s' doesn't exist in local DB, we need to create it",$username );
+      if ( strstr($username, '@') ) {
+        $name_arr = explode('@', $username);
+        $fullname = ucfirst(strtolower($name_arr[0]));
+        $email = $username;
+      }
+      else {
+        $fullname = ucfirst(strtolower($username));
+        $email = $username . "@" . $c->authenticate_hook['config']['email_base'];
+      }
+
+      $principal->Create( array(
+                      'username' => $username,
+                      'user_active' => true,
+                      'email' => $email,
+                      'fullname' => ucfirst($fullname)
+              ));
+      if ( ! $principal->Exists() ) {
+        dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username );
+        return false;
+      }
+      CreateHomeCollections($username);
+    }
+    return $principal;
+  }
+  else {
+    dbg_error_log( "PAM", "User %s is not a valid username (or password was wrong)", $username );
+    return false;
+  }
+
+}
diff --git a/inc/schedule-functions.php b/inc/schedule-functions.php
index 35091ed2..b792b932 100644
--- a/inc/schedule-functions.php
+++ b/inc/schedule-functions.php
@@ -177,7 +177,7 @@ function doItipAttendeeReply( vCalendar $resource, $partstat ) {
       }
     }
     else {
-      header( "Debug: Could maybe do the iMIP message dance for attendee ". $email );
+      header( "Debug: Could maybe do the iMIP message dance for attendee ". $email );
     }
   }
 
@@ -397,9 +397,9 @@ EOTEMPLATE;
     $email->Pretend($mime->getMimeHeaders());
   }
   else if ( !isset($c->iMIP->send_email) || !$c->iMIP->send_email) {
-    $email->PretendLog($mime->getMimeHeaders());
+    $email->PretendLog($mime->getMimeHeaders());
   }
   else {
     $email->Send($mime->getMimeHeaders());
   }
-}
\ No newline at end of file
+}
diff --git a/inc/ui/collection-edit.php b/inc/ui/collection-edit.php
index 246d59ea..9a3e056b 100644
--- a/inc/ui/collection-edit.php
+++ b/inc/ui/collection-edit.php
@@ -27,9 +27,9 @@ $editor->AddField('ics_file', "''");
 $editor->AddAttribute('ics_file', 'title', translate('Upload an iCalendar file or VCard file to replace this collection.'));
 $editor->AddAttribute('ics_file', 'id', 'fld_ics_file');
 $editor->AddField('mode', 'FALSE');
-$editor->AddAttribute('mode', 'title', translate('Should the uploaded entries be appended to the collection?'));
-$editor->AddAttribute('mode', '_label', translate('Append'));
-$editor->AddAttribute('mode', 'id', 'fld_mode');
+$editor->AddAttribute('mode', 'title', translate('Should the uploaded entries be appended to the collection?'));
+$editor->AddAttribute('mode', '_label', translate('Append'));
+$editor->AddAttribute('mode', 'id', 'fld_mode');
 
 $editor->SetWhere( 'collection_id='.$id );
 
diff --git a/inc/ui/principal-edit.php b/inc/ui/principal-edit.php
index 82bc5480..6ada0168 100644
--- a/inc/ui/principal-edit.php
+++ b/inc/ui/principal-edit.php
@@ -32,8 +32,8 @@ $can_write_principal = ($session->AllowedTo('Admin') || ($session->principal_id
 if ( !$can_write_principal && $id > 0 ) {
   $target_principal = new Principal('principal_id', $id);
   $can_write_principal = $session->HavePrivilegeTo('DAV::write', $target_principal->dav_name());
-}
-
+}
+
 
 $delete_collection_confirmation_required = null;
 $delete_principal_confirmation_required = null;
@@ -624,7 +624,7 @@ function edit_grant_row( $row_data ) {
   }
   else {
     $grantrow->Initialise( $row_data );
-  }
+  }
   
   $privs_html = build_privileges_html( $grantrow, 'grant_privileges' );
 

From 5fccb302a8f326ebab1ae6b4d9599e4ff426b828 Mon Sep 17 00:00:00 2001
From: Christoph Anton Mitterer 
Date: Wed, 20 Mar 2013 23:41:43 +0100
Subject: [PATCH 02/13] escape version string to prevent XSS for sure

* HTML escape the remotely retrieved version string printed to the HTML in order
  to prevent and attacks (if this would have been possible at all in 12
  characters).

The version string read from the davical.org webserver might be changed by an
attacker in order to perform XSS.
Even though this is highly unlikley (there are only 12 characters used) it's
better to HTML escape any such string that is printed to HTML.

This was originally reported at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=703290
---
 ChangeLog        | 3 +++
 debian/changelog | 2 +-
 htdocs/setup.php | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ed20829b..9488f8d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
 	* Changed the end-of-line encodings of all non-Windows-related and 
 	  non-autogenerated text files to use UNIX LF (lots of them had mixed
 	  LF/CRLF).
+	* HTML escape the remotely retrieved version string printed to the HTML
+	  in order to prevent and attacks (if this would have been possible at
+	  all in 12 characters).
 
 2013-03-06  Andrew McMillan  
 	* Fix capitalisation of 'plpgsql' & 'sql' for Postgres 9.2. (debbug #702403)
diff --git a/debian/changelog b/debian/changelog
index 647037c5..d1b201b0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
 davical (1.1.2-1) unstable; urgency=low
 
-  * New upstream release (closes:#702403)
+  * New upstream release (closes:#702403, #703290)
 
  -- Andrew McMillan   Wed, 06 Mar 2013 20:27:17 +1300
 
diff --git a/htdocs/setup.php b/htdocs/setup.php
index 54345f39..ac43670c 100644
--- a/htdocs/setup.php
+++ b/htdocs/setup.php
@@ -252,7 +252,7 @@ function check_davical_version() {
   $url = 'http://www.davical.org/current_davical_version?v='.$c->version_string;
   $version_file = @fopen($url, 'r');
   if ( ! $version_file ) return new CheckResult( false, translate("Could not retrieve") . " '$url'", 'dep_warning' );
-  $current_version = trim(fread( $version_file,12));
+  $current_version = htmlentities( trim(fread( $version_file,12)) );
   fclose($version_file);
   $result = new CheckResult($c->version_string == $current_version);
   if ( ! $result->getOK() ) {

From ce0747b74fccd20707b6f495068503e69e5473df Mon Sep 17 00:00:00 2001
From: Christoph Anton Mitterer 
Date: Wed, 20 Mar 2013 23:50:25 +0100
Subject: [PATCH 03/13] document closed Debian bug

* Document that Debian bug #703387 was closed by commit
  56968d48651518dd386a53bcd28c408ffe313aeb which I forgot to do before.
---
 debian/changelog | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index d1b201b0..ba719c31 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
 davical (1.1.2-1) unstable; urgency=low
 
-  * New upstream release (closes:#702403, #703290)
+  * New upstream release (closes:#702403, #703290, #703387)
 
  -- Andrew McMillan   Wed, 06 Mar 2013 20:27:17 +1300
 

From fd4e4005a4b7b3e638bc405be020b867f8881e72 Mon Sep 17 00:00:00 2001
From: Christoph Anton Mitterer 
Date: Thu, 21 Mar 2013 00:20:24 +0100
Subject: [PATCH 04/13] update addresses to the new canonical location

* Updated all addresses of the canonical git upstream repository and the issue
  tracker to the new ones.
---
 ChangeLog                | 2 ++
 debian/changelog         | 2 ++
 debian/control           | 4 ++--
 inc/interactive-page.php | 2 +-
 po/de.po                 | 2 +-
 po/es_AR.po              | 2 +-
 po/es_ES.po              | 2 +-
 po/es_MX.po              | 2 +-
 po/es_VE.po              | 2 +-
 po/et.po                 | 2 +-
 po/fr.po                 | 2 +-
 po/hu.po                 | 2 +-
 po/it.po                 | 2 +-
 po/ja.po                 | 2 +-
 po/nb_NO.po              | 2 +-
 po/nl.po                 | 2 +-
 po/pl.po                 | 2 +-
 po/pt_BR.po              | 2 +-
 po/pt_PT.po              | 2 +-
 po/ru.po                 | 2 +-
 po/sv.po                 | 2 +-
 21 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9488f8d9..7ac3a61b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
 	* HTML escape the remotely retrieved version string printed to the HTML
 	  in order to prevent and attacks (if this would have been possible at
 	  all in 12 characters).
+	* Updated all addresses of the canonical git upstream repository and the
+	  issue tracker to the new ones.
 
 2013-03-06  Andrew McMillan  
 	* Fix capitalisation of 'plpgsql' & 'sql' for Postgres 9.2. (debbug #702403)
diff --git a/debian/changelog b/debian/changelog
index ba719c31..49c93217 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
 davical (1.1.2-1) unstable; urgency=low
 
   * New upstream release (closes:#702403, #703290, #703387)
+  * Updated the control file Vcs-* fields to the new addresses of the
+    canonical git upstream repository.
 
  -- Andrew McMillan   Wed, 06 Mar 2013 20:27:17 +1300
 
diff --git a/debian/control b/debian/control
index 2682bb1b..4ea7d381 100644
--- a/debian/control
+++ b/debian/control
@@ -4,8 +4,8 @@ Priority: extra
 Maintainer: Andrew McMillan 
 Standards-Version: 3.9.2
 Build-Depends: debhelper (>= 7), libawl-php, gettext
-Vcs-git: git://repo.or.cz/davical.git
-Vcs-browser: http://repo.or.cz/w/davical.git
+Vcs-git: git://github.com/DAViCal/davical.git
+Vcs-browser: https://github.com/DAViCal/davical
 Homepage: http://davical.org/
 
 Package: davical
diff --git a/inc/interactive-page.php b/inc/interactive-page.php
index 5bee0567..a1b8cf58 100644
--- a/inc/interactive-page.php
+++ b/inc/interactive-page.php
@@ -20,7 +20,7 @@ $help_menu = new MenuSet('submenu', 'submenu', 'submenu_active');
 $help_menu->AddOption(translate('DAViCal Homepage'),'http://www.davical.org/',translate('The DAViCal Home Page'), false, 6000, true );
 $help_menu->AddOption(translate('DAViCal Wiki'),'http://wiki.davical.org/'.$wiki_help,translate('Visit the DAViCal Wiki'), false, 7000, true );
 $help_menu->AddOption(translate('Request Feature'),'http://davical.uservoice.com/',translate('Go to the DAViCal Feature Requests'), false, 8000, true );
-$help_menu->AddOption(translate('Report Bug'),'http://sourceforge.net/tracker/?func=add&group_id=179845&atid=890785',translate('Report a bug in the system'), false, 9000, true );
+$help_menu->AddOption(translate('Report Bug'),'https://github.com/DAViCal/davical/issues',translate('Report a bug in the system'), false, 9000, true );
 
 $user_menu = new MenuSet('submenu', 'submenu', 'submenu_active');
 $user_menu->AddOption(translate('View My Details'),$c->base_url.'/admin.php?action=edit&t=principal&id='.$session->principal_id,translate('View my own principal record'));
diff --git a/po/de.po b/po/de.po
index f1309221..8874bd09 100644
--- a/po/de.po
+++ b/po/de.po
@@ -11,7 +11,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/es_AR.po b/po/es_AR.po
index c4bb3e3a..b8df86d6 100644
--- a/po/es_AR.po
+++ b/po/es_AR.po
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/es_ES.po b/po/es_ES.po
index 404ff4e9..d502e361 100644
--- a/po/es_ES.po
+++ b/po/es_ES.po
@@ -9,7 +9,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/es_MX.po b/po/es_MX.po
index ebab5990..7dfc1cb6 100644
--- a/po/es_MX.po
+++ b/po/es_MX.po
@@ -8,7 +8,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/es_VE.po b/po/es_VE.po
index 92a837e4..4054031d 100644
--- a/po/es_VE.po
+++ b/po/es_VE.po
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/et.po b/po/et.po
index a8bfd832..21dcda00 100644
--- a/po/et.po
+++ b/po/et.po
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/fr.po b/po/fr.po
index 5531aa80..4873d5cb 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -10,7 +10,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/hu.po b/po/hu.po
index e92ec7c9..d1e2fbc2 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/it.po b/po/it.po
index 74f65758..a387d297 100644
--- a/po/it.po
+++ b/po/it.po
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/ja.po b/po/ja.po
index 16967ca0..1fcb9d3b 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/nb_NO.po b/po/nb_NO.po
index beb22760..327ec066 100644
--- a/po/nb_NO.po
+++ b/po/nb_NO.po
@@ -9,7 +9,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/nl.po b/po/nl.po
index e378a81a..504e7491 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -8,7 +8,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/pl.po b/po/pl.po
index 0c6620d9..63c7253d 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -10,7 +10,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index dc9456c2..8525abfb 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -8,7 +8,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/pt_PT.po b/po/pt_PT.po
index 922c7863..092a1179 100644
--- a/po/pt_PT.po
+++ b/po/pt_PT.po
@@ -8,7 +8,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/ru.po b/po/ru.po
index ffc4ab84..ff1be80d 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -9,7 +9,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"
diff --git a/po/sv.po b/po/sv.po
index 568d95aa..ff942d4e 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: DAViCal\n"
-"Report-Msgid-Bugs-To: http://repo.or.cz/w/davical.git/tree/HEAD:/issues\n"
+"Report-Msgid-Bugs-To: https://github.com/DAViCal/davical/issues\n"
 "POT-Creation-Date: 2012-05-28 21:24+1200\n"
 "PO-Revision-Date: 2012-05-28 09:26+0000\n"
 "Last-Translator: Andrew McMillan \n"

From e701961cf466ecefce5ff80b55c68524222368ae Mon Sep 17 00:00:00 2001
From: Christoph Anton Mitterer 
Date: Thu, 21 Mar 2013 02:10:34 +0100
Subject: [PATCH 05/13] make debug files pathnames more FHS compliant

* Changed the pathnames of the debug files to be a bit more FHS compliant.
---
 ChangeLog                    | 4 ++++
 inc/CalDAVRequest.php        | 2 +-
 inc/caldav-ACL.php           | 2 +-
 inc/caldav-MOVE.php          | 2 +-
 inc/caldav-POST.php          | 2 +-
 inc/caldav-PUT-default.php   | 2 +-
 inc/caldav-PUT-functions.php | 2 +-
 inc/caldav-PUT-vcalendar.php | 2 +-
 inc/caldav-PUT-vcard.php     | 2 +-
 inc/caldav-REPORT.php        | 2 +-
 10 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7ac3a61b..c8fd4113 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-21  Christoph Anton Mitterer 
+	* Changed the pathnames of the debug files to be a bit more FHS
+	  compliant.
+
 2013-03-20  Christoph Anton Mitterer 
 	* Changed the end-of-line encodings of all non-Windows-related and 
 	  non-autogenerated text files to use UNIX LF (lots of them had mixed
diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php
index d6003a6a..864eafb6 100644
--- a/inc/CalDAVRequest.php
+++ b/inc/CalDAVRequest.php
@@ -183,7 +183,7 @@ class CalDAVRequest
       @dbg_error_log('caldav', 'Content-Encoding: %s', $encoding );
       $encoding = preg_replace('{[^a-z0-9-]}i','',$encoding);
       if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['caldav'])) ) {
-        $fh = fopen('/tmp/encoded_data.'.$encoding,'w');
+        $fh = fopen('/var/log/davical/encoded_data.debug'.$encoding,'w');
         if ( $fh ) {
           fwrite($fh,$c->raw_post);
           fclose($fh);
diff --git a/inc/caldav-ACL.php b/inc/caldav-ACL.php
index 06cc40e8..6e6f539c 100644
--- a/inc/caldav-ACL.php
+++ b/inc/caldav-ACL.php
@@ -15,7 +15,7 @@ require_once('DAVResource.php');
 $request->NeedPrivilege('DAV::write-acl');
 
 if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) {
-  $fh = fopen('/tmp/MOVE.txt','w');
+  $fh = fopen('/var/log/davical/MOVE.debug','w');
   if ( $fh ) {
     fwrite($fh,$request->raw_post);
     fclose($fh);
diff --git a/inc/caldav-MOVE.php b/inc/caldav-MOVE.php
index ad0e120e..a9e742eb 100644
--- a/inc/caldav-MOVE.php
+++ b/inc/caldav-MOVE.php
@@ -15,7 +15,7 @@ require_once('DAVResource.php');
 $request->NeedPrivilege('DAV::unbind');
 
 if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['move']) && $c->dbg['move'])) ) {
-  $fh = fopen('/tmp/MOVE.txt','w');
+  $fh = fopen('/var/log/davical/MOVE.debug','w');
   if ( $fh ) {
     fwrite($fh,$request->raw_post);
     fclose($fh);
diff --git a/inc/caldav-POST.php b/inc/caldav-POST.php
index 26629a63..8f990f9b 100644
--- a/inc/caldav-POST.php
+++ b/inc/caldav-POST.php
@@ -16,7 +16,7 @@ include_once('freebusy-functions.php');
 include_once('iSchedule.php');
 
 if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['post'])) ) {
-  $fh = fopen('/tmp/POST.txt','w');
+  $fh = fopen('/var/log/davical/POST.debug','w');
   if ( $fh ) {
     fwrite($fh,$request->raw_post);
     fclose($fh);
diff --git a/inc/caldav-PUT-default.php b/inc/caldav-PUT-default.php
index 64b1a752..d291acb3 100644
--- a/inc/caldav-PUT-default.php
+++ b/inc/caldav-PUT-default.php
@@ -13,7 +13,7 @@ dbg_error_log("PUT", "method handler");
 require_once('DAVResource.php');
 
 if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) {
-  $fh = fopen('/tmp/PUT.txt','w');
+  $fh = fopen('/var/log/davical/PUT.debug','w');
   if ( $fh ) {
     fwrite($fh,$request->raw_post);
     fclose($fh);
diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php
index 79d48499..70b1baf7 100644
--- a/inc/caldav-PUT-functions.php
+++ b/inc/caldav-PUT-functions.php
@@ -647,7 +647,7 @@ function import_collection( $import_content, $user_no, $path, $caldav_context, $
   global $c;
   
   if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['put'])) ) {
-    $fh = fopen('/tmp/PUT-2.txt','w');
+    $fh = fopen('/var/log/davical/PUT-2.debug','w');
     if ( $fh ) {
       fwrite($fh,$import_content);
       fclose($fh);
diff --git a/inc/caldav-PUT-vcalendar.php b/inc/caldav-PUT-vcalendar.php
index 1d130531..65251ab7 100644
--- a/inc/caldav-PUT-vcalendar.php
+++ b/inc/caldav-PUT-vcalendar.php
@@ -45,7 +45,7 @@ if ( ! $dav_resource->Exists() && ! $dav_resource->HavePrivilegeTo('DAV::bind')
 }
 
 if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) {
-  $fh = fopen('/tmp/PUT.txt','w');
+  $fh = fopen('/var/log/davical/PUT.debug','w');
   if ( $fh ) {
     fwrite($fh,$request->raw_post);
     fclose($fh);
diff --git a/inc/caldav-PUT-vcard.php b/inc/caldav-PUT-vcard.php
index 0ced7ec3..8bb7dafe 100644
--- a/inc/caldav-PUT-vcard.php
+++ b/inc/caldav-PUT-vcard.php
@@ -13,7 +13,7 @@ dbg_error_log("PUT", "method handler");
 require_once('DAVResource.php');
 
 if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) {
-  $fh = fopen('/tmp/PUT.txt','w');
+  $fh = fopen('/var/log/davical/PUT.debug','w');
   if ( $fh ) {
     fwrite($fh,$request->raw_post);
     fclose($fh);
diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php
index 8d0e4355..8568e7f5 100644
--- a/inc/caldav-REPORT.php
+++ b/inc/caldav-REPORT.php
@@ -16,7 +16,7 @@ require_once('DAVResource.php');
 require_once('RRule-v2.php');
 
 if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['report']) && $c->dbg['report'])) ) {
-  $fh = fopen('/tmp/REPORT.txt','w');
+  $fh = fopen('/var/log/davical/REPORT.debug','w');
   if ( $fh ) {
     fwrite($fh,$request->raw_post);
     fclose($fh);

From 8c5a2719438f7a3bec1fc791c3560e2542241dd4 Mon Sep 17 00:00:00 2001
From: "fbiete@gmail.com" 
Date: Fri, 22 Mar 2013 11:05:20 +0100
Subject: [PATCH 06/13] CardDAV support for search contains, starts-with,
 ends-with, equals

---
 inc/caldav-REPORT-cardquery.php | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/inc/caldav-REPORT-cardquery.php b/inc/caldav-REPORT-cardquery.php
index 8d02ea1d..fdc82149 100644
--- a/inc/caldav-REPORT-cardquery.php
+++ b/inc/caldav-REPORT-cardquery.php
@@ -109,7 +109,21 @@ function SqlFilterCardDAV( $filter, $components, $property = null, $parameter =
             break;
         }
         $pname = ':text_match_'.$matchnum++;
-        $params[$pname] = '%'.$search.'%';
+        $match_type = $v->GetAttribute("match-type");
+        switch( strtolower($match_type) ) {
+          case 'starts-with':
+            $params[$pname] = $search.'%';
+            break;
+          case 'ends-with':
+            $params[$pname] = '%'.$search;
+            break;
+          case 'equals':
+            $params[$pname] = $search;
+          case 'contains':
+          default:
+            $params[$pname] = '%'.$search.'%';
+            break;
+        }
         dbg_error_log("cardquery", " text-match: (%s%s %s '%s') ", (isset($negate) && strtolower($negate) == "yes" ? "NOT ": ""),
                                           $property, $comparison, $params[$pname] );
         $sql .= sprintf( "AND (%s%s %s $pname) ", (isset($negate) && strtolower($negate) == "yes" ? "NOT ": ""),

From 2b68d1130f588a679ba895a7c461d97e4c869421 Mon Sep 17 00:00:00 2001
From: Christoph Anton Mitterer 
Date: Sat, 23 Mar 2013 03:31:11 +0100
Subject: [PATCH 07/13] RFC compliant CGI AUTH_TYPE usage

* Handle the content of the CGI AUTH_TYPE variable case-insensitively as defined
  by RFC 3875 Section 4.1.1.
---
 ChangeLog               | 4 ++++
 debian/changelog        | 2 +-
 inc/HTTPAuthSession.php | 4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c8fd4113..ba907cf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-23  Christoph Anton Mitterer 
+	* Handle the content of the CGI AUTH_TYPE variable case-insensitively as
+	  defined by RFC 3875 Section 4.1.1.
+
 2013-03-21  Christoph Anton Mitterer 
 	* Changed the pathnames of the debug files to be a bit more FHS
 	  compliant.
diff --git a/debian/changelog b/debian/changelog
index 49c93217..c8e9d191 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
 davical (1.1.2-1) unstable; urgency=low
 
-  * New upstream release (closes:#702403, #703290, #703387)
+  * New upstream release (closes:#702403, #703290, #703383, #703387)
   * Updated the control file Vcs-* fields to the new addresses of the
     canonical git upstream repository.
 
diff --git a/inc/HTTPAuthSession.php b/inc/HTTPAuthSession.php
index 7cb07356..cee5d0b4 100644
--- a/inc/HTTPAuthSession.php
+++ b/inc/HTTPAuthSession.php
@@ -114,10 +114,10 @@ class HTTPAuthSession {
     else if ( isset($c->authenticate_hook['server_auth_type'])
               && isset($_SERVER['REMOTE_USER']) && !empty($_SERVER['REMOTE_USER'])) {
       if ( ( is_array($c->authenticate_hook['server_auth_type'])
-                    && in_array($_SERVER['AUTH_TYPE'], $c->authenticate_hook['server_auth_type']) )
+                    && in_array( strtolower($_SERVER['AUTH_TYPE']), array_map('strtolower', $c->authenticate_hook['server_auth_type'])) )
          ||
            ( !is_array($c->authenticate_hook['server_auth_type'])
-                    && $c->authenticate_hook['server_auth_type'] == $_SERVER['AUTH_TYPE'] )
+                    && strtolower($c->authenticate_hook['server_auth_type']) == strtolower($_SERVER['AUTH_TYPE']) )
          ) {
         /**
         * The authentication has happened in the server, and we should accept it.

From f313282ee08339e5084d588172149b46dd278e13 Mon Sep 17 00:00:00 2001
From: Christoph Anton Mitterer 
Date: Mon, 25 Mar 2013 02:01:04 +0100
Subject: [PATCH 08/13] =?UTF-8?q?support=20Apache=E2=80=99s=20REDIRECT=5FR?=
 =?UTF-8?q?EMOTE=5FUSER=20CGI=20env=20var?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* In places where the CGI variable REMOTE_USER is read, support alternatively
  REDIRECT_REMOTE_USER, which is used by the Apache HTTPD Server instead, when a
  redirect was used.

Note: This alone is not enough yet, to fully support it in DAViCal. An analogous
      change (commit 29ddd89baaf65bda2560e51665a2e761abef4147) is necessary in
      AWL.
---
 ChangeLog               |  5 +++++
 debian/changelog        |  2 +-
 inc/HTTPAuthSession.php |  8 ++++++--
 inc/drivers_ldap.php    | 13 ++++++++++---
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ba907cf7..4a0292d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-25  Christoph Anton Mitterer 
+	* In places where the CGI variable REMOTE_USER is read, support
+	  alternatively REDIRECT_REMOTE_USER, which is used by the Apache
+	  HTTPD Server instead, when a redirect was used.
+
 2013-03-23  Christoph Anton Mitterer 
 	* Handle the content of the CGI AUTH_TYPE variable case-insensitively as
 	  defined by RFC 3875 Section 4.1.1.
diff --git a/debian/changelog b/debian/changelog
index c8e9d191..40ad6fed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
 davical (1.1.2-1) unstable; urgency=low
 
-  * New upstream release (closes:#702403, #703290, #703383, #703387)
+  * New upstream release (closes: #656395, #702403, #703290, #703383, #703387)
   * Updated the control file Vcs-* fields to the new addresses of the
     canonical git upstream repository.
 
diff --git a/inc/HTTPAuthSession.php b/inc/HTTPAuthSession.php
index cee5d0b4..3e2bd2f6 100644
--- a/inc/HTTPAuthSession.php
+++ b/inc/HTTPAuthSession.php
@@ -112,7 +112,8 @@ class HTTPAuthSession {
       }
     }
     else if ( isset($c->authenticate_hook['server_auth_type'])
-              && isset($_SERVER['REMOTE_USER']) && !empty($_SERVER['REMOTE_USER'])) {
+              && (  ( isset($_SERVER["REMOTE_USER"]) && !empty($_SERVER["REMOTE_USER"]) )  ||
+                    ( isset($_SERVER["REDIRECT_REMOTE_USER"]) && !empty($_SERVER["REDIRECT_REMOTE_USER"]) )  )   ) {
       if ( ( is_array($c->authenticate_hook['server_auth_type'])
                     && in_array( strtolower($_SERVER['AUTH_TYPE']), array_map('strtolower', $c->authenticate_hook['server_auth_type'])) )
          ||
@@ -122,7 +123,10 @@ class HTTPAuthSession {
         /**
         * The authentication has happened in the server, and we should accept it.
         */
-        $_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'];
+        if (isset($_SERVER["REMOTE_USER"]))
+          $_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'];
+        else
+          $_SERVER['PHP_AUTH_USER'] = $_SERVER['REDIRECT_REMOTE_USER'];
         $_SERVER['PHP_AUTH_PW'] = 'Externally Authenticated';
         if ( ! isset($c->authenticate_hook['call']) ) {
           /**
diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php
index d2c80147..a6665297 100644
--- a/inc/drivers_ldap.php
+++ b/inc/drivers_ldap.php
@@ -205,9 +205,16 @@ class ldapDrivers
     $dnUser = ldap_get_dn($this->connect, ldap_first_entry($this->connect,$entry));
 
     if ( isset($c->authenticate_hook['config']['i_use_mode_kerberos']) && $c->authenticate_hook['config']['i_use_mode_kerberos'] == "i_know_what_i_am_doing") {
-    	dbg_error_log( "LDAP", "drivers_ldap : Skipping password Check for user %s which should be the same as %s",$username , $_SERVER["REMOTE_USER"]);
-      if ($username != $_SERVER["REMOTE_USER"]) {
-        return false;
+      if (isset($_SERVER["REMOTE_USER"])) {
+        dbg_error_log( "LOG", "drivers_ldap : Skipping password Check for user %s which should be the same as %s",$username , $_SERVER["REMOTE_USER"]);
+        if ($username != $_SERVER["REMOTE_USER"]) {
+          return false;
+        }
+      } else {
+        dbg_error_log( "LOG", "drivers_ldap : Skipping password Check for user %s which should be the same as %s",$username , $_SERVER["REDIRECT_REMOTE_USER"]);
+        if ($username != $_SERVER["REDIRECT_REMOTE_USER"]) {
+          return false;
+        }
       }
     }
     else if ( empty($passwd) || preg_match('/[\x00-\x19]/',$passwd) ) {

From 639295eb439ceec53902ee6fff22630dd631e68a Mon Sep 17 00:00:00 2001
From: Christoph Anton Mitterer 
Date: Mon, 25 Mar 2013 20:13:38 +0100
Subject: [PATCH 09/13] removed debian/README.Debian
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Removed debian/README.Debian which didn’t contain any useful information.
---
 ChangeLog            |  2 ++
 debian/README.Debian | 14 --------------
 debian/changelog     |  1 +
 3 files changed, 3 insertions(+), 14 deletions(-)
 delete mode 100644 debian/README.Debian

diff --git a/ChangeLog b/ChangeLog
index 4a0292d7..bff4386d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 	* In places where the CGI variable REMOTE_USER is read, support
 	  alternatively REDIRECT_REMOTE_USER, which is used by the Apache
 	  HTTPD Server instead, when a redirect was used.
+	* Removed debian/README.Debian which didn’t contain any useful
+	  information.
 
 2013-03-23  Christoph Anton Mitterer 
 	* Handle the content of the CGI AUTH_TYPE variable case-insensitively as
diff --git a/debian/README.Debian b/debian/README.Debian
deleted file mode 100644
index 45871530..00000000
--- a/debian/README.Debian
+++ /dev/null
@@ -1,14 +0,0 @@
-DAViCal for Debian
-----------------
-
-This is a CalDAV Server which I wrote because I was getting
-sick of the length of time it was taking to make worthwhile
-CalDAV server-side implementations that worked OK with
-Evolution.
-
-Then, when I finally did find a CalDAV store that worked, I
-found that it was quite bloated because it wanted to do vast
-amounts of irrelevant stuff.  Well, irrelevant for me in any
-case.
-
-Andrew McMillan , Tue.  2 May 2006 07:11:22 +1200
diff --git a/debian/changelog b/debian/changelog
index 40ad6fed..fbd25284 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ davical (1.1.2-1) unstable; urgency=low
   * New upstream release (closes: #656395, #702403, #703290, #703383, #703387)
   * Updated the control file Vcs-* fields to the new addresses of the
     canonical git upstream repository.
+  * Removed README.Debian which didn’t contain any useful information.
 
  -- Andrew McMillan   Wed, 06 Mar 2013 20:27:17 +1300
 

From 3ab7787f7b2c6bebccbacb31396f77f09aa93f09 Mon Sep 17 00:00:00 2001
From: Jason Alavaliant 
Date: Sun, 21 Apr 2013 21:44:34 +1200
Subject: [PATCH 10/13] add fix for the OSX Contacts.app:

---
 inc/caldav-REPORT.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php
index 8568e7f5..442894bb 100644
--- a/inc/caldav-REPORT.php
+++ b/inc/caldav-REPORT.php
@@ -154,11 +154,11 @@ function component_to_xml( $properties, $item ) {
         $prop->NewElement($base_tag, ISODateToHTTPDate($item->modified) );
         break;
       case 'urn:ietf:params:xml:ns:caldav:calendar-data':
-        if ( $type == 'calendar' ) $reply->CalDAVElement($prop, $base_tag, $caldav_data );
+        if ( $type == 'calendar' ) $reply->CalDAVElement($prop, $base_tag, '' );
         else $unsupported[] = $base_tag;
         break;
       case 'urn:ietf:params:xml:ns:carddav:address-data':
-        if ( $type == 'vcard' ) $reply->CardDAVElement($prop, $base_tag, $caldav_data );
+        if ( $type == 'vcard' ) $reply->CardDAVElement($prop, $base_tag, '' );
         else $unsupported[] = $base_tag;
         break;
       case 'DAV::getcontenttype':

From 036872ac85981a56d6f16817fb2b819dd7882c8c Mon Sep 17 00:00:00 2001
From: Jason Alavaliant 
Date: Sun, 21 Apr 2013 21:47:59 +1200
Subject: [PATCH 11/13] fix for CLASS attribute problem (CONFIDENTIAL value)
 and invalid processing of ->hide_alarm configuration option:

---
 inc/caldav-REPORT.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php
index 442894bb..d6213128 100644
--- a/inc/caldav-REPORT.php
+++ b/inc/caldav-REPORT.php
@@ -116,7 +116,7 @@ function component_to_xml( $properties, $item ) {
       break;
   }
   if ( $type == 'calendar' ) {
-    if ( isset($properties['calendar-data']) || isset($properties['displayname']) ) {
+    if ( isset($properties['urn:ietf:params:xml:ns:caldav:calendar-data']) || isset($properties['DAV::displayname']) ) {
       if ( !$request->AllowedTo('all') && $session->user_no != $item->user_no ) {
         // the user is not admin / owner of this calendar looking at his calendar and can not admin the other cal
         if ( $item->class == 'CONFIDENTIAL' || !$request->AllowedTo('read') ) {
@@ -130,7 +130,7 @@ function component_to_xml( $properties, $item ) {
 
     if ( isset($c->hide_alarm) && $c->hide_alarm ) {
       $dav_resource = new DAVResource($item->dav_name);
-      if ( isset($properties['calendar-data']) && !$dav_resource->HavePrivilegeTo('write') ) {
+      if ( isset($properties['urn:ietf:params:xml:ns:caldav:calendar-data']) && !$dav_resource->HavePrivilegeTo('write') ) {
         dbg_error_log("REPORT","Stripping event alarms for: %s", $item->dav_name );
         $vcal = new vCalendar($caldav_data);
         $vcal->ClearComponents('VALARM');

From 126895e2a6c004372d3b06667b434d29212ac624 Mon Sep 17 00:00:00 2001
From: Jason Alavaliant 
Date: Sun, 21 Apr 2013 21:52:19 +1200
Subject: [PATCH 12/13] fix the append box when importing collections

---
 inc/ui/collection-edit.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/inc/ui/collection-edit.php b/inc/ui/collection-edit.php
index 9a3e056b..20f91298 100644
--- a/inc/ui/collection-edit.php
+++ b/inc/ui/collection-edit.php
@@ -115,7 +115,7 @@ if ( $can_write_collection && $editor->IsSubmit() ) {
       param_to_global('mode');
       include_once('caldav-PUT-functions.php');
       controlRequestContainer( $username, $user_no, $path, false, ($publicly_readable == 'on' ? true : false));
-      import_collection( $ics, $user_no, $path, $session->user_no, ($mode == 'append') );
+      import_collection( $ics, $user_no, $path, $session->user_no, ($mode == 'on') );
       $c->messages[] = sprintf(translate('Calendar "%s" was loaded from file.'), $path);
     }
     else {

From a5100a168144076eca8c9769efc6d29e1a611920 Mon Sep 17 00:00:00 2001
From: Matthias 
Date: Tue, 28 May 2013 12:51:32 +0200
Subject: [PATCH 13/13] Fixed schedule reply handling for missing organizer

---
 inc/caldav-PUT-functions.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php
index 70b1baf7..db9e376c 100644
--- a/inc/caldav-PUT-functions.php
+++ b/inc/caldav-PUT-functions.php
@@ -279,7 +279,7 @@ function handle_schedule_reply ( vCalendar $ical ) {
   $etag = md5 ( $request->raw_post );
   $organizer = $ical->GetOrganizer();
   // for now we treat events with out organizers as an error
-  if ( count ( $organizer ) < 1 ) return false;
+  if ( empty( $organizer ) ) return false;
 
   $attendees = array_merge($organizer,$ical->GetAttendees());
   dbg_error_log( "PUT", "Attempting to deliver scheduling request for %d attendees", count($attendees) );