summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-08-07 23:27:06 +0200
committerBart Visscher <bartv@thisnet.nl>2012-08-07 23:27:06 +0200
commit1e644b5a53856b2b4e2310e96ce6155fe32982d9 (patch)
tree1505e9c7c54015e7d1e091489a4699818dfdbb96 /apps
parentb287b11ff239bdb11672afbb10a5dcd5ab85a86e (diff)
downloadnextcloud-server-1e644b5a53856b2b4e2310e96ce6155fe32982d9.tar.gz
nextcloud-server-1e644b5a53856b2b4e2310e96ce6155fe32982d9.zip
Add Event share backend
Diffstat (limited to 'apps')
-rw-r--r--apps/calendar/appinfo/app.php2
-rw-r--r--apps/calendar/lib/share/event.php40
2 files changed, 42 insertions, 0 deletions
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 8a793d1fac2..72ddde60152 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -11,6 +11,7 @@ OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php';
OC::$CLASSPATH['OC_Calendar_Export'] = 'apps/calendar/lib/export.php';
OC::$CLASSPATH['OC_Calendar_Import'] = 'apps/calendar/lib/import.php';
OC::$CLASSPATH['OC_Share_Backend_Calendar'] = 'apps/calendar/lib/share/calendar.php';
+OC::$CLASSPATH['OC_Share_Backend_Event'] = 'apps/calendar/lib/share/event.php';
//General Hooks
OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'createUser');
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
@@ -37,3 +38,4 @@ OCP\App::addNavigationEntry( array(
OCP\App::registerPersonal('calendar', 'settings');
OC_Search::registerProvider('OC_Search_Provider_Calendar');
OCP\Share::registerBackend('calendar', 'OC_Share_Backend_Calendar');
+OCP\Share::registerBackend('event', 'OC_Share_Backend_Event');
diff --git a/apps/calendar/lib/share/event.php b/apps/calendar/lib/share/event.php
new file mode 100644
index 00000000000..5bb72ee6c98
--- /dev/null
+++ b/apps/calendar/lib/share/event.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class OC_Share_Backend_Event implements OCP\Share_Backend {
+
+ const FORMAT_EVENT = 0;
+
+ private static $event;
+
+ public function isValidSource($itemSource, $uidOwner) {
+ self::$event = OC_Calendar_Object::find($itemSource);
+ if (self::$event) {
+ return true;
+ }
+ return false;
+ }
+
+ public function generateTarget($itemSource, $shareWith, $exclude = null) {
+ // TODO Get default calendar and check for conflicts
+ return self::$event['summary'];
+ }
+
+ public function formatItems($items, $format, $parameters = null) {
+ $events = array();
+ if ($format == self::FORMAT_EVENT) {
+ foreach ($items as $item) {
+ $event = OC_Calendar_Object::find($item['item_source']);
+ $event['summary'] = $item['item_target'];
+ $events[] = $event;
+ }
+ }
+ return $events;
+ }
+
+}