mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Contacts: Add PoC ajax listing
This commit is contained in:
parent
15c3805127
commit
304a53b8f4
38
ajax/addressbook/list.php
Normal file
38
ajax/addressbook/list.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OCA\Contacts;
|
||||
|
||||
// Check if we are a user
|
||||
\OCP\JSON::checkLoggedIn();
|
||||
\OCP\JSON::checkAppEnabled('contacts');
|
||||
require_once __DIR__.'/../loghandler.php';
|
||||
|
||||
$app = new App();
|
||||
|
||||
$addressBooks = $app->getAllAddressBooksForUser();
|
||||
$addressBooksMetaData = array();
|
||||
$contacts = array();
|
||||
|
||||
foreach($addressBooks as $addressBook) {
|
||||
$addressBooksMetaData[] = $addressBook->getMetaData();
|
||||
foreach($addressBook->getChildren() as $contact) {
|
||||
$response = Utils\JSONSerializer::serializeContact($contact);
|
||||
if($response !== null) {
|
||||
$contacts[] = $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\OCP\JSON::success(array(
|
||||
'data' => array(
|
||||
'addressbooks' => $addressBooksMetaData,
|
||||
'contacts' => $contacts, //Utils\JSONSerializer::serialize($contacts),
|
||||
'is_indexed' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'contacts_indexed', 'no') === 'yes'
|
||||
)
|
||||
));
|
Loading…
x
Reference in New Issue
Block a user