From 8f2316695518e1e7925cab219737bc81d2a0668b Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Tue, 28 Oct 2014 22:54:09 +0100 Subject: [PATCH] Display correct number of contacts in shared addressbooks. Fixes #654. --- js/groups.js | 2 +- lib/controller/groupcontroller.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/groups.js b/js/groups.js index 6f221b92..9b09df62 100644 --- a/js/groups.js +++ b/js/groups.js @@ -751,7 +751,7 @@ OC.Contacts = OC.Contacts || {}; $elem = $elem.length ? $elem : (tmpl).octemplate({ id: shared.id, type: 'shared', - num: response.data.shared.length, + num: shared.length, name: shared.displayname }); $elem.find('.numcontacts').after(sharedindicator); diff --git a/lib/controller/groupcontroller.php b/lib/controller/groupcontroller.php index f3d4678e..c3257e8d 100644 --- a/lib/controller/groupcontroller.php +++ b/lib/controller/groupcontroller.php @@ -45,10 +45,17 @@ class GroupController extends Controller { $favorites = $this->tags->getFavorites(); + $shares = \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS); + $addressbookShare = new \OCA\Contacts\Share\Addressbook(); + foreach ($shares as $key => $share) { + $children = $addressbookShare->getChildren($share['id']); // FIXME: This should be cheaper! + $shares[$key]['length'] = count($children); + } + $groups = array( 'categories' => $tags, 'favorites' => $favorites, - 'shared' => \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS), + 'shared' => $shares, 'lastgroup' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'lastgroup', 'all'), 'sortorder' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'groupsort', ''), );