diff --git a/INSTALL.txt b/INSTALL.txt new file mode 100644 index 00000000..ec9372e8 --- /dev/null +++ b/INSTALL.txt @@ -0,0 +1,18 @@ +********************* +* Install Using Git * +********************* + +To install all addons using git, cd into your top level Friendica directory and + +git clone https://github.com/friendica/friendica-addons.git addon + +This will clone the entire repository in a directory called addon. They can now be activated in the plugins section of your admin panel. + +******************** +* Install Manually * +******************** + +1. Download the archive (AddonName.tgz) containing the addon you want to install. +2. Unzip the contents of the archive to your harddrive. +3. Upload the extracted directory and all it's contents to /path/to/friendica/addon. You will need to create the addon directory if this is the first addon you have installed. +4. Activate the addon in the plugins section of your admin panel. diff --git a/altpager.tgz b/altpager.tgz new file mode 100644 index 00000000..fbfd5594 Binary files /dev/null and b/altpager.tgz differ diff --git a/altpager/altpager.php b/altpager/altpager.php index 65f9c0d8..c6f537bd 100755 --- a/altpager/altpager.php +++ b/altpager/altpager.php @@ -61,6 +61,10 @@ function altpager_settings(&$a,&$s) { if(! local_user()) return; + $global = get_config("alt_pager", "global"); + if($global == 1) + return; + /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '' . "\r\n"; @@ -87,3 +91,19 @@ function altpager_settings(&$a,&$s) { $s .= '
'; } + +function altpager_plugin_admin(&$a, &$o){ + $t = get_markup_template( "admin.tpl", "addon/altpager/" ); + $o = replace_macros($t, array( + '$submit' => t('Submit'), + '$global' => array('altpagerchoice', t('Global'), 1, t('Force global use of the alternate pager'), get_config('alt_pager', 'global') == 1), + '$individual' => array('altpagerchoice', t('Individual'), 2, t('Each user chooses whether to use the alternate pager'), get_config('alt_pager', 'global') == 0) + )); +} + +function altpager_plugin_admin_post(&$a){ + $choice = ((x($_POST,'altpagerchoice')) ? notags(trim($_POST['altpagerchoice'])) : ''); + set_config('alt_pager','global',($choice == 1 ? 1 : 0)); + info( t('Settings updated.'). EOL ); +} + diff --git a/altpager/view/admin.tpl b/altpager/view/admin.tpl new file mode 100644 index 00000000..60558808 --- /dev/null +++ b/altpager/view/admin.tpl @@ -0,0 +1,3 @@ +{{ inc field_radio.tpl with $field=$global }}{{ endinc }} +{{ inc field_radio.tpl with $field=$individual }}{{ endinc }} +
diff --git a/altpager/view/admin.tpl.old b/altpager/view/admin.tpl.old new file mode 100755 index 00000000..60558808 --- /dev/null +++ b/altpager/view/admin.tpl.old @@ -0,0 +1,3 @@ +{{ inc field_radio.tpl with $field=$global }}{{ endinc }} +{{ inc field_radio.tpl with $field=$individual }}{{ endinc }} +
diff --git a/altpager/view/smarty3/admin.tpl b/altpager/view/smarty3/admin.tpl new file mode 100644 index 00000000..e67afd73 --- /dev/null +++ b/altpager/view/smarty3/admin.tpl @@ -0,0 +1,3 @@ +{{include file="field_radio.tpl" field=$global}} +{{include file="field_radio.tpl" field=$individual}} +
diff --git a/blackout.tgz b/blackout.tgz index 4b5a5d31..6d081dc4 100644 Binary files a/blackout.tgz and b/blackout.tgz differ diff --git a/blackout/blackout.php b/blackout/blackout.php index 2cb7c041..83495611 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -93,8 +93,9 @@ function blackout_plugin_admin(&$a, &$o) { if (! is_string($myend)) { $myend = "YYYY-MM-DD:hhmm"; } $myurl = get_config('blackout','url'); if (! is_string($myurl)) { $myurl = "http://www.example.com"; } - $t = file_get_contents( dirname(__file__)."/admin.tpl" ); - $o = replace_macros($t, array( + $t = get_markup_template( "admin.tpl", "addon/blackout/" ); + + $o = replace_macros($t, array( '$submit' => t('Submit'), '$rurl' => array("rurl", "Redirect URL", $myurl, "all your visitors from the web will be redirected to this URL"), '$startdate' => array("startdate", "Begin of the Blackout
(YYYY-MM-DD hh:mm)", $mystart, "format is YYYY year, MM month, DD day, hh hour and mm minute"), diff --git a/blackout/admin.tpl b/blackout/view/admin.tpl similarity index 100% rename from blackout/admin.tpl rename to blackout/view/admin.tpl diff --git a/blackout/view/smarty3/admin.tpl b/blackout/view/smarty3/admin.tpl new file mode 100644 index 00000000..11a4d914 --- /dev/null +++ b/blackout/view/smarty3/admin.tpl @@ -0,0 +1,11 @@ +{{include file="field_input.tpl" field=$startdate}} +{{include file="field_input.tpl" field=$enddate}} +{{include file="field_input.tpl" field=$rurl}} + +
Note: The redirect will be active from the moment you +press the submit button. Users currently logged in will not be +thrown out but can't login again after logging out should the blackout is +still in place.
+ +
diff --git a/blockem.tgz b/blockem.tgz index c1842e52..65026527 100755 Binary files a/blockem.tgz and b/blockem.tgz differ diff --git a/blockem/blockem.php b/blockem/blockem.php index 5ff87c58..85c7fec6 100755 --- a/blockem/blockem.php +++ b/blockem/blockem.php @@ -157,9 +157,9 @@ function blockem_item_photo_menu(&$a,&$b) { } } if($blocked) - $b['menu'][ t('Unblock Author')] = 'javascript:blockemUnblock("' . $author . '");'; + $b['menu'][ t('Unblock Author')] = 'javascript:blockemUnblock(\'' . $author . '\');'; else - $b['menu'][ t('Block Author')] = 'javascript:blockemBlock("' . $author . '");'; + $b['menu'][ t('Block Author')] = 'javascript:blockemBlock(\'' . $author . '\');'; } function blockem_module() {} diff --git a/buglink.tgz b/buglink.tgz index 171a17e9..f66558f2 100755 Binary files a/buglink.tgz and b/buglink.tgz differ diff --git a/buglink/buglink.php b/buglink/buglink.php index faa97a0c..9cd35ccd 100755 --- a/buglink/buglink.php +++ b/buglink/buglink.php @@ -12,4 +12,4 @@ function buglink_install() { register_hook('page_end', 'addon/buglink/buglink.ph function buglink_uninstall() { unregister_hook('page_end', 'addon/buglink/buglink.php', 'buglink_active'); } -function buglink_active(&$a,&$b) { $b .= '
' . t('Report Bug') . '
'; } +function buglink_active(&$a,&$b) { $b .= '
' . t('Report Bug') . '
'; } diff --git a/communityhome.tgz b/communityhome.tgz index 129081b6..71f1f8e3 100755 Binary files a/communityhome.tgz and b/communityhome.tgz differ diff --git a/communityhome/communityhome.php b/communityhome/communityhome.php index 2b14fd33..8b831888 100755 --- a/communityhome/communityhome.php +++ b/communityhome/communityhome.php @@ -47,7 +47,8 @@ function communityhome_home(&$a, &$o){ 0, 12 ); - $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl'); +# $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl'); + $tpl = get_markup_template( 'directory_item.tpl', 'addon/communityhome/' ); if(count($r)) { $photo = 'thumb'; foreach($r as $rr) { @@ -105,6 +106,7 @@ function communityhome_home(&$a, &$o){ `user` WHERE `user`.`uid` = `photo`.`uid` AND `user`.`blockwall`=0 + AND `user`.`hidewall` = 0 ORDER BY `photo`.`edited` DESC LIMIT 0, 12", dbesc(t('Contact Photos')), @@ -113,7 +115,8 @@ function communityhome_home(&$a, &$o){ if(count($r)) { - $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl'); +# $tpl = file_get_contents( dirname(__file__).'/directory_item.tpl'); + $tpl = get_markup_template( 'directory_item.tpl', 'addon/communityhome/' ); foreach($r as $rr) { $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id']; $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg'; @@ -173,7 +176,8 @@ function communityhome_home(&$a, &$o){ } - $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl'); +# $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl'); + $tpl = get_markup_template('communityhome.tpl', 'addon/communityhome/'); $a->page['aside'] = replace_macros($tpl, $aside); $o = '

' . ((x($a->config,'sitename')) ? sprintf( t("Welcome to %s") ,$a->config['sitename']) : "" ) . '

'; diff --git a/communityhome/communityhome.tpl b/communityhome/view/communityhome.tpl similarity index 100% rename from communityhome/communityhome.tpl rename to communityhome/view/communityhome.tpl diff --git a/communityhome/directory_item.tpl b/communityhome/view/directory_item.tpl similarity index 100% rename from communityhome/directory_item.tpl rename to communityhome/view/directory_item.tpl diff --git a/communityhome/view/smarty3/communityhome.tpl b/communityhome/view/smarty3/communityhome.tpl new file mode 100644 index 00000000..b8f80381 --- /dev/null +++ b/communityhome/view/smarty3/communityhome.tpl @@ -0,0 +1,70 @@ + +{{if $noOid}} +

{{$login_title}}

+{{else}} + +{{/if}} +{{$login_form}} + + +{{if $lastusers_title}} +

{{$lastusers_title}}

+
+{{foreach $lastusers_items as $i}} + {{$i}} +{{/foreach}} +
+{{/if}} + + +{{if $activeusers_title}} +

{{$activeusers_title}}

+
+{{foreach $activeusers_items as $i}} + {{$i}} +{{/foreach}} +
+{{/if}} + +{{if $photos_title}} +

{{$photos_title}}

+
+{{foreach $photos_items as $i}} + {{$i}} +{{/foreach}} +
+{{/if}} + + +{{if $like_title}} +

{{$like_title}}

+ +{{/if}} diff --git a/communityhome/view/smarty3/directory_item.tpl b/communityhome/view/smarty3/directory_item.tpl new file mode 100644 index 00000000..5fb11986 --- /dev/null +++ b/communityhome/view/smarty3/directory_item.tpl @@ -0,0 +1,10 @@ + +
+
+
+ + {{$alt}}-text + +
+
+
diff --git a/convert.tgz b/convert.tgz index 56e0080c..766eaf7a 100755 Binary files a/convert.tgz and b/convert.tgz differ diff --git a/dav.tgz b/dav.tgz new file mode 100644 index 00000000..a687deab Binary files /dev/null and b/dav.tgz differ diff --git a/dav/Changelog.txt b/dav/Changelog.txt index 90117b71..c336baa9 100644 --- a/dav/Changelog.txt +++ b/dav/Changelog.txt @@ -1,3 +1,8 @@ +v0.3 +[REFACTOR] The new version of the VObject Library is used +[REFACTOR] The addressbook part has beed heavily refactored +[REFACTOR] Remove some Friendica-specific code out of the "common"-folder + v0.2.0 ====== [FEATURE] Multiple private Calendars can be created. Each calendar can have its own default color; single events of a calendar can override this setting. diff --git a/dav/SabreDAV/ChangeLog b/dav/SabreDAV/ChangeLog index 1199ae76..3f424d95 100644 --- a/dav/SabreDAV/ChangeLog +++ b/dav/SabreDAV/ChangeLog @@ -14,6 +14,7 @@ only used for informational purposes. * BC Break: The DAV: namespace is no longer converted to urn:DAV. This was a workaround for a bug in older PHP versions (pre-5.3). + * Changed: The Sabre_VObject library now spawned into it's own project! * New feature: Support for caldav notifications! * Changed: Responsibility for dealing with the calendar-query is now moved from the CalDAV plugin to the CalDAV backends. This allows for @@ -33,13 +34,14 @@ * Fixed: Uploaded VCards without a UID are now rejected. (thanks Dominik!) * Fixed: Rejecting calendar objects if they are not in the supported-calendar-component list. (thanks Armin!) - * Fixed: Workaround for 10.8 Mountain Lion vCards, as it needs \r line - endings to parse them correctly. * Fixed: Issue 219: serialize() now reorders correctly. * Fixed: Sabre_DAV_XMLUtil no longer returns empty $dom->childNodes if there is whitespace in $dom. -1.6.4-stable (2012-??-??) +1.6.5-stable (2012-??-??) + * Fixed: Workaround for line-ending bug OS X 10.8 addressbook has. + +1.6.4-stable (2012-08-02) * Fixed: Issue 220: Calendar-query filters may fail when filtering on alarms, if an overridden event has it's alarm removed. * Fixed: Compatibility for OS/X 10.8 iCal in the IMipHandler. @@ -56,6 +58,8 @@ exactly on the start of a time-range. * Fixed: HTTP basic auth did not correctly deal with passwords containing colons on some servers. + * Fixed: Issue 228: DTEND is now non-inclusive for all-day events in the + calendar-query REPORT and free-busy calculations. 1.6.3-stable (2012-06-12) * Added: It's now possible to specify in Sabre_DAV_Client which type of diff --git a/dav/SabreDAV/composer.json b/dav/SabreDAV/composer.json index 8875829e..1a427e76 100644 --- a/dav/SabreDAV/composer.json +++ b/dav/SabreDAV/composer.json @@ -1,21 +1,30 @@ { - "name": "evert/sabredav", + "name": "sabre/dav", "type": "library", "description": "WebDAV Framework for PHP", "keywords": ["Framework", "WebDAV", "CalDAV", "CardDAV", "iCalendar"], "homepage": "http://code.google.com/p/sabredav/", - "license": "New BSD License", + "license" : "BSD-3-Clause", "authors": [ { "name": "Evert Pot", "email": "evert@rooftopsolutions.nl", - "homepage" : "http://www.rooftopsolutions.nl/" + "homepage" : "http://www.rooftopsolutions.nl/", + "role" : "Developer" } ], "require": { - "php": ">=5.3.1" + "php": ">=5.3.1", + "sabre/vobject" : "master-dev" + }, + "provide" : { + "evert/sabredav" : "2.0.0" }, "autoload": { "psr-0": { "Sabre": "lib/" } + }, + "support" : { + "forum" : "https://groups.google.com/group/sabredav-discuss", + "source" : "https://github.com/evert/sabredav" } } diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php index 480e6329..8adf10e1 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php @@ -1,5 +1,7 @@ getCalendarObject($object['calendarid'], $object['uri']); } - $vObject = Sabre_VObject_Reader::read($object['calendardata']); + $vObject = VObject\Reader::read($object['calendardata']); $validator = new Sabre_CalDAV_CalendarQueryValidator(); return $validator->validate($vObject, $filters); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php index 105ebd33..74b34267 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php @@ -1,5 +1,7 @@ DTEND->getDateTime()->getTimeStamp(); } elseif (isset($component->DURATION)) { $endDate = clone $component->DTSTART->getDateTime(); - $endDate->add(Sabre_VObject_DateTimeParser::parse($component->DURATION->value)); + $endDate->add(VObject\DateTimeParser::parse($component->DURATION->value)); $lastOccurence = $endDate->getTimeStamp(); - } elseif ($component->DTSTART->getDateType()===Sabre_VObject_Property_DateTime::DATE) { + } elseif ($component->DTSTART->getDateType()===VObject\Property\DateTime::DATE) { $endDate = clone $component->DTSTART->getDateTime(); $endDate->modify('+1 day'); $lastOccurence = $endDate->getTimeStamp(); @@ -494,7 +496,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { $lastOccurence = $firstOccurence; } } else { - $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->UID); + $it = new VObject\RecurrenceIterator($vObject, (string)$component->UID); $maxDate = new DateTime(self::MAX_DATE); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php index 098edccc..b95095f9 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php @@ -1,5 +1,7 @@ item(0); if ($start = $timeRangeNode->getAttribute('start')) { - $start = Sabre_VObject_DateTimeParser::parseDateTime($start); + $start = VObject\DateTimeParser::parseDateTime($start); } else { $start = null; } if ($end = $timeRangeNode->getAttribute('end')) { - $end = Sabre_VObject_DateTimeParser::parseDateTime($end); + $end = VObject\DateTimeParser::parseDateTime($end); } else { $end = null; } @@ -274,13 +276,13 @@ class Sabre_CalDAV_CalendarQueryParser { if(!$start) { throw new Sabre_DAV_Exception_BadRequest('The "start" attribute is required for the CALDAV:expand element'); } - $start = Sabre_VObject_DateTimeParser::parseDateTime($start); + $start = VObject\DateTimeParser::parseDateTime($start); $end = $parentNode->getAttribute('end'); if(!$end) { throw new Sabre_DAV_Exception_BadRequest('The "end" attribute is required for the CALDAV:expand element'); } - $end = Sabre_VObject_DateTimeParser::parseDateTime($end); + $end = VObject\DateTimeParser::parseDateTime($end); if ($end <= $start) { throw new Sabre_DAV_Exception_BadRequest('The end-date must be larger than the start-date in the expand element.'); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php index 8f674840..53e86fc5 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php @@ -1,5 +1,7 @@ parent->name === 'VEVENT' && $component->parent->RRULE) { // Fire up the iterator! - $it = new Sabre_VObject_RecurrenceIterator($component->parent->parent, (string)$component->parent->UID); + $it = new VObject\RecurrenceIterator($component->parent->parent, (string)$component->parent->UID); while($it->valid()) { $expandedEvent = $it->getEventObject(); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php b/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php index ec42b406..d3e4e7b7 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php @@ -1,5 +1,7 @@ version = '2.0'; if (Sabre_DAV_Server::$exposeVersion) { $calendar->prodid = '-//SabreDAV//SabreDAV ' . Sabre_DAV_Version::VERSION . '//EN'; @@ -103,7 +105,7 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin { } $nodeData = $node[200]['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data']; - $nodeComp = Sabre_VObject_Reader::read($nodeData); + $nodeComp = VObject\Reader::read($nodeData); foreach($nodeComp->children() as $child) { diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php b/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php index 0b0978f1..c0e4a206 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php @@ -1,5 +1,7 @@ server->getPropertiesForPath($uri,$properties); if ($expand && isset($objProps[200]['{' . self::NS_CALDAV . '}calendar-data'])) { - $vObject = Sabre_VObject_Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']); + $vObject = VObject\Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']); $vObject->expand($start, $end); $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); } @@ -543,7 +545,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) { $validator = new Sabre_CalDAV_CalendarQueryValidator(); - $vObject = Sabre_VObject_Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); + $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); if ($validator->validate($vObject,$parser->filters)) { // If the client didn't require the calendar-data property, @@ -577,7 +579,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { if ($parser->expand) { // We need to do some post-processing - $vObject = Sabre_VObject_Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); + $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); $vObject->expand($parser->expand['start'], $parser->expand['end']); $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); } @@ -617,10 +619,10 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { } if ($start) { - $start = Sabre_VObject_DateTimeParser::parseDateTime($start); + $start = VObject\DateTimeParser::parseDateTime($start); } if ($end) { - $end = Sabre_VObject_DateTimeParser::parseDateTime($end); + $end = VObject\DateTimeParser::parseDateTime($end); } if (!$start && !$end) { @@ -647,7 +649,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { return $obj; }, $calendar->getChildren()); - $generator = new Sabre_VObject_FreeBusyGenerator(); + $generator = new VObject\FreeBusyGenerator(); $generator->setObjects($objects); $generator->setTimeRange($start, $end); $result = $generator->getResult(); @@ -763,9 +765,9 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { try { - $vobj = Sabre_VObject_Reader::read($data); + $vobj = VObject\Reader::read($data); - } catch (Sabre_VObject_ParseException $e) { + } catch (VObject\ParseException $e) { throw new Sabre_DAV_Exception_UnsupportedMediaType('This resource only supports valid iCalendar 2.0 data. Parse error: ' . $e->getMessage()); @@ -868,8 +870,8 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { } try { - $vObject = Sabre_VObject_Reader::read($this->server->httpRequest->getBody(true)); - } catch (Sabre_VObject_ParseException $e) { + $vObject = VObject\Reader::read($this->server->httpRequest->getBody(true)); + } catch (VObject\ParseException $e) { throw new Sabre_DAV_Exception_BadRequest('The request body must be a valid iCalendar object. Parse error: ' . $e->getMessage()); } @@ -920,10 +922,10 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { * * @param string $originator * @param array $recipients - * @param Sabre_VObject_Component $vObject + * @param Sabre\VObject\Component $vObject * @return array */ - protected function iMIPMessage($originator, array $recipients, Sabre_VObject_Component $vObject, $principal) { + protected function iMIPMessage($originator, array $recipients, VObject\Component $vObject, $principal) { if (!$this->imipHandler) { $resultStatus = '5.2;This server does not support this operation'; diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php b/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php index 1be63a06..f62f94af 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php @@ -1,5 +1,7 @@ getMessage()); @@ -441,7 +443,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { */ public function validateFilters($vcardData, array $filters, $test) { - $vcard = Sabre_VObject_Reader::read($vcardData); + $vcard = VObject\Reader::read($vcardData); if (!$filters) return true; diff --git a/dav/SabreDAV/lib/Sabre/VObject/includes.php b/dav/SabreDAV/lib/Sabre/VObject/includes.php deleted file mode 100644 index 76497d6f..00000000 --- a/dav/SabreDAV/lib/Sabre/VObject/includes.php +++ /dev/null @@ -1,39 +0,0 @@ -RRULE = 'FREQ=MONTHLY'; $vevent->DTSTART = '20120101T120000Z'; $vevent->UID = 'bla'; - $valarm = Sabre_VObject_Component::create('VALARM'); + $valarm = VObject\Component::create('VALARM'); $valarm->TRIGGER = '-P15D'; $vevent->add($valarm); - $vcalendar = Sabre_VObject_Component::create('VCALENDAR'); + $vcalendar = VObject\Component::create('VCALENDAR'); $vcalendar->add($vevent); $filter = array( @@ -52,16 +54,16 @@ class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase { // A limited recurrence rule, should return false - $vevent = Sabre_VObject_Component::create('VEVENT'); + $vevent = VObject\Component::create('VEVENT'); $vevent->RRULE = 'FREQ=MONTHLY;COUNT=1'; $vevent->DTSTART = '20120101T120000Z'; $vevent->UID = 'bla'; - $valarm = Sabre_VObject_Component::create('VALARM'); + $valarm = VObject\Component::create('VALARM'); $valarm->TRIGGER = '-P15D'; $vevent->add($valarm); - $vcalendar = Sabre_VObject_Component::create('VCALENDAR'); + $vcalendar = VObject\Component::create('VCALENDAR'); $vcalendar->add($vevent); $this->assertFalse($validator->validate($vcalendar, $filter)); @@ -69,15 +71,15 @@ class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase { function testAlarmWayBefore() { - $vevent = Sabre_VObject_Component::create('VEVENT'); + $vevent = VObject\Component::create('VEVENT'); $vevent->DTSTART = '20120101T120000Z'; $vevent->UID = 'bla'; - $valarm = Sabre_VObject_Component::create('VALARM'); + $valarm = VObject\Component::create('VALARM'); $valarm->TRIGGER = '-P2W1D'; $vevent->add($valarm); - $vcalendar = Sabre_VObject_Component::create('VCALENDAR'); + $vcalendar = VObject\Component::create('VCALENDAR'); $vcalendar->add($vevent); $filter = array( diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php index 18c8330d..dede4764 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php @@ -1,5 +1,7 @@ null, ); - $vObject = Sabre_VObject_Reader::read($icalObject); + $vObject = VObject\Reader::read($icalObject); switch($outcome) { case 0 : @@ -31,7 +33,7 @@ class Sabre_CalDAV_CalendarQueryValidatorTest extends PHPUnit_Framework_TestCase case -1 : try { $validator->validate($vObject, $filters); - } catch (Sabre_DAV_Exception $e) { + } catch (Exception $e) { // Success } break; diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php index 984212aa..444dc496 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php @@ -1,5 +1,7 @@ VEVENT as $vevent) { - /** @var $vevent Sabre_VObject_Component_VEvent */ + /** @var $vevent Sabre\VObject\Component_VEvent */ foreach ($vevent->children as $child) { - /** @var $child Sabre_VObject_Property */ + /** @var $child Sabre\VObject\Property */ if ($child->name == 'DTSTART') { // DTSTART has to be one of three valid values diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php index a2c2fc27..a183082b 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php @@ -1,5 +1,7 @@ assertEquals(2, count($vObject->VEVENT)); // check if DTSTARTs and DTENDs are correct foreach ($vObject->VEVENT as $vevent) { - /** @var $vevent Sabre_VObject_Component_VEvent */ + /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children as $child) { - /** @var $child Sabre_VObject_Property */ + /** @var $child Sabre\VObject\Property */ if ($child->name == 'DTSTART') { // DTSTART has to be one of two valid values diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php index 55d06b23..087c384f 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php @@ -1,5 +1,7 @@ assertEquals(3, count($vObject->VEVENT),'We got 6 events instead of 3. Output: ' . $body); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php index b8a97ca1..d9a6d586 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php @@ -1,5 +1,7 @@ assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php index d23b8123..c569da8f 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php @@ -1,5 +1,7 @@ 'text/calendar', ), $s->httpResponse->headers); - $obj = Sabre_VObject_Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($s->httpResponse->body); $this->assertEquals(5,count($obj->children())); $this->assertEquals(1,count($obj->VERSION)); @@ -98,7 +100,7 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase { 'Content-Type' => 'text/calendar', ), $s->httpResponse->headers); - $obj = Sabre_VObject_Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($s->httpResponse->body); $this->assertEquals(5,count($obj->children())); $this->assertEquals(1,count($obj->VERSION)); @@ -211,7 +213,7 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase { 'Content-Type' => 'text/calendar', ), $s->httpResponse->headers); - $obj = Sabre_VObject_Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($s->httpResponse->body); $this->assertEquals(5,count($obj->children())); $this->assertEquals(1,count($obj->VERSION)); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php index 3a61663e..11d2f21c 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php @@ -1,5 +1,7 @@ false, 'time-range' => null, ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php index 024b2557..90e13fd8 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php @@ -1,5 +1,7 @@ array(), ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } @@ -77,7 +79,7 @@ HI; ), 'prop-filters' => array(), ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } @@ -125,7 +127,7 @@ HI; ), 'prop-filters' => array(), ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } } diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php index e9eaecab..4cb8eec9 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php @@ -1,5 +1,7 @@ assertEquals(2, count($vObject->VEVENT)); @@ -113,10 +115,10 @@ END:VCALENDAR $matching = false; foreach ($vObject->VEVENT as $vevent) { - /** @var $vevent Sabre_VObject_Component_VEvent */ + /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children as $child) { - /** @var $child Sabre_VObject_Property */ + /** @var $child Sabre\VObject\Property */ if (isset($expectedEvent[$child->name])) { if ($expectedEvent[$child->name] != $child->value) { diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php index 20098252..6e9e497c 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php @@ -1,5 +1,7 @@ assertEquals(1, count($vObject->VEVENT)); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue228Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue228Test.php new file mode 100644 index 00000000..f251ab13 --- /dev/null +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue228Test.php @@ -0,0 +1,75 @@ + 1, + 'name' => 'Calendar', + 'principaluri' => 'principals/user1', + 'uri' => 'calendar1', + ) + ); + + protected $caldavCalendarObjects = array( + 1 => array( + 'event.ics' => array( + 'calendardata' => 'BEGIN:VCALENDAR +VERSION:2.0 +BEGIN:VEVENT +UID:20120730T113415CEST-6804EGphkd@xxxxxx.de +DTSTAMP:20120730T093415Z +DTSTART;VALUE=DATE:20120729 +DTEND;VALUE=DATE:20120730 +SUMMARY:sunday event +TRANSP:TRANSPARENT +END:VEVENT +END:VCALENDAR +', + ), + ), + ); + + function testIssue228() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_CONTENT_TYPE' => 'application/xml', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', + )); + + $request->setBody(' + + + + + + + + + + + + + + +'); + + $response = $this->request($request); + + // We must check if absolutely nothing was returned from this query. + $this->assertFalse(strpos($response->body, 'BEGIN:VCALENDAR')); + + } +} diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VEventTest.php b/dav/SabreDAV/tests/Sabre/VObject/Component/VEventTest.php deleted file mode 100644 index 90579cb4..00000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Component/VEventTest.php +++ /dev/null @@ -1,69 +0,0 @@ -assertEquals($outcome, $vevent->isInTimeRange($start, $end)); - - } - - public function timeRangeTestData() { - - $tests = array(); - - $vevent = new Sabre_VObject_Component_VEvent('VEVENT'); - $vevent->DTSTART = '20111223T120000Z'; - $tests[] = array($vevent, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vevent2 = clone $vevent; - $vevent2->DTEND = '20111225T120000Z'; - $tests[] = array($vevent2, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent2, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vevent3 = clone $vevent; - $vevent3->DURATION = 'P1D'; - $tests[] = array($vevent3, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent3, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vevent4 = clone $vevent; - $vevent4->DTSTART = '20111225'; - $vevent4->DTSTART['VALUE'] = 'DATE'; - $tests[] = array($vevent4, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent4, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - // Event with no end date should be treated as lasting the entire day. - $tests[] = array($vevent4, new DateTime('2011-12-25 16:00:00'), new DateTime('2011-12-25 17:00:00'), true); - - - $vevent5 = clone $vevent; - $vevent5->DURATION = 'P1D'; - $vevent5->RRULE = 'FREQ=YEARLY'; - $tests[] = array($vevent5, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent5, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - $tests[] = array($vevent5, new DateTime('2013-12-01'), new DateTime('2013-12-31'), true); - - $vevent6 = clone $vevent; - $vevent6->DTSTART = '20111225'; - $vevent6->DTSTART['VALUE'] = 'DATE'; - $vevent6->DTEND = '20111225'; - $vevent6->DTEND['VALUE'] = 'DATE'; - $tests[] = array($vevent6, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent6, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - // Added this test to ensure that recurrence rules with no DTEND also - // get checked for the entire day. - $vevent7 = clone $vevent; - $vevent7->DTSTART = '20120101'; - $vevent7->DTSTART['VALUE'] = 'DATE'; - $vevent7->RRULE = 'FREQ=MONTHLY'; - $tests[] = array($vevent7, new DateTime('2012-02-01 15:00:00'), new DateTime('2012-02-02'), true); - return $tests; - - } - -} - diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VJournalTest.php b/dav/SabreDAV/tests/Sabre/VObject/Component/VJournalTest.php deleted file mode 100644 index 04fcc9db..00000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Component/VJournalTest.php +++ /dev/null @@ -1,37 +0,0 @@ -assertEquals($outcome, $vtodo->isInTimeRange($start, $end)); - - } - - public function timeRangeTestData() { - - $tests = array(); - - $vjournal = Sabre_VObject_Component::create('VJOURNAL'); - $vjournal->DTSTART = '20111223T120000Z'; - $tests[] = array($vjournal, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vjournal, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vjournal2 = Sabre_VObject_Component::create('VJOURNAL'); - $vjournal2->DTSTART = '20111223'; - $vjournal2->DTSTART['VALUE'] = 'DATE'; - $tests[] = array($vjournal2, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vjournal2, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vjournal3 = Sabre_VObject_Component::create('VJOURNAL'); - $tests[] = array($vjournal3, new DateTime('2011-01-01'), new DateTime('2012-01-01'), false); - $tests[] = array($vjournal3, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - return $tests; - } - -} - diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VTodoTest.php b/dav/SabreDAV/tests/Sabre/VObject/Component/VTodoTest.php deleted file mode 100644 index a8bd619a..00000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Component/VTodoTest.php +++ /dev/null @@ -1,63 +0,0 @@ -assertEquals($outcome, $vtodo->isInTimeRange($start, $end)); - - } - - public function timeRangeTestData() { - - $tests = array(); - - $vtodo = Sabre_VObject_Component::create('VTODO'); - $vtodo->DTSTART = '20111223T120000Z'; - $tests[] = array($vtodo, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo2 = clone $vtodo; - $vtodo2->DURATION = 'P1D'; - $tests[] = array($vtodo2, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo2, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo3 = clone $vtodo; - $vtodo3->DUE = '20111225'; - $tests[] = array($vtodo3, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo3, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo4 = Sabre_VObject_Component::create('VTODO'); - $vtodo4->DUE = '20111225'; - $tests[] = array($vtodo4, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo4, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo5 = Sabre_VObject_Component::create('VTODO'); - $vtodo5->COMPLETED = '20111225'; - $tests[] = array($vtodo5, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo5, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo6 = Sabre_VObject_Component::create('VTODO'); - $vtodo6->CREATED = '20111225'; - $tests[] = array($vtodo6, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo6, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo7 = Sabre_VObject_Component::create('VTODO'); - $vtodo7->CREATED = '20111225'; - $vtodo7->COMPLETED = '20111226'; - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo7 = Sabre_VObject_Component::create('VTODO'); - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2011-11-01'), true); - - return $tests; - - } - -} - diff --git a/dav/SabreDAV/tests/Sabre/VObject/DateTimeParserTest.php b/dav/SabreDAV/tests/Sabre/VObject/DateTimeParserTest.php deleted file mode 100644 index 83e4c429..00000000 --- a/dav/SabreDAV/tests/Sabre/VObject/DateTimeParserTest.php +++ /dev/null @@ -1,117 +0,0 @@ -assertEquals('+1 weeks', Sabre_VObject_DateTimeParser::parseDuration('P1W',true)); - $this->assertEquals('+5 days', Sabre_VObject_DateTimeParser::parseDuration('P5D',true)); - $this->assertEquals('+5 days 3 hours 50 minutes 12 seconds', Sabre_VObject_DateTimeParser::parseDuration('P5DT3H50M12S',true)); - $this->assertEquals('-1 weeks 50 minutes', Sabre_VObject_DateTimeParser::parseDuration('-P1WT50M',true)); - $this->assertEquals('+50 days 3 hours 2 seconds', Sabre_VObject_DateTimeParser::parseDuration('+P50DT3H2S',true)); - $this->assertEquals(new DateInterval('PT0S'), Sabre_VObject_DateTimeParser::parseDuration('PT0S')); - - } - - function testParseICalendarDurationDateInterval() { - - $expected = new DateInterval('P7D'); - $this->assertEquals($expected, Sabre_VObject_DateTimeParser::parseDuration('P1W')); - $this->assertEquals($expected, Sabre_VObject_DateTimeParser::parse('P1W')); - - $expected = new DateInterval('PT3M'); - $expected->invert = true; - $this->assertEquals($expected, Sabre_VObject_DateTimeParser::parseDuration('-PT3M')); - - } - - /** - * @expectedException Sabre_DAV_Exception_BadRequest - */ - function testParseICalendarDurationFail() { - - Sabre_VObject_DateTimeParser::parseDuration('P1X',true); - - } - - function testParseICalendarDateTime() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405'); - - $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); - - $this->assertEquals($compare, $dateTime); - - } - - /** - * @depends testParseICalendarDateTime - * @expectedException Sabre_DAV_Exception_BadRequest - */ - function testParseICalendarDateTimeBadFormat() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405 '); - - } - - /** - * @depends testParseICalendarDateTime - */ - function testParseICalendarDateTimeUTC() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405Z'); - - $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); - $this->assertEquals($compare, $dateTime); - - } - - /** - * @depends testParseICalendarDateTime - */ - function testParseICalendarDateTimeUTC2() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20101211T160000Z'); - - $compare = new DateTime('2010-12-11 16:00:00',new DateTimeZone('UTC')); - $this->assertEquals($compare, $dateTime); - - } - - /** - * @depends testParseICalendarDateTime - */ - function testParseICalendarDateTimeCustomTimeZone() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405', new DateTimeZone('Europe/Amsterdam')); - - $compare = new DateTime('2010-03-16 13:14:05',new DateTimeZone('UTC')); - $this->assertEquals($compare, $dateTime); - - } - - function testParseICalendarDate() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDate('20100316'); - - $expected = new DateTime('2010-03-16 00:00:00',new DateTimeZone('UTC')); - - $this->assertEquals($expected, $dateTime); - - $dateTime = Sabre_VObject_DateTimeParser::parse('20100316'); - $this->assertEquals($expected, $dateTime); - - } - - /** - * @depends testParseICalendarDate - * @expectedException Sabre_DAV_Exception_BadRequest - */ - function testParseICalendarDateBadFormat() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDate('20100316T141405'); - - } -} diff --git a/dav/SabreDAV/tests/Sabre/VObject/Issue153Test.php b/dav/SabreDAV/tests/Sabre/VObject/Issue153Test.php deleted file mode 100644 index 16557c52..00000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Issue153Test.php +++ /dev/null @@ -1,12 +0,0 @@ -assertEquals('Test Benutzer', (string)$obj->fn); - - } - -} diff --git a/dav/SabreDAV/tests/bootstrap.php b/dav/SabreDAV/tests/bootstrap.php index 8dcae248..c3be7366 100644 --- a/dav/SabreDAV/tests/bootstrap.php +++ b/dav/SabreDAV/tests/bootstrap.php @@ -4,9 +4,9 @@ define('SABRE_MYSQLDSN','mysql:host=127.0.0.1;dbname=sabredav'); define('SABRE_MYSQLUSER','root'); define('SABRE_MYSQLPASS',''); -set_include_path(dirname(__FILE__) . PATH_SEPARATOR . dirname(__FILE__) . '/../lib/' . PATH_SEPARATOR . get_include_path()); +set_include_path(__DIR__ . '/../lib/' . PATH_SEPARATOR . __DIR__ . PATH_SEPARATOR . get_include_path()); -include 'Sabre/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; include 'Sabre/DAVServerTest.php'; date_default_timezone_set('GMT'); diff --git a/dav/common/calendar.fnk.php b/dav/common/calendar.fnk.php index 1bfe97e2..11f31f7d 100644 --- a/dav/common/calendar.fnk.php +++ b/dav/common/calendar.fnk.php @@ -7,7 +7,9 @@ define("DAV_DISPLAYNAME", "{DAV:}displayname"); define("DAV_CALENDARCOLOR", "{http://apple.com/ns/ical/}calendar-color"); -class DAVVersionMismatchException extends Exception {} +class DAVVersionMismatchException extends Exception +{ +} class vcard_source_data_email @@ -99,9 +101,6 @@ class vcard_source_data public $photo; } -; - - /** * @param vcard_source_data $vcardsource * @return string @@ -196,13 +195,9 @@ function icalendar_sanitize_string($str = "") */ function dav_createRootCalendarNode() { - $caldavBackend_std = Sabre_CalDAV_Backend_Private::getInstance(); - $caldavBackend_community = Sabre_CalDAV_Backend_Friendica::getInstance(); - - return new Sabre_CalDAV_AnimexxCalendarRootNode(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), array( - $caldavBackend_std, - $caldavBackend_community, - )); + $backends = array(Sabre_CalDAV_Backend_Private::getInstance()); + foreach ($GLOBALS["CALDAV_PRIVATE_SYSTEM_BACKENDS"] as $backendclass) $backends[] = $backendclass::getInstance(); + return new Sabre_CalDAV_AnimexxCalendarRootNode(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), $backends); } /** @@ -210,13 +205,10 @@ function dav_createRootCalendarNode() */ function dav_createRootContactsNode() { - $carddavBackend_std = Sabre_CardDAV_Backend_Std::getInstance(); - $carddavBackend_community = Sabre_CardDAV_Backend_FriendicaCommunity::getInstance(); + $backends = array(Sabre_CardDAV_Backend_Std::getInstance()); + foreach ($GLOBALS["CARDDAV_PRIVATE_SYSTEM_BACKENDS"] as $backendclass) $backends[] = $backendclass::getInstance(); - return new Sabre_CardDAV_AddressBookRootFriendica(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), array( - $carddavBackend_std, - $carddavBackend_community, - )); + return new Sabre_CardDAV_AddressBookRootFriendica(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), $backends); } @@ -242,15 +234,11 @@ function dav_create_server($force_authentication = false, $needs_caldav = true, // The object tree needs in turn to be passed to the server class $server = new Sabre_DAV_Server($tree); - $server->setBaseUri(CALDAV_URL_PREFIX); + if (CALDAV_URL_PREFIX != "") $server->setBaseUri(CALDAV_URL_PREFIX); - $authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), 'SabreDAV'); + $authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), DAV_APPNAME); $server->addPlugin($authPlugin); - $aclPlugin = new Sabre_DAVACL_Plugin_Friendica(); - $aclPlugin->defaultUsernamePath = "principals/users"; - $server->addPlugin($aclPlugin); - if ($needs_caldav) { $caldavPlugin = new Sabre_CalDAV_Plugin(); $server->addPlugin($caldavPlugin); @@ -260,6 +248,16 @@ function dav_create_server($force_authentication = false, $needs_caldav = true, $server->addPlugin($carddavPlugin); } + if ($GLOBALS["CALDAV_ACL_PLUGIN_CLASS"] != "") { + $aclPlugin = new $GLOBALS["CALDAV_ACL_PLUGIN_CLASS"](); + $aclPlugin->defaultUsernamePath = "principals/users"; + $server->addPlugin($aclPlugin); + } else { + $aclPlugin = new Sabre_DAVACL_Plugin(); + $aclPlugin->defaultUsernamePath = "principals/users"; + $server->addPlugin($aclPlugin); + } + if ($force_authentication) $server->broadcastEvent('beforeMethod', array("GET", "/")); // Make it authenticate return $server; @@ -286,7 +284,7 @@ function dav_get_current_user_calendars(&$server, $with_privilege = "") $calendars = array(); /** @var Sabre_DAVACL_Plugin $aclplugin */ $aclplugin = $server->getPlugin("acl"); - foreach ($children as $child) if (is_a($child, "Sabre_CalDAV_Calendar")) { + foreach ($children as $child) if (is_a($child, "Sabre_CalDAV_Calendar") || is_subclass_of($child, "Sabre_CalDAV_Calendar")) { if ($with_privilege != "") { $caluri = $calendar_path . $child->getName(); if ($aclplugin->checkPrivileges($caluri, $with_privilege, Sabre_DAVACL_Plugin::R_PARENT, false)) $calendars[] = $child; @@ -303,7 +301,7 @@ function dav_get_current_user_calendars(&$server, $with_privilege = "") * @param Sabre_CalDAV_Calendar $calendar * @param string $calendarobject_uri * @param string $with_privilege - * @return null|Sabre_VObject_Component_VCalendar + * @return null|Sabre\VObject\Component\VCalendar */ function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobject_uri, $with_privilege = "") { @@ -319,7 +317,7 @@ function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobje if (!$aclplugin->checkPrivileges($uri, $with_privilege, Sabre_DAVACL_Plugin::R_PARENT, false)) return null; $data = $obj->get(); - $vObject = Sabre_VObject_Reader::read($data); + $vObject = Sabre\VObject\Reader::read($data); return $vObject; } @@ -347,20 +345,19 @@ function dav_get_current_user_calendar_by_id(&$server, $id, $with_privilege = "" /** * @param string $uid - * @return Sabre_VObject_Component_VCalendar $vObject + * @return Sabre\VObject\Component\VCalendar $vObject */ function dav_create_empty_vevent($uid = "") { - $a = get_app(); if ($uid == "") $uid = uniqid(); - return Sabre_VObject_Reader::read("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Friendica//DAV-Plugin//EN\r\nBEGIN:VEVENT\r\nUID:" . $uid . "@" . $a->get_hostname() . + return Sabre\VObject\Reader::read("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//" . DAV_APPNAME . "//DAV-Plugin//EN\r\nBEGIN:VEVENT\r\nUID:" . $uid . "@" . dav_compat_get_hostname() . "\r\nDTSTAMP:" . date("Ymd") . "T" . date("His") . "Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); } /** - * @param Sabre_VObject_Component_VCalendar $vObject - * @return Sabre_VObject_Component_VEvent|null + * @param Sabre\VObject\Component\VCalendar $vObject + * @return Sabre\VObject\Component\VEvent|null */ function dav_get_eventComponent(&$vObject) { diff --git a/dav/common/calendar_rendering.fnk.php b/dav/common/calendar_rendering.fnk.php index f8224795..d80892f7 100644 --- a/dav/common/calendar_rendering.fnk.php +++ b/dav/common/calendar_rendering.fnk.php @@ -3,8 +3,8 @@ /** - * @param Sabre_VObject_Component_VAlarm $alarm - * @param Sabre_VObject_Component_VEvent|Sabre_VObject_Component_VTodo $parent + * @param Sabre\VObject\Component\VAlarm $alarm + * @param Sabre\VObject\Component\VEvent|Sabre\VObject\Component\VTodo $parent * @return DateTime|null * @throws Sabre_DAV_Exception */ @@ -12,12 +12,12 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent) { $trigger = $alarm->__get("TRIGGER"); if (!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') { - $triggerDuration = Sabre_VObject_DateTimeParser::parseDuration($trigger->value); + $triggerDuration = Sabre\VObject\DateTimeParser::parseDuration($trigger->value); $related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START'; if ($related === 'START') { - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $parent->__get("DTSTART"); $effectiveTrigger = $dtstart->getDateTime(); $effectiveTrigger->add($triggerDuration); @@ -28,14 +28,14 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent) $endProp = 'DTEND'; } - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $parent->__get("DTSTART"); if (isset($parent->$endProp)) { $effectiveTrigger = clone $parent->$endProp->getDateTime(); $effectiveTrigger->add($triggerDuration); } elseif ($parent->__get("DURATION") != "") { $effectiveTrigger = clone $dtstart->getDateTime(); - $duration = Sabre_VObject_DateTimeParser::parseDuration($parent->__get("DURATION")); + $duration = Sabre\VObject\DateTimeParser::parseDuration($parent->__get("DURATION")); $effectiveTrigger->add($duration); $effectiveTrigger->add($triggerDuration); } else { @@ -58,10 +58,10 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent) */ function renderCalDavEntry_data(&$calendar, &$calendarobject) { - /** @var Sabre_VObject_Component_VCalendar $vObject */ - $vObject = Sabre_VObject_Reader::read($calendarobject["calendardata"]); + /** @var Sabre\VObject\Component\VCalendar $vObject */ + $vObject = Sabre\VObject\Reader::read($calendarobject["calendardata"]); $componentType = null; - /** @var Sabre_VObject_Component_VEvent $component */ + /** @var Sabre\VObject\Component\VEvent $component */ $component = null; foreach ($vObject->getComponents() as $component) { if ($component->name !== 'VTIMEZONE') { @@ -86,18 +86,18 @@ function renderCalDavEntry_data(&$calendar, &$calendarobject) ); $recurring = ($component->__get("RRULE") ? 1 : 0); - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $component->__get("DTSTART"); - $allday = ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE ? 1 : 0); + $allday = ($dtstart->getDateType() == Sabre\VObject\Property\DateTime::DATE ? 1 : 0); - /** @var array|Sabre_VObject_Component_VAlarm[] $alarms */ + /** @var array|Sabre\VObject\Component\VAlarm[] $alarms */ $alarms = array(); foreach ($component->getComponents() as $a_component) if ($a_component->name == "VALARM") { - /** var Sabre_VObject_Component_VAlarm $component */ + /** var Sabre\VObject\Component\VAlarm $component */ $alarms[] = $a_component; } - $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID")); + $it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID")); $last_end = 0; $max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR * 1); $first = true; diff --git a/dav/common/dav_caldav_backend_common.inc.php b/dav/common/dav_caldav_backend_common.inc.php index 99fcb6c1..97d5722a 100644 --- a/dav/common/dav_caldav_backend_common.inc.php +++ b/dav/common/dav_caldav_backend_common.inc.php @@ -81,22 +81,22 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract /** * @static - * @param Sabre_VObject_Component_VEvent $component + * @param Sabre\VObject\Component\VEvent $component * @return int */ public static function getDtEndTimeStamp(&$component) { - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $component->__get("DTSTART"); if ($component->__get("DTEND")) { - /** @var Sabre_VObject_Property_DateTime $dtend */ + /** @var Sabre\VObject\Property\DateTime $dtend */ $dtend = $component->__get("DTEND"); return $dtend->getDateTime()->getTimeStamp(); } elseif ($component->__get("DURATION")) { $endDate = clone $dtstart->getDateTime(); - $endDate->add(Sabre_VObject_DateTimeParser::parse($component->__get("DURATION")->value)); + $endDate->add(Sabre\VObject\DateTimeParser::parse($component->__get("DURATION")->value)); return $endDate->getTimeStamp(); - } elseif ($dtstart->getDateType() === Sabre_VObject_Property_DateTime::DATE) { + } elseif ($dtstart->getDateType() === Sabre\VObject\Property\DateTime::DATE) { $endDate = clone $dtstart->getDateTime(); $endDate->modify('+1 day'); return $endDate->getTimeStamp(); @@ -124,8 +124,8 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract */ protected function getDenormalizedData($calendarData) { - /** @var Sabre_VObject_Component_VEvent $vObject */ - $vObject = Sabre_VObject_Reader::read($calendarData); + /** @var Sabre\VObject\Component\VEvent $vObject */ + $vObject = Sabre\VObject\Reader::read($calendarData); $componentType = null; $component = null; $firstOccurence = null; @@ -141,15 +141,15 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract throw new Sabre_DAV_Exception_BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); } if ($componentType === 'VEVENT') { - /** @var Sabre_VObject_Component_VEvent $component */ - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Component\VEvent $component */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $component->__get("DTSTART"); $firstOccurence = $dtstart->getDateTime()->getTimeStamp(); // Finding the last occurence is a bit harder if (!$component->__get("RRULE")) { $lastOccurence = self::getDtEndTimeStamp($component); } else { - $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID")); + $it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID")); $maxDate = new DateTime(CALDAV_MAX_YEAR . "-01-01"); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); diff --git a/dav/common/dav_caldav_backend_private.inc.php b/dav/common/dav_caldav_backend_private.inc.php index 5356280a..1eb3b365 100644 --- a/dav/common/dav_caldav_backend_private.inc.php +++ b/dav/common/dav_caldav_backend_private.inc.php @@ -177,7 +177,7 @@ class Sabre_CalDAV_Backend_Private extends Sabre_CalDAV_Backend_Common "principaluri" => $principalUri, '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $cal['ctag'] ? $cal['ctag'] : '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components), - "calendar_class" => "Sabre_CalDAV_Calendar", + "calendar_class" => "Sabre_CalDAV_Calendar_Private", ); foreach ($this->propertyMap as $key=> $field) $dat[$key] = $cal[$field]; diff --git a/dav/common/dav_caldav_calendar_private.inc.php b/dav/common/dav_caldav_calendar_private.inc.php new file mode 100644 index 00000000..65f7c2b0 --- /dev/null +++ b/dav/common/dav_caldav_calendar_private.inc.php @@ -0,0 +1,50 @@ + '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ), + /* + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'protected' => true, + ), + array( + 'privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}read-free-busy', + 'principal' => '{DAV:}authenticated', + 'protected' => true, + ), + */ + + ); + + } + + + +} \ No newline at end of file diff --git a/dav/common/dav_carddav_backend_common.inc.php b/dav/common/dav_carddav_backend_common.inc.php new file mode 100644 index 00000000..4279f8a1 --- /dev/null +++ b/dav/common/dav_carddav_backend_common.inc.php @@ -0,0 +1,116 @@ + $newValue) { + + switch ($property) { + case '{DAV:}displayname' : + $updates['displayname'] = $newValue; + break; + case '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' : + $updates['description'] = $newValue; + break; + default : + // If any unsupported values were being updated, we must + // let the entire request fail. + return false; + } + + } + + // No values are being updated? + if (!$updates) { + return false; + } + + $query = 'UPDATE ' . CALDAV_SQL_DB . CALDAV_SQL_PREFIX . 'addressbooks SET ctag = ctag + 1 '; + foreach ($updates as $key=> $value) { + $query .= ', `' . dbesc($key) . '` = ' . dbesc($key) . ' '; + } + $query .= ' WHERE id = ' . IntVal($addressBookId); + q($query); + + return true; + + } + + /** + * @param int $addressbookId + */ + protected function increaseAddressbookCtag($addressbookId) + { + q("UPDATE %s%saddressbooks SET `ctag` = `ctag` + 1 WHERE `id` = '%d'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId)); + self::$addressbookCache = array(); + } +} \ No newline at end of file diff --git a/dav/common/dav_carddav_backend_std.inc.php b/dav/common/dav_carddav_backend_private.inc.php similarity index 57% rename from dav/common/dav_carddav_backend_std.inc.php rename to dav/common/dav_carddav_backend_private.inc.php index e257d156..71923b99 100644 --- a/dav/common/dav_carddav_backend_std.inc.php +++ b/dav/common/dav_carddav_backend_private.inc.php @@ -1,17 +1,6 @@ getNamespace()) return array(); $addressBooks = array(); - $books = q("SELECT id, uri, displayname, principaluri, description, ctag FROM %s%saddressbooks_phone WHERE principaluri = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($principalUri)); - if (count($books) == 0) { - q("INSERT INTO %s%saddressbooks_phone (uid, principaluri, displayname, uri, description, ctag) VALUES (%d, '%s', '%s', '%s', '%s', 1)", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $uid, dbesc($principalUri), 'Other', 'phone', 'Manually added contacts' - ); - $books = q("SELECT id, uri, displayname, principaluri, description, ctag FROM %s%saddressbooks_phone WHERE principaluri = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($principalUri)); - } + $books = q("SELECT * FROM %s%saddressbooks WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($n["namespace"]), IntVal($n["namespace_id"])); foreach ($books as $row) { + if (in_array($row["uri"], $GLOBALS["CARDDAV_PRIVATE_SYSTEM_ADDRESSBOOKS"])) continue; + $addressBooks[] = array( - 'id' => CARDDAV_NAMESPACE_PHONECONTACTS . "-" . $row['id'], + 'id' => $row['id'], 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], + 'principaluri' => $principalUri, '{DAV:}displayname' => $row['displayname'], '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], '{http://calendarserver.org/ns/}getctag' => $row['ctag'], @@ -76,57 +80,6 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract } - /** - * Updates an addressbook's properties - * - * See Sabre_DAV_IProperties for a description of the mutations array, as - * well as the return value. - * - * @param mixed $addressBookId - * @param array $mutations - * @throws Sabre_DAV_Exception_Forbidden - * @see Sabre_DAV_IProperties::updateProperties - * @return bool|array - */ - public function updateAddressBook($addressBookId, array $mutations) - { - $x = explode("-", $addressBookId); - - $updates = array(); - - foreach ($mutations as $property=> $newValue) { - - switch ($property) { - case '{DAV:}displayname' : - $updates['displayname'] = $newValue; - break; - case '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' : - $updates['description'] = $newValue; - break; - default : - // If any unsupported values were being updated, we must - // let the entire request fail. - return false; - } - - } - - // No values are being updated? - if (!$updates) { - return false; - } - - $query = 'UPDATE ' . CALDAV_SQL_DB . CALDAV_SQL_PREFIX . 'addressbooks_phone SET ctag = ctag + 1 '; - foreach ($updates as $key=> $value) { - $query .= ', `' . dbesc($key) . '` = ' . dbesc($key) . ' '; - } - $query .= ' WHERE id = ' . IntVal($x[1]); - q($query); - - return true; - - } - /** * Creates a new address book * @@ -138,6 +91,8 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract */ public function createAddressBook($principalUri, $url, array $properties) { + $uid = dav_compat_principal2uid($principalUri); + $values = array( 'displayname' => null, 'description' => null, @@ -160,8 +115,8 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract } - q("INSERT INTO %s%saddressbooks_phone (uri, displayname, description, principaluri, ctag) VALUES ('%s', '%s', '%s', '%s', 1)", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($values["uri"]), dbesc($values["displayname"]), dbesc($values["description"]), dbesc($values["principaluri"]) + q("INSERT INTO %s%saddressbooks (`uri`, `displayname`, `description`, `namespace`, `namespace_id`, `ctag`) VALUES ('%s', '%s', '%s', %d, %d, 1)", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($values["uri"]), dbesc($values["displayname"]), dbesc($values["description"]), CARDDAV_NAMESPACE_PRIVATE, IntVal($uid) ); } @@ -174,9 +129,8 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract */ public function deleteAddressBook($addressBookId) { - $x = explode("-", $addressBookId); - q("DELETE FROM %s%scards WHERE namespace = %d AND namespace_id = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1])); - q("DELETE FROM %s%saddressbooks_phone WHERE id = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); + q("DELETE FROM %s%saddressbookobjects WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId)); + q("DELETE FROM %s%saddressbooks WHERE `addressbook_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId)); } /** @@ -200,10 +154,8 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract */ public function getCards($addressbookId) { - $x = explode("-", $addressbookId); - - $r = q('SELECT id, carddata, uri, lastmodified, etag, size, contact FROM %s%scards WHERE namespace = %d AND namespace_id = %d AND manually_deleted = 0', - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]) + $r = q('SELECT `id`, `carddata`, `uri`, `lastmodified`, `etag`, `size`, `contact` FROM %s%saddressbookobjects WHERE `addressbook_id` = %d AND `manually_deleted` = 0', + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId) ); if ($r) return $r; return array(); @@ -222,9 +174,8 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract */ public function getCard($addressBookId, $cardUri) { - $x = explode("-", $addressBookId); - $x = q("SELECT id, carddata, uri, lastmodified, etag, size FROM %s%scards WHERE namespace = %d AND namespace_id = %d AND uri = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($cardUri)); + $x = q("SELECT `id`, `carddata`, `uri`, `lastmodified`, `etag`, `size` FROM %s%saddressbookobjects WHERE `addressbook_id` = %d AND `uri` = '%s'", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId), dbesc($cardUri)); if (count($x) == 0) throw new Sabre_DAV_Exception_NotFound(); return $x[0]; } @@ -257,14 +208,12 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract */ public function createCard($addressBookId, $cardUri, $cardData) { - $x = explode("-", $addressBookId); - $etag = md5($cardData); - q("INSERT INTO %s%scards (carddata, uri, lastmodified, namespace, namespace_id, etag, size) VALUES ('%s', '%s', %d, %d, '%s', %d)", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), dbesc($cardUri), time(), IntVal($x[0]), IntVal($x[1]), $etag, strlen($cardData) + q("INSERT INTO %s%saddressbookobjects (`carddata`, `uri`, `lastmodified`, `addressbook_id`, `etag`, `size`) VALUES ('%s', '%s', NOW(), %d, '%s', %d)", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), dbesc($cardUri), IntVal($addressBookId), dbesc($etag), strlen($cardData) ); - q('UPDATE %s%saddressbooks_phone SET ctag = ctag + 1 WHERE id = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); + q('UPDATE %s%saddressbooks SET `ctag` = `ctag` + 1 WHERE `id` = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId)); return '"' . $etag . '"'; @@ -298,14 +247,12 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract */ public function updateCard($addressBookId, $cardUri, $cardData) { - $x = explode("-", $addressBookId); - $etag = md5($cardData); - q("UPDATE %s%scards SET carddata = '%s', lastmodified = %d, etag = '%s', size = %d, manually_edited = 1 WHERE uri = '%s' AND namespace = %d AND namespace_id =%d", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), time(), $etag, strlen($cardData), dbesc($cardUri), IntVal($x[10]), IntVal($x[1]) + q("UPDATE %s%saddressbookobjects SET `carddata` = '%s', `lastmodified` = NOW(), `etag` = '%s', `size` = %d, `manually_edited` = 1 WHERE `uri` = '%s' AND `addressbook_id` = %d", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), dbesc($etag), strlen($cardData), dbesc($cardUri), IntVal($addressBookId) ); - q('UPDATE %s%saddressbooks_phone SET ctag = ctag + 1 WHERE id = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); + q('UPDATE %s%saddressbooks SET `ctag` = `ctag` + 1 WHERE `id` = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId)); return '"' . $etag . '"'; } @@ -320,10 +267,8 @@ class Sabre_CardDAV_Backend_Std extends Sabre_CardDAV_Backend_Abstract */ public function deleteCard($addressBookId, $cardUri) { - $x = explode("-", $addressBookId); - - q("DELETE FROM %s%scards WHERE namespace = %d AND namespace_id = %d AND uri = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($cardUri)); - q('UPDATE %s%saddressbooks_phone SET ctag = ctag + 1 WHERE id = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); + q("DELETE FROM %s%saddressbookobjects WHERE `addressbook_id` = %d AND `uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId), dbesc($cardUri)); + q('UPDATE %s%saddressbooks SET `ctag` = `ctag` + 1 WHERE `id` = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId)); return true; } diff --git a/dav/common/dav_carddav_backend_virtual.inc.php b/dav/common/dav_carddav_backend_virtual.inc.php new file mode 100644 index 00000000..f81a0a48 --- /dev/null +++ b/dav/common/dav_carddav_backend_virtual.inc.php @@ -0,0 +1,269 @@ +select("X-" . $prop_name); + $curr = $component->select($prop_name); + + if (count($automatic) == 0) { + $prop = new Sabre\VObject\Property('X-' . $prop_name, $prop_value); + foreach ($parameters as $key=>$val) $prop->add($key, $val); + $component->children[] = $prop; + + if (count($curr) == 0) { + $prop = new Sabre\VObject\Property($prop_name, $prop_value); + foreach ($parameters as $key=>$val) $prop->add($key, $val); + $component->children[] = $prop; + } + + } else foreach ($automatic as $auto_prop) { + /** @var Sabre\VObject\Property $auto_prop */ + /** @var Sabre\VObject\Property $actual_prop */ + foreach ($curr as $actual_prop) { + if ($auto_prop->value == $actual_prop->value) $actual_prop->setValue($prop_value); + } + $auto_prop->setValue($prop_value); + } + } + + + + /** + * Deletes the x-prop_name value. Deletes the prop_name value IF the old value is the same as the old value of x-prop_name (meaning: the user has not manually changed it) + * + * @param Sabre\VObject\Component $component + * @param string $prop_name + * @param array $parameters + */ + static public function card_del_automatic_value(&$component, $prop_name, $parameters = array()) { + // @TODO + } + + /** + * @param int $addressbookId + * @param string $objectUri + * @param array $book + * @param array $obj + * @throws Sabre_DAV_Exception_NotFound + * @return array + */ + public function getCard($addressbookId, $objectUri, $book = null, $obj = null) + { + $addressbookId = IntVal($addressbookId); + + if ($book == null) { + $add = q("SELECT `needs_rebuild`, `uri` FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId); + $book = $add[0]; + } + if ($book["needs_rebuild"] == 1) { + static::createCache_internal($addressbookId); + q("UPDATE %s%saddressbooks SET `needs_rebuild` = 0, `ctag` = `ctag` + 1 WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId); + $add[0]["needs_rebuild"] = 0; + } + + if ($obj == null) { + $r = q("SELECT * FROM %s%saddressbookobjects WHERE `uri` = '%s' AND `addressbook_id` = %d AND `manually_deleted` = 0", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($objectUri), IntVal($addressbookId)); + if (count($r) == 0) throw new Sabre_DAV_Exception_NotFound(); + $obj = $r[0]; + if ($obj["needs_rebuild"] == 1) $obj = static::createCardCache($addressbookId, $obj["contact"]); + } + + $ret = array( + "id" => IntVal($obj["uri"]), + "carddata" => $obj["carddata"], + "uri" => $obj["uri"], + "lastmodified" => $obj["lastmodified"], + "addressbookid" => $addressbookId, + "etag" => $obj["etag"], + "size" => IntVal($obj["size"]), + ); + return $ret; + } + + + + /** + * @param string $principalUri + * @param string $addressbookUri + * @param array $properties + * @throws Sabre_DAV_Exception_Forbidden + * @return void + */ + public function createAddressBook($principalUri, $addressbookUri, array $properties) + { + throw new Sabre_DAV_Exception_Forbidden(); + } + + /** + * @param string $addressbookId + * @throws Sabre_DAV_Exception_Forbidden + * @return void + */ + public function deleteAddressBook($addressbookId) + { + throw new Sabre_DAV_Exception_Forbidden(); + } + + + /** + * @param string $addressbookId + * @param string $objectUri + * @param string $cardData + * @throws Sabre_DAV_Exception_Forbidden + * @return null|string|void + */ + function createCard($addressbookId, $objectUri, $cardData) + { + throw new Sabre_DAV_Exception_Forbidden(); + } + + /** + * Updates a card. + * + * The addressbook id will be passed as the first argument. This is the + * same id as it is returned from the getAddressbooksForUser method. + * + * The cardUri is a base uri, and doesn't include the full path. The + * cardData argument is the vcard body, and is passed as a string. + * + * It is possible to return an ETag from this method. This ETag should + * match that of the updated resource, and must be enclosed with double + * quotes (that is: the string itself must contain the actual quotes). + * + * You should only return the ETag if you store the carddata as-is. If a + * subsequent GET request on the same card does not have the same body, + * byte-by-byte and you did return an ETag here, clients tend to get + * confused. + * + * If you don't return an ETag, you can just return null. + * + * @param string $addressBookId + * @param string $cardUri + * @param string $cardData + * @throws Sabre_DAV_Exception_Forbidden + * @return string|null + */ + public function updateCard($addressBookId, $cardUri, $cardData) + { + echo "Die!"; die(); // @TODO + $x = explode("-", $addressBookId); + + $etag = md5($cardData); + q("UPDATE %s%scards SET carddata = '%s', lastmodified = %d, etag = '%s', size = %d, manually_edited = 1 WHERE uri = '%s' AND namespace = %d AND namespace_id =%d", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), time(), $etag, strlen($cardData), dbesc($cardUri), IntVal($x[10]), IntVal($x[1]) + ); + q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); + + return '"' . $etag . '"'; + } + + + + + /** + * Deletes a card + * + * @param string $addressBookId + * @param string $cardUri + * @throws Sabre_DAV_Exception_Forbidden + * @return bool + */ + public function deleteCard($addressBookId, $cardUri) + { + q("UPDATE %s%scards SET `manually_deleted` = 1 WHERE `addressbook_id` = %d AND `uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId), dbesc($cardUri)); + q('UPDATE %s%saddressbooks SET ctag = ctag + 1 WHERE `id` = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId)); + + return true; + } + + +} \ No newline at end of file diff --git a/dav/common/dav_user_calendars.inc.php b/dav/common/dav_user_calendars.inc.php index 62837dc5..b292074d 100644 --- a/dav/common/dav_user_calendars.inc.php +++ b/dav/common/dav_user_calendars.inc.php @@ -169,7 +169,6 @@ class Sabre_CalDAV_AnimexxUserCalendars implements Sabre_DAV_IExtendedCollection $objs[] = new $calendar["calendar_class"]($this->principalBackend, $backend, $calendar); } } - //$objs[] = new Sabre_CalDAV_AnimexxUserZirkelCalendars($this->principalBackend, $this->caldavBackend, $this->username); return $objs; } diff --git a/dav/common/wdcal_backend.inc.php b/dav/common/wdcal_backend.inc.php index 9233da6e..330f2988 100644 --- a/dav/common/wdcal_backend.inc.php +++ b/dav/common/wdcal_backend.inc.php @@ -97,12 +97,12 @@ function wdcal_print_feed($base_path = "") $component = dav_get_eventComponent($item); $component->add("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("CalendarTitle"))); - if (isset($_REQUEST["allday"])) $type = Sabre_VObject_Property_DateTime::DATE; - else $type = Sabre_VObject_Property_DateTime::LOCALTZ; + if (isset($_REQUEST["allday"])) $type = Sabre\VObject\Property\DateTime::DATE; + else $type = Sabre\VObject\Property\DateTime::LOCALTZ; - $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART"); + $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type); - $datetime_end = new Sabre_VObject_Property_DateTime("DTEND"); + $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->add($datetime_start); @@ -179,12 +179,12 @@ function wdcal_print_feed($base_path = "") killme(); } - if (isset($_REQUEST["allday"])) $type = Sabre_VObject_Property_DateTime::DATE; - else $type = Sabre_VObject_Property_DateTime::LOCALTZ; + if (isset($_REQUEST["allday"])) $type = Sabre\VObject\Property\DateTime::DATE; + else $type = Sabre\VObject\Property\DateTime::LOCALTZ; - $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART"); + $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type); - $datetime_end = new Sabre_VObject_Property_DateTime("DTEND"); + $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->__unset("DTSTART"); diff --git a/dav/common/wdcal_edit.inc.php b/dav/common/wdcal_edit.inc.php index dac49368..d507a900 100644 --- a/dav/common/wdcal_edit.inc.php +++ b/dav/common/wdcal_edit.inc.php @@ -29,7 +29,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $calendar_id, $uri) if ($component == null) return t('Could not open component for editing'); - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $component->__get("DTSTART"); $event = array( "id" => IntVal($uri), @@ -44,7 +44,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $calendar_id, $uri) $exdates = $component->select("EXDATE"); $recurrentce_exdates = array(); - /** @var Sabre_VObject_Property_MultiDateTime $x */ + /** @var Sabre\VObject\Property\MultiDateTime $x */ foreach ($exdates as $x) { /** @var DateTime $y */ $z = $x->getDateTimes(); @@ -511,15 +511,15 @@ function wdcal_set_component_date(&$component, &$localization) if (isset($_REQUEST["allday"])) { $ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " 00:00"); $ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " 00:00"); - $type = Sabre_VObject_Property_DateTime::DATE; + $type = Sabre\VObject\Property\DateTime::DATE; } else { $ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]); $ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]); - $type = Sabre_VObject_Property_DateTime::LOCALTZ; + $type = Sabre\VObject\Property\DateTime::LOCALTZ; } - $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART"); + $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type); - $datetime_end = new Sabre_VObject_Property_DateTime("DTEND"); + $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type); $component->__unset("DTSTART"); @@ -539,7 +539,7 @@ function wdcal_set_component_date(&$component, &$localization) function wdcal_set_component_recurrence_special(&$component, $str) { $ret = ""; - /** @var Sabre_VObject_Property_DateTime $start */ + /** @var Sabre\VObject\Property\DateTime $start */ $start = $component->__get("DTSTART"); $dayMap = array( 0 => 'SU', @@ -595,8 +595,8 @@ function wdcal_set_component_recurrence(&$component, &$localization) case "date": $date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]); $part_until = ";UNTIL=" . date("Ymd", $date); - $datetime_until = new Sabre_VObject_Property_DateTime("UNTIL"); - $datetime_until->setDateTime(new DateTime(date("Y-m-d H:i:s", $date)), Sabre_VObject_Property_DateTime::DATE); + $datetime_until = new Sabre\VObject\Property\DateTime("UNTIL"); + $datetime_until->setDateTime(new DateTime(date("Y-m-d H:i:s", $date)), Sabre\VObject\Property\DateTime::DATE); break; case "count": $part_until = ";COUNT=" . IntVal($_REQUEST["rec_until_count"]); @@ -626,7 +626,7 @@ function wdcal_set_component_recurrence(&$component, &$localization) $part_freq .= wdcal_set_component_recurrence_special($component, $_REQUEST["rec_monthly_day"]); break; case "yearly": - /** @var Sabre_VObject_Property_DateTime $start */ + /** @var Sabre\VObject\Property\DateTime $start */ $start = $component->__get("DTSTART"); $part_freq = "FREQ=YEARLY"; $part_freq .= ";BYMONTH=" . $start->getDateTime()->format("n"); @@ -645,20 +645,20 @@ function wdcal_set_component_recurrence(&$component, &$localization) foreach ($_REQUEST["rec_exceptions"] as $except) { $arr[] = new DateTime(date("Y-m-d H:i:s", $except)); } - /** @var Sabre_VObject_Property_MultiDateTime $prop */ - $prop = Sabre_VObject_Property::create("EXDATE"); + /** @var Sabre\VObject\Property\MultiDateTime $prop */ + $prop = Sabre\VObject\Property::create("EXDATE"); $prop->setDateTimes($arr); $component->add($prop); } $rrule = $part_freq . $part_until; - $component->add(new Sabre_VObject_Property("RRULE", $rrule)); + $component->add(new Sabre\VObject\Property("RRULE", $rrule)); } /** - * @param Sabre_VObject_Component_VEvent $component + * @param Sabre\VObject\Component\VEvent $component * @param wdcal_local $localization * @param string $summary * @param int $dtstart @@ -671,12 +671,12 @@ function wdcal_set_component_alerts(&$component, &$localization, $summary, $dtst $component->__unset("VALARM"); foreach ($prev_alarms as $al) { - /** @var Sabre_VObject_Component_VAlarm $al */ + /** @var Sabre\VObject\Component\VAlarm $al */ // @TODO Parse notifications that have been there before; e.g. from Lightning } foreach (array_keys($_REQUEST["noti_type"]) as $key) if (is_numeric($key) || ($key == "new" && $_REQUEST["new_alarm"] == 1)) { - $alarm = new Sabre_VObject_Component_VAlarm("VALARM"); + $alarm = new Sabre\VObject\Component\VAlarm("VALARM"); switch ($_REQUEST["noti_type"][$key]) { case "email": @@ -686,15 +686,15 @@ function wdcal_set_component_alerts(&$component, &$localization, $summary, $dtst $localization->date_timestamp2local($dtstart), $summary, ), t("The event #name# will start at #date")); - $alarm->add(new Sabre_VObject_Property("ACTION", "EMAIL")); - $alarm->add(new Sabre_VObject_Property("SUMMARY", $summary)); - $alarm->add(new Sabre_VObject_Property("DESCRIPTION", $mailtext)); - $alarm->add(new Sabre_VObject_Property("ATTENDEE", "MAILTO:" . $a->user["email"])); + $alarm->add(new Sabre\VObject\Property("ACTION", "EMAIL")); + $alarm->add(new Sabre\VObject\Property("SUMMARY", $summary)); + $alarm->add(new Sabre\VObject\Property("DESCRIPTION", $mailtext)); + $alarm->add(new Sabre\VObject\Property("ATTENDEE", "MAILTO:" . $a->user["email"])); break; case "display": - $alarm->add(new Sabre_VObject_Property("ACTION", "DISPLAY")); + $alarm->add(new Sabre\VObject\Property("ACTION", "DISPLAY")); $text = str_replace("#name#", $summary, t("#name# is about to begin.")); - $alarm->add(new Sabre_VObject_Property("DESCRIPTION", $text)); + $alarm->add(new Sabre\VObject\Property("DESCRIPTION", $text)); break; default: continue; @@ -706,7 +706,7 @@ function wdcal_set_component_alerts(&$component, &$localization, $summary, $dtst $trigger_val .= "-P"; if (in_array($_REQUEST["noti_unit"][$key], array("H", "M", "S"))) $trigger_val .= "T"; $trigger_val .= IntVal($_REQUEST["noti_value"][$key]) . $_REQUEST["noti_unit"][$key]; - $alarm->add(new Sabre_VObject_Property($trigger_name, $trigger_val)); + $alarm->add(new Sabre\VObject\Property($trigger_name, $trigger_val)); $component->add($alarm); } @@ -785,12 +785,12 @@ function wdcal_getEditPage_exception_selector() foreach ($vObject->getComponents() as $component) { if ($component->name !== 'VTIMEZONE') break; } - /** @var Sabre_VObject_Component_VEvent $component */ + /** @var Sabre\VObject\Component\VEvent $component */ wdcal_set_component_date($component, $localization); wdcal_set_component_recurrence($component, $localization); - $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID")); + $it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID")); $max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR + 1); $last_start = 0; diff --git a/dav/dav.php b/dav/dav.php index 05916d01..f4d08f02 100644 --- a/dav/dav.php +++ b/dav/dav.php @@ -2,11 +2,11 @@ /** * Name: Calendar with CalDAV Support * Description: A web-based calendar system with CalDAV-support. Also brings your Friendica-Contacts to your CardDAV-capable mobile phone. Requires PHP >= 5.3. - * Version: 0.2.0 + * Version: 0.3.0 * Author: Tobias Hößl */ $_v = explode(".", phpversion()); if ($_v[0] > 5 || ($_v[0] == 5 && $_v[1] >= 3)) { - require(__DIR__ . "/main.php"); + require(__DIR__ . "/friendica/main.php"); } \ No newline at end of file diff --git a/dav/dav_carddav_backend_virtual_friendica.inc.php b/dav/dav_carddav_backend_virtual_friendica.inc.php deleted file mode 100644 index 8d8a156c..00000000 --- a/dav/dav_carddav_backend_virtual_friendica.inc.php +++ /dev/null @@ -1,336 +0,0 @@ - CARDDAV_NAMESPACE_COMMUNITYCONTACTS . "-" . $uid, - 'uri' => "friendica", - 'principaluri' => $principalUri, - '{DAV:}displayname' => t("Friendica-Contacts"), - '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => t("Your Friendica-Contacts"), - '{http://calendarserver.org/ns/}getctag' => $ctag, - '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => - new Sabre_CardDAV_Property_SupportedAddressData(), - ); - - return $addressBooks; - - } - - - /** - * Updates an addressbook's properties - * - * See Sabre_DAV_IProperties for a description of the mutations array, as - * well as the return value. - * - * @param string $addressBookId - * @param array $mutations - * @throws Sabre_DAV_Exception_Forbidden - * @see Sabre_DAV_IProperties::updateProperties - * @return bool|array - */ - public function updateAddressBook($addressBookId, array $mutations) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Creates a new address book - * - * @param string $principalUri - * @param string $url Just the 'basename' of the url. - * @param array $properties - * @throws Sabre_DAV_Exception_Forbidden - * @return void - */ - public function createAddressBook($principalUri, $url, array $properties) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Deletes an entire addressbook and all its contents - * - * @param int $addressBookId - * @throws Sabre_DAV_Exception_Forbidden - * @return void - */ - public function deleteAddressBook($addressBookId) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - - /** - * @param array $contact - * @return array - */ - private function dav_contactarr2vcardsource($contact) - { - $name = explode(" ", $contact["name"]); - $first_name = $last_name = ""; - $middle_name = array(); - $num = count($name); - for ($i = 0; $i < $num && $first_name == ""; $i++) if ($name[$i] != "") { - $first_name = $name[$i]; - unset($name[$i]); - } - for ($i = $num - 1; $i >= 0 && $last_name == ""; $i--) if (isset($name[$i]) && $name[$i] != "") { - $last_name = $name[$i]; - unset($name[$i]); - } - foreach ($name as $n) if ($n != "") $middle_name[] = $n; - $vcarddata = new vcard_source_data($first_name, implode(" ", $middle_name), $last_name); - $vcarddata->homepages[] = new vcard_source_data_homepage("pref", $contact["url"]); - $vcarddata->last_update = ($contact["last-update"] > 0 ? $contact["last-update"] : $contact["created"]); - - $photo = q("SELECT * FROM photo WHERE `contact-id` = %d ORDER BY scale DESC", $contact["id"]); //prefer size 80x80 - if ($photo && count($photo) > 0) { - $photodata = new vcard_source_data_photo(); - $photodata->width = $photo[0]["width"]; - $photodata->height = $photo[0]["height"]; - $photodata->type = "JPEG"; - $photodata->binarydata = $photo[0]["data"]; - $vcarddata->photo = $photodata; - } - - switch ($contact["network"]) { - case "face": - $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("facebook", $contact["notify"], "http://www.facebook.com/" . $contact["notify"]); - break; - case "dfrn": - $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("dfrn", $contact["nick"], $contact["url"]); - break; - case "twitter": - $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("twitter", $contact["nick"], "http://twitter.com/" . $contact["nick"]); // @TODO Stimmt das? - break; - } - - $vcard = vcard_source_compile($vcarddata); - return array( - "id" => $contact["id"], - "carddata" => $vcard, - "uri" => $contact["id"] . ".vcf", - "lastmodified" => wdcal_mySql2PhpTime($vcarddata->last_update), - "etag" => md5($vcard), - "size" => strlen($vcard), - ); - - } - - /** - * @param int $uid - * @param array|int[] $exclude_ids - * @return array - */ - private function dav_getCommunityContactsVCards($uid = 0, $exclude_ids = array()) - { - $notin = (count($exclude_ids) > 0 ? " AND id NOT IN (" . implode(", ", $exclude_ids) . ") " : ""); - $uid = IntVal($uid); - $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 $notin ORDER BY `name` ASC", $uid); - - $retdata = array(); - foreach ($contacts as $contact) { - $x = $this->dav_contactarr2vcardsource($contact); - $x["contact"] = $contact["id"]; - $retdata[] = $x; - } - return $retdata; - } - - - /** - * Returns all cards for a specific addressbook id. - * - * This method should return the following properties for each card: - * * carddata - raw vcard data - * * uri - Some unique url - * * lastmodified - A unix timestamp - * - * It's recommended to also return the following properties: - * * etag - A unique etag. This must change every time the card changes. - * * size - The size of the card in bytes. - * - * If these last two properties are provided, less time will be spent - * calculating them. If they are specified, you can also ommit carddata. - * This may speed up certain requests, especially with large cards. - * - * @param string $addressbookId - * @return array - */ - public function getCards($addressbookId) - { - $add = explode("-", $addressbookId); - - $indb = q('SELECT id, carddata, uri, lastmodified, etag, size, contact, manually_deleted FROM %s%scards WHERE namespace = %d AND namespace_id = %d', - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($add[0]), IntVal($add[1]) - ); - $found_contacts = array(); - $contacts = array(); - foreach ($indb as $x) { - if ($x["manually_deleted"] == 0) $contacts[] = $x; - $found_contacts[] = IntVal($x["contact"]); - } - $new_found = $this->dav_getCommunityContactsVCards($add[1], $found_contacts); - foreach ($new_found as $new) { - q("INSERT INTO %s%scards (namespace, namespace_id, contact, carddata, uri, lastmodified, manually_edited, manually_deleted, etag, size) - VALUES (%d, %d, %d, '%s', '%s', %d, 0, 0, '%s', %d)", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, - IntVal($add[0]), IntVal($add[1]), IntVal($new["contact"]), dbesc($new["carddata"]), dbesc($new["uri"]), time(), md5($new["carddata"]), strlen($new["carddata"]) - ); - } - return array_merge($contacts, $new_found); - } - - /** - * Returns a specfic card. - * - * The same set of properties must be returned as with getCards. The only - * exception is that 'carddata' is absolutely required. - * - * @param mixed $addressBookId - * @param string $cardUri - * @throws Sabre_DAV_Exception_NotFound - * @return array - */ - public function getCard($addressBookId, $cardUri) - { - $x = explode("-", $addressBookId); - $x = q("SELECT id, carddata, uri, lastmodified, etag, size FROM %s%scards WHERE namespace = %d AND namespace_id = %d AND uri = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($cardUri)); - if (count($x) == 0) throw new Sabre_DAV_Exception_NotFound(); - return $x[0]; - } - - /** - * Creates a new card. - * - * The addressbook id will be passed as the first argument. This is the - * same id as it is returned from the getAddressbooksForUser method. - * - * The cardUri is a base uri, and doesn't include the full path. The - * cardData argument is the vcard body, and is passed as a string. - * - * It is possible to return an ETag from this method. This ETag is for the - * newly created resource, and must be enclosed with double quotes (that - * is, the string itself must contain the double quotes). - * - * You should only return the ETag if you store the carddata as-is. If a - * subsequent GET request on the same card does not have the same body, - * byte-by-byte and you did return an ETag here, clients tend to get - * confused. - * - * If you don't return an ETag, you can just return null. - * - * @param string $addressBookId - * @param string $cardUri - * @param string $cardData - * @throws Sabre_DAV_Exception_Forbidden - * @return string - */ - public function createCard($addressBookId, $cardUri, $cardData) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Updates a card. - * - * The addressbook id will be passed as the first argument. This is the - * same id as it is returned from the getAddressbooksForUser method. - * - * The cardUri is a base uri, and doesn't include the full path. The - * cardData argument is the vcard body, and is passed as a string. - * - * It is possible to return an ETag from this method. This ETag should - * match that of the updated resource, and must be enclosed with double - * quotes (that is: the string itself must contain the actual quotes). - * - * You should only return the ETag if you store the carddata as-is. If a - * subsequent GET request on the same card does not have the same body, - * byte-by-byte and you did return an ETag here, clients tend to get - * confused. - * - * If you don't return an ETag, you can just return null. - * - * @param string $addressBookId - * @param string $cardUri - * @param string $cardData - * @throws Sabre_DAV_Exception_Forbidden - * @return string|null - */ - public function updateCard($addressBookId, $cardUri, $cardData) - { - $x = explode("-", $addressBookId); - - $etag = md5($cardData); - q("UPDATE %s%scards SET carddata = '%s', lastmodified = %d, etag = '%s', size = %d, manually_edited = 1 WHERE uri = '%s' AND namespace = %d AND namespace_id =%d", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), time(), $etag, strlen($cardData), dbesc($cardUri), IntVal($x[10]), IntVal($x[1]) - ); - q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); - - return '"' . $etag . '"'; - } - - /** - * Deletes a card - * - * @param string $addressBookId - * @param string $cardUri - * @throws Sabre_DAV_Exception_Forbidden - * @return bool - */ - public function deleteCard($addressBookId, $cardUri) - { - $x = explode("-", $addressBookId); - - q("UPDATE %s%scards SET manually_deleted = 1 WHERE namespace = %d AND namespace_id = %d AND uri = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($cardUri)); - q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); - - return true; - } -} diff --git a/dav/FriendicaACLPlugin.inc.php b/dav/friendica/FriendicaACLPlugin.inc.php similarity index 100% rename from dav/FriendicaACLPlugin.inc.php rename to dav/friendica/FriendicaACLPlugin.inc.php diff --git a/dav/calendar.friendica.fnk.php b/dav/friendica/calendar.friendica.fnk.php similarity index 74% rename from dav/calendar.friendica.fnk.php rename to dav/friendica/calendar.friendica.fnk.php index fff3447e..60dd9c6b 100644 --- a/dav/calendar.friendica.fnk.php +++ b/dav/friendica/calendar.friendica.fnk.php @@ -10,16 +10,21 @@ if (isset($uri["path"]) && strlen($uri["path"]) > 1) { define("CALDAV_SQL_DB", ""); define("CALDAV_SQL_PREFIX", "dav_"); define("CALDAV_URL_PREFIX", $path . "dav/"); +define("DAV_APPNAME", "Friendica"); define("CALDAV_NAMESPACE_PRIVATE", 1); - define("CALDAV_FRIENDICA_MINE", "friendica-mine"); define("CALDAV_FRIENDICA_CONTACTS", "friendica-contacts"); $GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"] = array(CALDAV_FRIENDICA_MINE, CALDAV_FRIENDICA_CONTACTS); +$GLOBALS["CALDAV_PRIVATE_SYSTEM_BACKENDS"] = array("Sabre_CalDAV_Backend_Friendica"); -define("CARDDAV_NAMESPACE_COMMUNITYCONTACTS", 1); -define("CARDDAV_NAMESPACE_PHONECONTACTS", 2); +define("CARDDAV_NAMESPACE_PRIVATE", 1); +define("CARDDAV_FRIENDICA_CONTACT", "friendica"); +$GLOBALS["CARDDAV_PRIVATE_SYSTEM_ADDRESSBOOKS"] = array(CARDDAV_FRIENDICA_CONTACT); +$GLOBALS["CARDDAV_PRIVATE_SYSTEM_BACKENDS"] = array("Sabre_CardDAV_Backend_Friendica"); + +$GLOBALS["CALDAV_ACL_PLUGIN_CLASS"] = "Sabre_DAVACL_Plugin_Friendica"; define("CALDAV_MAX_YEAR", date("Y") + 5); @@ -151,6 +156,14 @@ function dav_compat_get_max_private_calendars() return null; } +/** + * @return string + */ +function dav_compat_get_hostname() { + $a = get_app(); + return $a->get_hostname(); +} + /** * @param int $namespace * @param int $namespace_id @@ -218,3 +231,44 @@ function wdcal_create_std_calendars() $stms = wdcal_create_std_calendars_get_statements($a->user["uid"]); foreach ($stms as $stmt) q($stmt); } + + + + +/** + * @param int $user_id + * @param bool $withcheck + * @return array + */ +function wdcal_create_std_addressbooks_get_statements($user_id, $withcheck = true) +{ + $stms = array(); + $a = get_app(); + $uris = array( + 'private' => t("Private Addresses"), + CARDDAV_FRIENDICA_CONTACT => t("Friendica Contacts"), + ); + foreach ($uris as $uri => $name) { + $cals = q("SELECT * FROM %s%saddressbooks WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($uri)); + if (count($cals) == 0 || !$withcheck) $stms[] = + sprintf("INSERT INTO %s%saddressbooks (`namespace`, `namespace_id`, `displayname`, `ctag`, `uri`) + VALUES (%d, %d, '%s', 1, '%s')", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CARDDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($name), dbesc($uri)); + } + return $stms; +} + +/** + */ +function wdcal_create_std_addressbooks() +{ + $a = get_app(); + if (!local_user()) return; + + $privates = q("SELECT COUNT(*) num FROM %s%addressbooks WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CARDDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"])); + if ($privates[0]["num"] > 0) return; + + $stms = wdcal_create_std_addressbooks_get_statements($a->user["uid"]); + foreach ($stms as $stmt) q($stmt); +} diff --git a/dav/database-init.inc.php b/dav/friendica/database-init.inc.php similarity index 76% rename from dav/database-init.inc.php rename to dav/friendica/database-init.inc.php index 8cdd9b9b..f91ddb25 100644 --- a/dav/database-init.inc.php +++ b/dav/friendica/database-init.inc.php @@ -43,6 +43,36 @@ function dav_get_update_statements($from_version) } + if (in_array($from_version, array(1, 2))) { + $stms[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `namespace` mediumint(9) NOT NULL, + `namespace_id` int(11) unsigned NOT NULL, + `displayname` varchar(200) NOT NULL, + `description` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `needs_rebuild` TINYINT NOT NULL DEFAULT '1', + `uri` varchar(50) NOT NULL, + `ctag` int(11) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + + $stms[] = "CREATE TABLE IF NOT EXISTS `dav_addressbookobjects` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `addressbook_id` int(11) unsigned NOT NULL, + `contact` int(11) DEFAULT NULL, + `carddata` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci, + `uri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `lastmodified` timestamp NULL DEFAULT NULL, + `needs_rebuild` tinyint(4) NOT NULL DEFAULT '0', + `manually_deleted` tinyint(4) NOT NULL DEFAULT '0', + `etag` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `size` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `namespace` (`addressbook_id`,`contact`), + KEY `contact` (`contact`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + } + return $stms; } @@ -54,24 +84,6 @@ function dav_get_create_statements($except = array()) { $arr = array(); - if (!in_array("dav_addressbooks_community", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks_community` ( - `uid` int(11) NOT NULL, - `ctag` int(11) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`uid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8"; - - if (!in_array("dav_addressbooks_phone", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks_phone` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `uid` int(11) NOT NULL, - `principaluri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `displayname` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `uri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci, - `ctag` int(11) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - UNIQUE KEY `principaluri` (`principaluri`,`uri`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8"; - if (!in_array("dav_caldav_log", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_caldav_log` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` mediumint(9) NOT NULL, @@ -82,7 +94,7 @@ function dav_get_create_statements($except = array()) `url` varchar(100) NOT NULL, PRIMARY KEY (`id`), KEY `mitglied` (`uid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8"; +) ENGINE=InnoDB DEFAULT CHARSET=utf8"; if (!in_array("dav_calendarobjects", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_calendarobjects` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -98,7 +110,7 @@ function dav_get_create_statements($except = array()) PRIMARY KEY (`id`), UNIQUE KEY `uri` (`uri`), KEY `calendar_id` (`calendar_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8"; +) ENGINE=InnoDB DEFAULT CHARSET=utf8"; if (!in_array("dav_calendars", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_calendars` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -116,7 +128,7 @@ function dav_get_create_statements($except = array()) PRIMARY KEY (`id`), UNIQUE KEY (`namespace` , `namespace_id` , `uri`), KEY `uri` (`uri`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8"; +) ENGINE=InnoDB DEFAULT CHARSET=utf8"; if (!in_array("dav_cal_virtual_object_cache", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_cal_virtual_object_cache` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, @@ -135,7 +147,7 @@ function dav_get_create_statements($except = array()) PRIMARY KEY (`id`), KEY `data_uri` (`data_uri`), KEY `ref_type` (`calendar_id`,`data_end`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8"; +) ENGINE=InnoDB DEFAULT CHARSET=utf8"; if (!in_array("dav_cal_virtual_object_sync", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_cal_virtual_object_sync` ( `calendar_id` int(10) unsigned NOT NULL, @@ -143,23 +155,6 @@ function dav_get_create_statements($except = array()) PRIMARY KEY (`calendar_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8"; - if (!in_array("dav_cards", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_cards` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `namespace` tinyint(3) unsigned NOT NULL, - `namespace_id` int(11) unsigned NOT NULL, - `contact` int(11) DEFAULT NULL, - `carddata` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci, - `uri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `lastmodified` int(11) unsigned DEFAULT NULL, - `manually_edited` tinyint(4) NOT NULL DEFAULT '0', - `manually_deleted` tinyint(4) NOT NULL DEFAULT '0', - `etag` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `size` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `namespace` (`namespace`,`namespace_id`,`contact`), - KEY `contact` (`contact`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8"; - if (!in_array("dav_jqcalendar", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_jqcalendar` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ical_recurr_uri` varchar(100) DEFAULT NULL, @@ -190,6 +185,34 @@ function dav_get_create_statements($except = array()) KEY `calendar_id` (`calendar_id`,`calendarobject_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8"; + if (!in_array("dav_addressbooks", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `namespace` mediumint(9) NOT NULL, + `namespace_id` int(11) unsigned NOT NULL, + `displayname` varchar(200) NOT NULL, + `description` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `needs_rebuild` TINYINT NOT NULL DEFAULT '1', + `uri` varchar(50) NOT NULL, + `ctag` int(11) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + + if (!in_array("dav_addressbookobjects", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_addressbookobjects` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `addressbook_id` int(11) unsigned NOT NULL, + `contact` int(11) DEFAULT NULL, + `carddata` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci, + `uri` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, + `lastmodified` timestamp NULL DEFAULT NULL, + `needs_rebuild` tinyint(4) NOT NULL DEFAULT '0', + `manually_deleted` tinyint(4) NOT NULL DEFAULT '0', + `etag` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `size` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `namespace` (`addressbook_id`,`contact`), + KEY `contact` (`contact`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + return $arr; } @@ -201,7 +224,12 @@ function dav_check_tables() $x = q("DESCRIBE %s%scalendars", CALDAV_SQL_DB, CALDAV_SQL_PREFIX); if (!$x) return -1; if (count($x) == 9) return 1; // Version 0.1 + + $x2 = q("show tables like '%s%saddressbooks'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX); + if (!$x2 || count($x2) == 0) return 2; // Version 0.2 + if (count($x) == 12) return 0; // Correct + return -2; // Unknown version } @@ -215,7 +243,7 @@ function dav_create_tables() $errors = array(); global $db; - foreach ($stms as $st) { + foreach ($stms as $st) { // @TODO Friendica-dependent $db->q($st); if ($db->error) $errors[] = $db->error; } @@ -229,16 +257,15 @@ function dav_create_tables() function dav_upgrade_tables() { $ver = dav_check_tables(); - if (!in_array($ver, array(1) )) return array("Unknown error"); - + if (!in_array($ver, array(1, 2))) return array("Unknown error"); $stms = dav_get_update_statements($ver); - $errors = array(); + $errors = array(); global $db; - foreach ($stms as $st) { + foreach ($stms as $st) { // @TODO Friendica-dependent $db->q($st); if ($db->error) $errors[] = $db->error; } return $errors; -} \ No newline at end of file +} diff --git a/dav/dav_caldav_backend_virtual_friendica.inc.php b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php similarity index 96% rename from dav/dav_caldav_backend_virtual_friendica.inc.php rename to dav/friendica/dav_caldav_backend_virtual_friendica.inc.php index 9178aaab..0afc03bd 100644 --- a/dav/dav_caldav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php @@ -33,7 +33,7 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual * @return string */ public static function getBackendTypeName() { - return t("Friendicy-Native events"); + return t("Friendica-Native events"); } /** @@ -82,11 +82,11 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual $ts_end = wdcal_mySql2PhpTime($start); $allday = (strpos($start, "00:00:00") !== false && strpos($finish, "00:00:00") !== false); - $type = ($allday ? Sabre_VObject_Property_DateTime::DATE : Sabre_VObject_Property_DateTime::LOCALTZ); + $type = ($allday ? Sabre\VObject\Property\DateTime::DATE : Sabre\VObject\Property\DateTime::LOCALTZ); - $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART"); + $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type); - $datetime_end = new Sabre_VObject_Property_DateTime("DTEND"); + $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type); $component->add($datetime_start); diff --git a/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php b/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php new file mode 100644 index 00000000..3a06d042 --- /dev/null +++ b/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php @@ -0,0 +1,227 @@ + $books[0]["id"], + 'uri' => "friendica", + 'principaluri' => $principalUri, + '{DAV:}displayname' => t("Friendica-Contacts"), + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => t("Your Friendica-Contacts"), + '{http://calendarserver.org/ns/}getctag' => $ctag, + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => + new Sabre_CardDAV_Property_SupportedAddressData(), + ); + + return $addressBooks; + + } + + /** + * @static + * @param array $contact + * @return array + */ + private static function dav_contactarr2vcardsource($contact) + { + $name = explode(" ", $contact["name"]); + $first_name = $last_name = ""; + $middle_name = array(); + $num = count($name); + for ($i = 0; $i < $num && $first_name == ""; $i++) if ($name[$i] != "") { + $first_name = $name[$i]; + unset($name[$i]); + } + for ($i = $num - 1; $i >= 0 && $last_name == ""; $i--) if (isset($name[$i]) && $name[$i] != "") { + $last_name = $name[$i]; + unset($name[$i]); + } + foreach ($name as $n) if ($n != "") $middle_name[] = $n; + $vcarddata = new vcard_source_data($first_name, implode(" ", $middle_name), $last_name); + $vcarddata->homepages[] = new vcard_source_data_homepage("pref", $contact["url"]); + $vcarddata->last_update = ($contact["last-update"] > 0 ? $contact["last-update"] : $contact["created"]); + + $photo = q("SELECT * FROM photo WHERE `contact-id` = %d ORDER BY scale DESC", $contact["id"]); //prefer size 80x80 + if ($photo && count($photo) > 0) { + $photodata = new vcard_source_data_photo(); + $photodata->width = $photo[0]["width"]; + $photodata->height = $photo[0]["height"]; + $photodata->type = "JPEG"; + $photodata->binarydata = $photo[0]["data"]; + $vcarddata->photo = $photodata; + } + + switch ($contact["network"]) { + case "face": + $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("facebook", $contact["notify"], "http://www.facebook.com/" . $contact["notify"]); + break; + case "dfrn": + $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("dfrn", $contact["nick"], $contact["url"]); + break; + case "twitter": + $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("twitter", $contact["nick"], "http://twitter.com/" . $contact["nick"]); // @TODO Stimmt das? + break; + } + + $vcard = vcard_source_compile($vcarddata); + return array( + "id" => $contact["id"], + "carddata" => $vcard, + "uri" => $contact["id"] . ".vcf", + "lastmodified" => wdcal_mySql2PhpTime($vcarddata->last_update), + "etag" => md5($vcard), + "size" => strlen($vcard), + ); + + } + + /** + * @static + * @param int $addressbookId + * @param bool $force + * @throws Sabre_DAV_Exception_NotFound + */ + static protected function createCache_internal($addressbookId, $force = false) { + //$notin = (count($exclude_ids) > 0 ? " AND id NOT IN (" . implode(", ", $exclude_ids) . ") " : ""); + $addressbook = q("SELECT * FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId)); + if (count($addressbook) != 1 || $addressbook[0]["namespace"] != CARDDAV_NAMESPACE_PRIVATE) throw new Sabre_DAV_Exception_NotFound(); + $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY `name` ASC", $addressbook[0]["namespace_id"]); + + foreach ($contacts as $contact) { + $x = static::dav_contactarr2vcardsource($contact); + q("INSERT INTO %s%saddressbookobjects (`addressbook_id`, `contact`, `carddata`, `uri`, `lastmodified`, `etag`, `size`) VALUES (%d, %d, '%s', '%s', NOW(), '%s', %d)", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId, $contact["id"], dbesc($x["carddata"]), dbesc($x["uri"]), dbesc($x["etag"]), $x["size"] + ); + } + } + + + /** + * @static + * @param int $addressbookId + * @param int $contactId + * @param bool $force + * @throws Sabre_DAV_Exception_NotFound + */ + static protected function createCardCache($addressbookId, $contactId, $force = false) + { + $addressbook = q("SELECT * FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId)); + if (count($addressbook) != 1 || $addressbook[0]["namespace"] != CARDDAV_NAMESPACE_PRIVATE) throw new Sabre_DAV_Exception_NotFound(); + + $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 AND `id` = %d ORDER BY `name` ASC", + $addressbook[0]["namespace_id"], IntVal($contactId)); + $contact = $contacts[0]; + + $x = static::dav_contactarr2vcardsource($contact); + q("INSERT INTO %s%saddressbookobjects (`addressbook_id`, `contact`, `carddata`, `uri`, `lastmodified`, `etag`, `size`) VALUES (%d, %d, '%s', '%s', NOW(), '%s', %d)", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId, $contact["id"], dbesc($x["carddata"]), dbesc($x["uri"]), dbesc($x["etag"]), $x["size"] + ); + } + /** + * Updates a card. + * + * The addressbook id will be passed as the first argument. This is the + * same id as it is returned from the getAddressbooksForUser method. + * + * The cardUri is a base uri, and doesn't include the full path. The + * cardData argument is the vcard body, and is passed as a string. + * + * It is possible to return an ETag from this method. This ETag should + * match that of the updated resource, and must be enclosed with double + * quotes (that is: the string itself must contain the actual quotes). + * + * You should only return the ETag if you store the carddata as-is. If a + * subsequent GET request on the same card does not have the same body, + * byte-by-byte and you did return an ETag here, clients tend to get + * confused. + * + * If you don't return an ETag, you can just return null. + * + * @param string $addressBookId + * @param string $cardUri + * @param string $cardData + * @throws Sabre_DAV_Exception_Forbidden + * @return string|null + */ + public function updateCard($addressBookId, $cardUri, $cardData) + { + $x = explode("-", $addressBookId); + + $etag = md5($cardData); + q("UPDATE %s%scards SET carddata = '%s', lastmodified = %d, etag = '%s', size = %d, manually_edited = 1 WHERE uri = '%s' AND namespace = %d AND namespace_id =%d", + CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), time(), $etag, strlen($cardData), dbesc($cardUri), IntVal($x[10]), IntVal($x[1]) + ); + q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); + + return '"' . $etag . '"'; + } + + /** + * Deletes a card + * + * @param string $addressBookId + * @param string $cardUri + * @throws Sabre_DAV_Exception_Forbidden + * @return bool + */ + public function deleteCard($addressBookId, $cardUri) + { + $x = explode("-", $addressBookId); + + q("UPDATE %s%scards SET manually_deleted = 1 WHERE namespace = %d AND namespace_id = %d AND uri = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($cardUri)); + q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); + + return true; + } + +} diff --git a/dav/dav_friendica_auth.inc.php b/dav/friendica/dav_friendica_auth.inc.php similarity index 100% rename from dav/dav_friendica_auth.inc.php rename to dav/friendica/dav_friendica_auth.inc.php diff --git a/dav/dav_friendica_principal.inc.php b/dav/friendica/dav_friendica_principal.inc.php similarity index 100% rename from dav/dav_friendica_principal.inc.php rename to dav/friendica/dav_friendica_principal.inc.php diff --git a/dav/layout.fnk.php b/dav/friendica/layout.fnk.php similarity index 98% rename from dav/layout.fnk.php rename to dav/friendica/layout.fnk.php index 597e773d..80a9ae2d 100644 --- a/dav/layout.fnk.php +++ b/dav/friendica/layout.fnk.php @@ -17,7 +17,7 @@ function wdcal_addRequiredHeaders() $a->page['htmlhead'] .= '' . "\r\n"; $a->page['htmlhead'] .= '' . "\r\n"; - $a->page['htmlhead'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\r\n"; $a->page['htmlhead'] .= '' . "\r\n"; $a->page['htmlhead'] .= '' . "\r\n"; @@ -86,12 +86,12 @@ function wdcal_import_user_ics($calendar_id) { if ($_FILES["ics_file"]["tmp_name"] != "" && is_uploaded_file($_FILES["ics_file"]["tmp_name"])) try { $text = file_get_contents($_FILES["ics_file"]["tmp_name"]); - /** @var Sabre_VObject_Component_VCalendar $vObject */ - $vObject = Sabre_VObject_Reader::read($text); + /** @var Sabre\VObject\Component\VCalendar $vObject */ + $vObject = Sabre\VObject\Reader::read($text); $comp = $vObject->getComponents(); $imported = array(); foreach ($comp as $c) try { - /** @var Sabre_VObject_Component_VEvent $c */ + /** @var Sabre\VObject\Component\VEvent $c */ $uid = $c->__get("UID")->value; if (!isset($imported[$uid])) $imported[$uid] = ""; $imported[$uid] .= $c->serialize(); diff --git a/dav/main.php b/dav/friendica/main.php similarity index 76% rename from dav/main.php rename to dav/friendica/main.php index 03f342bd..0fe939eb 100644 --- a/dav/main.php +++ b/dav/friendica/main.php @@ -26,21 +26,48 @@ function dav_module() function dav_include_files() { - require_once (__DIR__ . "/SabreDAV/lib/Sabre/autoload.php"); + require_once (__DIR__ . "/../SabreDAV/lib/Sabre/autoload.php"); - require_once (__DIR__ . "/common/calendar.fnk.php"); - require_once (__DIR__ . "/common/calendar_rendering.fnk.php"); - require_once (__DIR__ . "/common/dav_caldav_backend_common.inc.php"); - require_once (__DIR__ . "/common/dav_caldav_backend_private.inc.php"); - require_once (__DIR__ . "/common/dav_caldav_backend_virtual.inc.php"); - require_once (__DIR__ . "/common/dav_caldav_root.inc.php"); - require_once (__DIR__ . "/common/dav_user_calendars.inc.php"); - require_once (__DIR__ . "/common/dav_carddav_root.inc.php"); - require_once (__DIR__ . "/common/dav_carddav_backend_std.inc.php"); - require_once (__DIR__ . "/common/dav_user_addressbooks.inc.php"); - require_once (__DIR__ . "/common/dav_caldav_calendar_virtual.inc.php"); - require_once (__DIR__ . "/common/wdcal_configuration.php"); - require_once (__DIR__ . "/common/wdcal_backend.inc.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Node.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Element.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/DateTimeParser.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/ElementList.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Parameter.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/ParseException.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Property.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Reader.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Version.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Property/DateTime.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VEvent.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VJournal.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VTodo.php"); + + require_once (__DIR__ . "/../common/calendar.fnk.php"); + require_once (__DIR__ . "/../common/calendar_rendering.fnk.php"); + + require_once (__DIR__ . "/../common/dav_caldav_backend_common.inc.php"); + require_once (__DIR__ . "/../common/dav_caldav_backend_private.inc.php"); + require_once (__DIR__ . "/../common/dav_caldav_backend_virtual.inc.php"); + require_once (__DIR__ . "/../common/dav_caldav_root.inc.php"); + require_once (__DIR__ . "/../common/dav_user_calendars.inc.php"); + require_once (__DIR__ . "/../common/dav_caldav_calendar_virtual.inc.php"); + require_once (__DIR__ . "/../common/dav_caldav_calendar_private.inc.php"); + + require_once (__DIR__ . "/../common/dav_carddav_root.inc.php"); + require_once (__DIR__ . "/../common/dav_carddav_backend_common.inc.php"); + require_once (__DIR__ . "/../common/dav_carddav_backend_virtual.inc.php"); + require_once (__DIR__ . "/../common/dav_carddav_backend_private.inc.php"); + require_once (__DIR__ . "/../common/dav_user_addressbooks.inc.php"); + + require_once (__DIR__ . "/../common/wdcal_configuration.php"); + require_once (__DIR__ . "/../common/wdcal_backend.inc.php"); require_once (__DIR__ . "/dav_friendica_principal.inc.php"); require_once (__DIR__ . "/dav_friendica_auth.inc.php"); @@ -48,7 +75,7 @@ function dav_include_files() require_once (__DIR__ . "/dav_caldav_backend_virtual_friendica.inc.php"); require_once (__DIR__ . "/FriendicaACLPlugin.inc.php"); - require_once (__DIR__ . "/common/wdcal_edit.inc.php"); + require_once (__DIR__ . "/../common/wdcal_edit.inc.php"); require_once (__DIR__ . "/calendar.friendica.fnk.php"); require_once (__DIR__ . "/layout.fnk.php"); } @@ -65,6 +92,9 @@ function dav_init(&$a) * ALTER TABLE `photo` ADD INDEX ( `contact-id` ) */ + ini_set("display_errors", 1); + error_reporting(E_ALL); + dav_include_files(); if (false) { @@ -74,6 +104,7 @@ function dav_init(&$a) } wdcal_create_std_calendars(); + wdcal_create_std_addressbooks(); wdcal_addRequiredHeaders(); if ($a->argc >= 2 && $a->argv[1] == "wdcal") { @@ -99,9 +130,11 @@ function dav_init(&$a) } - $server = dav_create_server(); + $server = dav_create_server(); + $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); + $server->exec(); killme(); @@ -281,8 +314,7 @@ function dav_plugin_admin_post(&$a = null, &$o = null) if (count($errs) == 0) { renderAllCalDavEntries(); info(t('The database tables have been updated.') . EOL); - } - else notice(t("An error occurred during the update.") . EOL); + } else notice(t("An error occurred during the update.") . EOL); } } @@ -307,6 +339,7 @@ function dav_plugin_admin(&$a, &$o) $o .= t('Installed'); break; case 1: + case 2: $o .= "" . t('Upgrade needed') . "
" . t("Please back up all calendar data (the tables beginning with dav_*) before proceeding. While all calendar events should be converted to the new database structure, it's always safe to have a backup. Below, you can have a look at the database-queries that will be made when pressing the 'update'-button.") . "

"; break; case -1: @@ -323,8 +356,8 @@ function dav_plugin_admin(&$a, &$o) $o .= "

" . t("Manual creation of the database tables:") . "

"; $o .= "" . t("Show SQL-statements") . "