From 0374ded776d370d2d8a62fca09b622c394033539 Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 9 Apr 2021 17:06:17 +0200 Subject: [PATCH] Cleanup Contacts/AddressBook PDO settings --- dev/Settings/Admin/Contacts.js | 4 +--- snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php | 9 ++++----- .../0.0.0/app/libraries/RainLoop/Config/Application.php | 2 +- .../app/templates/Views/Admin/AdminSettingsContacts.html | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dev/Settings/Admin/Contacts.js b/dev/Settings/Admin/Contacts.js index 7e0fe8a83..9bcd91f56 100644 --- a/dev/Settings/Admin/Contacts.js +++ b/dev/Settings/Admin/Contacts.js @@ -19,7 +19,7 @@ export class ContactsAdminSettings { addObservablesTo(this, { enableContacts: !!SettingsGet('ContactsEnable'), contactsSync: !!SettingsGet('ContactsSync'), - contactsType: '', + contactsType: SettingsGet('ContactsPdoType'), pdoDsn: SettingsGet('ContactsPdoDsn'), pdoUser: SettingsGet('ContactsPdoUser'), @@ -69,8 +69,6 @@ export class ContactsAdminSettings { }) .extend({ notify: 'always' }); - this.contactsType(SettingsGet('ContactsPdoType')); - addSubscribablesTo(this, { enableContacts: value => Remote.saveAdminConfig(null, { diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index e98915c60..68fb6e671 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -265,18 +265,17 @@ class Actions break; case 'address-book': // Providers\AddressBook\AddressBookInterface - $sDsn = \trim($this->Config()->Get('contacts', 'pdo_dsn', '')); $sUser = \trim($this->Config()->Get('contacts', 'pdo_user', '')); $sPassword = (string)$this->Config()->Get('contacts', 'pdo_password', ''); - $sDsnType = $this->ValidateContactPdoType(\trim($this->Config()->Get('contacts', 'type', 'sqlite'))); if ('sqlite' === $sDsnType) { - $mResult = new Providers\AddressBook\PdoAddressBook( - 'sqlite:' . APP_PRIVATE_DATA . 'AddressBook.sqlite', '', '', 'sqlite'); + $sUser = $sPassword = ''; + $sDsn = 'sqlite:' . APP_PRIVATE_DATA . 'AddressBook.sqlite'; } else { - $mResult = new Providers\AddressBook\PdoAddressBook($sDsn, $sUser, $sPassword, $sDsnType); + $sDsn = $sDsnType . ':' . \preg_replace('/^[a-z]+:/', '', $sDsn); } + $mResult = new Providers\AddressBook\PdoAddressBook($sDsn, $sUser, $sPassword, $sDsnType); break; case 'identities': $mResult = []; diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 962d296ef..d89da53a3 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -141,7 +141,7 @@ class Application extends \RainLoop\Config\AbstractConfig 'allow_sync' => array(false), 'sync_interval' => array(20), 'type' => array('sqlite', ''), - 'pdo_dsn' => array('mysql:host=127.0.0.1;port=3306;dbname=rainloop', ''), + 'pdo_dsn' => array('host=127.0.0.1;port=3306;dbname=snappymail', ''), 'pdo_user' => array('root', ''), 'pdo_password' => array('', ''), 'suggestions_limit' => array(30) diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html index 507062b36..73b6c5d87 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html @@ -47,8 +47,8 @@ data-bind="value: pdoDsn, saveTrigger: pdoDsnTrigger" />

-mysql:host=127.0.0.1;port=3306;dbname=rainloop
-pgsql:host=127.0.0.1;port=5432;dbname=rainloop +host=127.0.0.1;port=3306;dbname=snappymail
+host=127.0.0.1;port=5432;dbname=snappymail