mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-11-29 11:24:11 +01:00
Merge pull request #621 from jakobsack/master
Move creation of default address book to backend
This commit is contained in:
commit
95bd2ff182
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[$id] = $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