1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-30 19:52:17 +01:00

Add GET route to single contact.

This commit is contained in:
Thomas Tanghus 2013-05-09 05:58:28 +02:00
parent 980a0dbdf1
commit b8b9c5dc91
2 changed files with 38 additions and 0 deletions

View File

@ -167,6 +167,16 @@ $this->create('contacts_contact_save_property', 'addressbook/{backend}/{addressb
)
->requirements(array('backend', 'addressbook', 'contactid'));
$this->create('contacts_contact_get', 'addressbook/{backend}/{addressbookid}/contact/{contactid}/')
->get()
->action(
function($params) {
session_write_close();
Main::main('ContactController', 'getContact', $params, new DIContainer());
}
)
->requirements(array('backend', 'addressbook', 'contactid'));
// Save all properties. Used for merging contacts.
$this->create('contacts_contact_save_all', 'addressbook/{backend}/{addressbookid}/contact/{contactid}/save')
->post()

View File

@ -24,6 +24,34 @@ use OCA\AppFramework\Core\API;
*/
class ContactController extends BaseController {
/**
* @IsAdminExemption
* @IsSubAdminExemption
* @Ajax
*/
public function getContact() {
$app = new App($this->api->getUserId());
$request = $this->request;
$response = new JSONResponse();
$contact = $app->getContact(
$request->parameters['backend'],
$request->parameters['addressbookid'],
$request->parameters['contactid']
);
if(!$contact) {
$response->bailOut(App::$l10n->t('Couldn\'t find contact.'));
}
$data = JSONSerializer::serializeContact($contact);
$response->setParams($data);
return $response;
}
/**
* @IsAdminExemption
* @IsSubAdminExemption