summaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-06-25 22:51:42 +0200
committerBart Visscher <bartv@thisnet.nl>2012-06-27 01:05:36 +0200
commitb9e1033563b534faa75b0e0562f441b4eaf83a7d (patch)
tree4bcb1dcc70f70fef8370b5d32682a40810ffa243 /apps/contacts
parentd332e1e9c1b4289f8ecd927047e6d16234013908 (diff)
downloadnextcloud-server-b9e1033563b534faa75b0e0562f441b4eaf83a7d.tar.gz
nextcloud-server-b9e1033563b534faa75b0e0562f441b4eaf83a7d.zip
Basic framework for contacts sharing
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/appinfo/app.php2
-rw-r--r--apps/contacts/lib/share.php54
2 files changed, 56 insertions, 0 deletions
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index 64fe00eef10..f27db13ca75 100644
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -3,6 +3,7 @@ OC::$CLASSPATH['OC_Contacts_App'] = 'apps/contacts/lib/app.php';
OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php';
OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php';
+OC::$CLASSPATH['OC_Contacts_Share'] = 'apps/contacts/lib/share.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php';
OC::$CLASSPATH['OC_Search_Provider_Contacts'] = 'apps/contacts/lib/search.php';
OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Contacts_Hooks', 'createUser');
@@ -21,3 +22,4 @@ OCP\App::addNavigationEntry( array(
OCP\App::registerPersonal('contacts','settings');
OCP\Util::addscript('contacts', 'loader');
OC_Search::registerProvider('OC_Search_Provider_Contacts');
+OCP\Share::registerBackend('addressbook', new OC_Contacts_Share());
diff --git a/apps/contacts/lib/share.php b/apps/contacts/lib/share.php
new file mode 100644
index 00000000000..d304042edd3
--- /dev/null
+++ b/apps/contacts/lib/share.php
@@ -0,0 +1,54 @@
+<?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_Contacts_Share extends OCP\Share_Backend {
+ /**
+ * @brief Get the source of the item to be stored in the database
+ * @param string Item
+ * @param string Owner of the item
+ * @return mixed|array|false Source
+ *
+ * Return an array if the item is file dependent, the array needs two keys: 'item' and 'file'
+ * Return false if the item does not exist for the user
+ *
+ * The formatItems() function will translate the source returned back into the item
+ */
+ public function getSource($item, $uid) {
+ $addressbook = OC_Contacts_Addressbook::find( $item );
+ if( $addressbook === false || $addressbook['userid'] != $uid) {
+ return false;
+ }
+ return $item;
+ }
+
+ /**
+ * @brief Get a unique name of the item for the specified user
+ * @param string Item
+ * @param string|false User the item is being shared with
+ * @param array|null List of similar item names already existing as shared items
+ * @return string Target name
+ *
+ * This function needs to verify that the user does not already have an item with this name.
+ * If it does generate a new name e.g. name_#
+ */
+ public function generateTarget($item, $uid, $exclude = null) {
+ }
+
+ /**
+ * @brief Converts the shared item sources back into the item in the specified format
+ * @param array Sources of shared items
+ * @param int Format
+ * @return ?
+ *
+ * The items array is formatted with the sources as the keys to an array with the following keys: item_target, permissions, stime
+ * This function allows the backend to control the output of shared items with custom formats.
+ * It is only called through calls to the public getItem(s)SharedWith functions.
+ */
+ public function formatItems($items, $format) {
+ }
+}