aboutsummaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-03 15:05:45 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-03 15:05:45 -0400
commit09bb3bfaf8bbc276ff23a2882d5591be542c0139 (patch)
tree69d9e9d759ffe40c65d327cb638bdeab89ff17d3 /apps/contacts
parent6c7baacf8959e32c6702b68357bc85b286c67940 (diff)
downloadnextcloud-server-09bb3bfaf8bbc276ff23a2882d5591be542c0139.tar.gz
nextcloud-server-09bb3bfaf8bbc276ff23a2882d5591be542c0139.zip
Preparing for proper collection implementation
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/appinfo/app.php7
-rw-r--r--apps/contacts/lib/addressbook.php2
-rw-r--r--apps/contacts/lib/share.php77
3 files changed, 6 insertions, 80 deletions
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index 74660a2e2b8..aa0f229dd9f 100644
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -3,7 +3,8 @@ 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_Share_Contact_Backend'] = 'apps/contacts/lib/share/contact.php';
+OC::$CLASSPATH['OC_Share_Addressbook_Backend'] = 'apps/contacts/lib/share/addressbook.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php';
OC::$CLASSPATH['Sabre_CardDAV_VCFExportPlugin'] = 'apps/contacts/lib/VCFExportPlugin.php';
OC::$CLASSPATH['OC_Search_Provider_Contacts'] = 'apps/contacts/lib/search.php';
@@ -23,4 +24,6 @@ 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', 'OC_Contacts_Share');
+OCP\Share::registerBackend('contact', 'OC_Share_Contact_Backend');
+OCP\Share::registerBackend('addressbook', 'OC_Share_Addressbook_Backend', 'contact');
+
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 6e082c5e2e9..d3cceb58807 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -64,7 +64,7 @@ class OC_Contacts_Addressbook {
while( $row = $result->fetchRow()) {
$addressbooks[] = $row;
}
- $addressbooks = array_merge($addressbooks, OCP\Share::getItemsSharedWith('addressbook', OC_Contacts_Share::FORMAT_ADDRESSBOOKS));
+ $addressbooks = array_merge($addressbooks, OCP\Share::getItemsSharedWith('addressbook', OC_Share_Addressbook_Backend::FORMAT_ADDRESSBOOKS));
if(!$active && !count($addressbooks)) {
self::addDefault($uid);
}
diff --git a/apps/contacts/lib/share.php b/apps/contacts/lib/share.php
deleted file mode 100644
index 7aec5339577..00000000000
--- a/apps/contacts/lib/share.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?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 {
- const FORMAT_ADDRESSBOOKS = 1;
- /**
- * @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) {
- $addressbook = OC_Contacts_Addressbook::find( $item );
- $user_addressbooks = array();
- foreach(OC_Contacts_Addressbook::all($uid) as $user_addressbook) {
- $user_addressbooks[] = $user_addressbook['displayname'];
- }
- $name = $addressbook['userid']."'s ".$addressbook['displayname'];
- $suffix = '';
- while (in_array($name.$suffix, $user_addressbooks)) {
- $suffix++;
- }
-
- return $name.$suffix;
- }
-
- /**
- * @brief Converts the shared item sources back into the item in the specified format
- * @param array Shared items
- * @param int Format
- * @return ?
- *
- * The items array is a 3-dimensional array with the item_source as the first key and the share id as the second key to an array with the share info.
- * The key/value pairs included in the share info depend on the function originally called:
- * If called by getItem(s)Shared: id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source
- * If called by getItem(s)SharedWith: id, item_type, item, item_source, item_target, share_type, share_with, permissions, stime, file_source, file_target
- * 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)Shared(With) functions.
- */
- public function formatItems($items, $format, $parameters = null) {
- $addressbooks = array();
- foreach ($items as $item) {
- $addressbook = OC_Contacts_Addressbook::find($item['item_source']);
- $addressbook['displayname'] = $item['item_target'];
- $addressbooks[] = $addressbook;
- }
- return $addressbooks;
- }
-}