1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-02 14:24:10 +01:00

Change getItems() return to a 3-dimensional array to handle multiple shares of the same item

This commit is contained in:
Michael Gapczynski 2012-07-02 15:29:34 -04:00
parent 9214c97dd7
commit 9fc953d447

View File

@ -54,19 +54,24 @@ class OC_Contacts_Share extends OCP\Share_Backend {
/** /**
* @brief Converts the shared item sources back into the item in the specified format * @brief Converts the shared item sources back into the item in the specified format
* @param array Sources of shared items * @param array Shared items
* @param int Format * @param int Format
* @return ? * @return ?
* *
* The items array is formatted with the sources as the keys to an array with the following keys: item_target, permissions, stime * 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. * 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. * It is only called through calls to the public getItem(s)Shared(With) functions.
*/ */
public function formatItems($items, $format) { public function formatItems($items, $format) {
$addressbooks = array(); $addressbooks = array();
foreach($items as $source => $info) { foreach ($items as $source => $shares) {
$addressbook = OC_Contacts_Addressbook::find( $source ); $addressbook = OC_Contacts_Addressbook::find( $source );
$addressbook['displayname'] = $info['item_target']; foreach ($shares as $info) {
$addressbook['displayname'] = $info['item_target'];
}
$addressbooks[] = $addressbook; $addressbooks[] = $addressbook;
} }
return $addressbooks; return $addressbooks;