2012-03-07 16:39:56 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2012-09-07 14:32:45 +02:00
|
|
|
|
2012-05-03 12:23:29 +02:00
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::checkAppEnabled('contacts');
|
2012-03-07 16:39:56 +01:00
|
|
|
|
2012-10-25 03:34:12 +02:00
|
|
|
$catmgr = OCA\Contacts\App::getVCategories();
|
2012-09-17 16:15:31 +02:00
|
|
|
$categories = $catmgr->categories(OC_VCategories::FORMAT_MAP);
|
|
|
|
foreach($categories as &$category) {
|
|
|
|
$ids = array();
|
|
|
|
$contacts = $catmgr->itemsForCategory(
|
2012-10-22 15:35:33 +02:00
|
|
|
$category['name'],
|
2012-09-17 16:15:31 +02:00
|
|
|
array(
|
|
|
|
'tablename' => '*PREFIX*contacts_cards',
|
|
|
|
'fields' => array('id',),
|
|
|
|
));
|
|
|
|
foreach($contacts as $contact) {
|
|
|
|
$ids[] = $contact['id'];
|
|
|
|
}
|
|
|
|
$category['contacts'] = $ids;
|
|
|
|
}
|
2012-03-07 16:39:56 +01:00
|
|
|
|
2012-10-22 15:35:33 +02:00
|
|
|
$favorites = $catmgr->getFavorites();
|
|
|
|
|
|
|
|
OCP\JSON::success(array(
|
|
|
|
'data' => array(
|
|
|
|
'categories' => $categories,
|
|
|
|
'favorites' => $favorites,
|
2012-10-25 03:34:12 +02:00
|
|
|
'shared' => OCP\Share::getItemsSharedWith('addressbook', OCA\Contacts\Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS),
|
2012-10-23 10:55:18 +02:00
|
|
|
'lastgroup' => OCP\Config::getUserValue(
|
|
|
|
OCP\User::getUser(),
|
|
|
|
'contacts',
|
|
|
|
'lastgroup', 'all'),
|
2012-10-22 15:35:33 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|