Hello, I am a french student in trainee at an association, and I must create and manage a Nextcloud server.
My clients want I create a Nextcloud application for get contacts store in Nextcloud, send them in a Laurux Database, and they want that we can add a contact in a “show” and filter the contacts by show.
For example if I am a show named : “FunShow”, we would like add a contact in this show.
For the moment the app look like this (Sorry it’s in french) :
I would like find how get a specific contact (with UID for example), edit this and save this in Nextcloud.
For the moment I use IManager for that but, it don’t save correctly in Nextcloud, here I want say, the profil picture of contact are delete and several information are bad formated.
Ok, now I understand. You want to access the Nextcloud contacts database with a self programmed application. Due to the fact that Nextcloud relies on Sabre/dav, you’re most likely already aware of the Nextcloud developer guide, aren’t you?
The Nextcloud developer guid purpose to use IManager but it not it not really useful here, because the only function for get contact is “search()” but this function it’s not reliable.
Your github link it’s maybe the solution but, I don’t understand the line :
/**
* @NoAdminRequired
*
* Gets the addressbook of an addressbookId
*
* @param {String} addressbookId the identifier of the addressbook
*
* @returns {IAddressBook} the corresponding addressbook or null
*/
protected function getAddressBook(string $addressbookId) : ?IAddressBook {
$addressBook = null;
$addressBooks = $this->manager->getUserAddressBooks();
foreach($addressBooks as $ab) {
if ($ab->getUri() === $addressbookId) {
$addressBook = $ab;
}
}
return $addressBook;
}
…
try {
// get corresponding addressbook
$addressBook = $this->getAddressBook($addressbookId);
if (is_null($addressBook)) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
}
// search contact in that addressbook, get social data
$contact = $addressBook->search($contactId, ['UID'], ['types' => true])[0];
Hello,
I don’t undestand how you have keep all data of photo of contact…
Because the problem, is the profile picture of contact are destroy after update