mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-12-01 13:24:10 +01:00
Move creation of default address book to backend
Fixes owncloud/contacts#513
This commit is contained in:
parent
dc33a738e9
commit
026fb01af3
14
lib/app.php
14
lib/app.php
@ -105,20 +105,6 @@ class App {
|
||||
foreach (array_keys(self::$backendClasses) as $backendName) {
|
||||
$backend = self::getBackend($backendName, $this->user);
|
||||
$addressBooks = $backend->getAddressBooksForUser();
|
||||
if ($backendName === 'local' && count($addressBooks) === 0) {
|
||||
$id = $backend->createAddressBook(array('displayname' => self::$l10n->t('Contacts')));
|
||||
if ($id !== false) {
|
||||
$addressBook = $backend->getAddressBook($id);
|
||||
$addressBooks = array($addressBook);
|
||||
} else {
|
||||
\OCP\Util::writeLog(
|
||||
'contacts',
|
||||
__METHOD__ . ', Error creating default address book',
|
||||
\OCP\Util::ERROR
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($addressBooks as $addressBook) {
|
||||
$addressBook['backend'] = $backendName;
|
||||
|
@ -117,6 +117,22 @@ class Database extends AbstractBackend {
|
||||
$this->addressBooks[$row['id']] = $row;
|
||||
}
|
||||
|
||||
// Create default address book if the list is empty
|
||||
if (count($this->addressBooks) === 0) {
|
||||
$l10n = \OCP\Util::getL10N('contacts');
|
||||
$id = $this->createAddressBook(array('displayname' => $l10n->t('Contacts')));
|
||||
if ($id !== false) {
|
||||
$addressBook = $this->getAddressBook($id);
|
||||
$this->addressBooks = array($addressBook);
|
||||
} else {
|
||||
\OCP\Util::writeLog(
|
||||
'contacts',
|
||||
__METHOD__ . ', Error creating default address book',
|
||||
\OCP\Util::ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addressBooks;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user