Added feature to use the SQLite AddressBook per login account instead of global.

On by default unless the global AddressBook.sqlite already exists.
This commit is contained in:
the-djmaze 2024-01-17 00:55:23 +01:00
parent b89a1b309c
commit 2d829178f8
33 changed files with 57 additions and 22 deletions

View file

@ -28,6 +28,8 @@ export class AdminSettingsContacts extends AbstractViewSettings {
this.addSetting('contactsMySQLSSLVerify');
this.addSetting('contactsMySQLSSLCiphers');
this.addSetting('contactsSQLiteGlobal');
addObservablesTo(this, {
testing: false,
testContactsSuccess: false,
@ -102,7 +104,8 @@ export class AdminSettingsContacts extends AbstractViewSettings {
PdoPassword: this.contactsPdoPassword(),
MySQLSSLCA: this.contactsMySQLSSLCA(),
MySQLSSLVerify: this.contactsMySQLSSLVerify(),
MySQLSSLCiphers: this.contactsMySQLSSLCiphers()
MySQLSSLCiphers: this.contactsMySQLSSLCiphers(),
SQLiteGlobal: this.contactsSQLiteGlobal()
}
);
}

View file

@ -649,6 +649,7 @@ class Actions
$aResult['contactsMySQLSSLCA'] = (string) $oConfig->Get('contacts', 'mysql_ssl_ca', '');
$aResult['contactsMySQLSSLVerify'] = !!$oConfig->Get('contacts', 'mysql_ssl_verify', true);
$aResult['contactsMySQLSSLCiphers'] = (string) $oConfig->Get('contacts', 'mysql_ssl_ciphers', '');
$aResult['contactsSQLiteGlobal'] = !!$oConfig->Get('contacts', 'sqlite_global', \is_file(APP_PRIVATE_DATA . '/AddressBook.sqlite'));
$aResult['contactsSuggestionsLimit'] = (int)$oConfig->Get('contacts', 'suggestions_limit', 20);
$aResult['faviconUrl'] = $oConfig->Get('webmail', 'favicon_url', '');

View file

@ -76,6 +76,7 @@ class ActionsAdmin extends Actions
$this->setConfigFromParams($oConfig, 'contactsMySQLSSLCA', 'contacts', 'mysql_ssl_ca', 'string');
$this->setConfigFromParams($oConfig, 'contactsMySQLSSLVerify', 'contacts', 'mysql_ssl_verify', 'bool');
$this->setConfigFromParams($oConfig, 'contactsMySQLSSLCiphers', 'contacts', 'mysql_ssl_ciphers', 'string');
$this->setConfigFromParams($oConfig, 'contactsSQLiteGlobal', 'contacts', 'sqlite_global', 'bool');
$this->setConfigFromParams($oConfig, 'contactsSuggestionsLimit', 'contacts', 'suggestions_limit', 'int');
$this->setConfigFromParams($oConfig, 'contactsPdoType', 'contacts', 'type', 'string', function ($sType) use ($self) {
return Providers\AddressBook\PdoAddressBook::validPdoType($sType);
@ -153,6 +154,7 @@ class ActionsAdmin extends Actions
$this->setConfigFromParams($oConfig, 'MySQLSSLCA', 'contacts', 'mysql_ssl_ca', 'string');
$this->setConfigFromParams($oConfig, 'MySQLSSLVerify', 'contacts', 'mysql_ssl_verify', 'bool');
$this->setConfigFromParams($oConfig, 'MySQLSSLCiphers', 'contacts', 'mysql_ssl_ciphers', 'string');
$this->setConfigFromParams($oConfig, 'SQLiteGlobal', 'contacts', 'sqlite_global', 'bool');
$sTestMessage = '';
try {
@ -391,6 +393,7 @@ class ActionsAdmin extends Actions
$aResult['contactsMySQLSSLCA'] = (string) $oConfig->Get('contacts', 'mysql_ssl_ca', '');
$aResult['contactsMySQLSSLVerify'] = !!$oConfig->Get('contacts', 'mysql_ssl_verify', true);
$aResult['contactsMySQLSSLCiphers'] = (string) $oConfig->Get('contacts', 'mysql_ssl_ciphers', '');
$aResult['contactsSQLiteGlobal'] = !!$oConfig->Get('contacts', 'sqlite_global', \is_file(APP_PRIVATE_DATA . '/AddressBook.sqlite'));
$aResult['contactsSuggestionsLimit'] = (int)$oConfig->Get('contacts', 'suggestions_limit', 20);
$aResult['faviconUrl'] = $oConfig->Get('webmail', 'favicon_url', '');

View file

@ -201,6 +201,7 @@ Warning: only enable when server does not do this, else double compression error
'mysql_ssl_ca' => array('', 'PEM format certificate'),
'mysql_ssl_verify' => array(true),
'mysql_ssl_ciphers' => array('', 'HIGH'),
'sqlite_global' => array(\is_file(APP_PRIVATE_DATA . '/AddressBook.sqlite')),
'suggestions_limit' => array(20)
),

View file

@ -32,20 +32,20 @@ class PdoAddressBook
$oSettings->driver = static::validPdoType($oConfig->Get('contacts', 'type', 'sqlite'));
if ('sqlite' === $oSettings->driver) {
$sDsn = 'sqlite:' . APP_PRIVATE_DATA . 'AddressBook.sqlite';
/*
// TODO: use local db?
$oAccount = \RainLoop\Api::Actions()->getMainAccountFromToken(false);
if ($oAccount) {
$homedir = \RainLoop\Api::Actions()->StorageProvider()->GenerateFilePath(
$oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::ROOT
);
if (!\is_file($homedir . 'AddressBook.sqlite') && \is_file(APP_PRIVATE_DATA . '/AddressBook.sqlite')) {
\copy(APP_PRIVATE_DATA . '/AddressBook.sqlite', $homedir . 'AddressBook.sqlite');
if (!$oConfig->Get('contacts', 'sqlite_global', \is_file(APP_PRIVATE_DATA . '/AddressBook.sqlite'))) {
$oAccount = \RainLoop\Api::Actions()->getMainAccountFromToken(false);
if ($oAccount) {
$homedir = \RainLoop\Api::Actions()->StorageProvider()->GenerateFilePath(
$oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::ROOT
);
// TODO: sync data on switch?
// if (!\is_file($homedir . 'AddressBook.sqlite') && \is_file(APP_PRIVATE_DATA . '/AddressBook.sqlite')) {
// \copy(APP_PRIVATE_DATA . '/AddressBook.sqlite', $homedir . 'AddressBook.sqlite');
// }
$sDsn = 'sqlite:' . $homedir . 'AddressBook.sqlite';
}
$sDsn = 'sqlite:' . $homedir . 'AddressBook.sqlite';
}
*/
} else {
$sDsn = \trim($oConfig->Get('contacts', 'pdo_dsn', ''));
$oSettings->user = \trim($oConfig->Get('contacts', 'pdo_user', ''));

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Uživatel",
"LABEL_STORAGE_PASSWORD": "Heslo",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Upozornění!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Nepoužívejte tento typ databáze při velkém počtu aktivních uživatelů.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Bruger",
"LABEL_STORAGE_PASSWORD": "Adgangskode",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Underretning!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Brug ikke denne database type med større antal af aktive brugere.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "DSN",
"LABEL_STORAGE_USER": "Benutzer",
"LABEL_STORAGE_PASSWORD": "Passwort",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Hinweis!",
"SUGGESTIONS_LIMIT": "Limit für Empfehlungen",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Verwenden Sie diesen Datenbanktyp nicht bei einer hohen Anzahl aktiver Benutzer.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Data Source Name (DSN)",
"LABEL_STORAGE_USER": "User",
"LABEL_STORAGE_PASSWORD": "Password",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Notice!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Don't use this database type with a large number of active users.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Usuario",
"LABEL_STORAGE_PASSWORD": "Contraseña",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "¡Advertencia!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "No utilices este tipo de Base de Datos para un número grande de usuarios.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Erabiltzailea",
"LABEL_STORAGE_PASSWORD": "Pasahitza",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Adi!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Ez erabili datubase hau erabiltzaile aktibo koputu handiarekin.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "کاربر",
"LABEL_STORAGE_PASSWORD": "گذرواژه",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "توجه!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "از این پایگاه داده برای کاربران زیاد استفاده نکنید.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Käyttäjä",
"LABEL_STORAGE_PASSWORD": "Salasana",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Huomio!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Älä käytä tätä tietokantatyyppiä suurella määrällä aktiivisia käyttäjiä.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Utilisateur",
"LABEL_STORAGE_PASSWORD": "Mot de passe",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Note !",
"SUGGESTIONS_LIMIT": "Limite de suggestions",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "N'utilisez pas ce type de base de données avec un grand nombre d'utilisateurs actifs.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "DSN",
"LABEL_STORAGE_USER": "Felhasználó",
"LABEL_STORAGE_PASSWORD": "Jelszó",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Megjegyzés!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Ne használd ezt az adatbázis típust nagy számú aktív felhasználóval.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "User",
"LABEL_STORAGE_PASSWORD": "Password",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Perhatian!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Jangan gunakan tipe database ini untuk jumlah user aktif yang besar.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Utente",
"LABEL_STORAGE_PASSWORD": "Password",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Avviso!",
"SUGGESTIONS_LIMIT": "Limite suggerimenti",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Non usare questo tipo di database con un grande numero di utenti attivi.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "ユーザー",
"LABEL_STORAGE_PASSWORD": "パスワード",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "注意!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "アクティブユーザーの数が多いとき、このデータベース・タイプを使用しないでください。",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Vartotojas",
"LABEL_STORAGE_PASSWORD": "Slaptažodis",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Pastaba!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Nenaudokite šio duomenų bazės tipo, jei turite daug aktyvių vartotojų",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Bruker",
"LABEL_STORAGE_PASSWORD": "Passord",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Varsel!",
"SUGGESTIONS_LIMIT": "Forslagsbegrensning",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Ikke bruk denne databasetypen hvis dette systemet har mange brukere.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Gebruikersnaam",
"LABEL_STORAGE_PASSWORD": "Wachtwoord",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Aandacht!",
"SUGGESTIONS_LIMIT": "Suggesties limiet",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Gegruik deze database soort niet met een groot aantal actieve gebrukers.",

View file

@ -255,7 +255,7 @@
"TITLE_UPDATE_IDENTITY": "Identiteit bijwerken?",
"BUTTON_ADD_IDENTITY": "Toevoegen",
"BUTTON_UPDATE_IDENTITY": "Bijwerken",
"LABEL_SIGNATURE_ADD": "Handtekening toevoegen/wijzigen",
"LABEL_SIGNATURE_ADD": "Handtekening toevoegen\/wijzigen",
"LABEL_SIGNATURE_INSERT_BEFORE": "Plaats deze handtekening vóór geciteerde tekst in antwoorden"
},
"POPUPS_CREATE_FOLDER": {

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Adres DSN",
"LABEL_STORAGE_USER": "Użytkownik",
"LABEL_STORAGE_PASSWORD": "Hasło",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Ostrzeżenie!",
"SUGGESTIONS_LIMIT": "Limit sugestii",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Nie używaj tej bazy danych z dużą ilością aktywnych użytkowników.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Usuário",
"LABEL_STORAGE_PASSWORD": "Senha",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Aviso!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Não use este tipo de banco de dados com um grande número de usuários ativos.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Nome da Origem de Dados (DSN)",
"LABEL_STORAGE_USER": "Utilizador",
"LABEL_STORAGE_PASSWORD": "Palavra-passe",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Aviso!",
"SUGGESTIONS_LIMIT": "Limite de sugestões",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Não use este tipo de base de dados com uma grande quantidade de utilizadores ativos.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Nome da Origem de Dados (DSN)",
"LABEL_STORAGE_USER": "Utilizador",
"LABEL_STORAGE_PASSWORD": "Palavra-passe",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Aviso!",
"SUGGESTIONS_LIMIT": "Limite de sugestões",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Não use este tipo de base de dados com uma grande quantidade de utilizadores ativos.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Пользователь",
"LABEL_STORAGE_PASSWORD": "Пароль",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Внимание!",
"SUGGESTIONS_LIMIT": "Лимит предложений",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Не используйте этот тип базы данных с большим числом активных пользователей.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Užívateľ",
"LABEL_STORAGE_PASSWORD": "Heslo",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Notice!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Nepoužívajte tento typ databázy, ak máte veľký počet aktívnych používateľov.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Ime podatkovnega vira (DSN)",
"LABEL_STORAGE_USER": "Uporabnik",
"LABEL_STORAGE_PASSWORD": "Geslo",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Obvestilo!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Ta tip podatkovne baze ni priporočljiv za večje število uporabnikov.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Användare",
"LABEL_STORAGE_PASSWORD": "Lösenord",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Notis",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Använd inte denna typ av databas med ett stort antal aktiva användare.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "Người dùng",
"LABEL_STORAGE_PASSWORD": "Mật khẩu",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "Chú ý!",
"SUGGESTIONS_LIMIT": "Suggestions limit",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "Đừng nên sử dụng loại cơ sở dữ liệu này với lượng lớn người dùng mail đang hoạt động.",

View file

@ -68,6 +68,7 @@
"LABEL_STORAGE_DSN": "Dsn",
"LABEL_STORAGE_USER": "用户",
"LABEL_STORAGE_PASSWORD": "密码",
"SQLITE_GLOBAL": "Use a global DB instead of per account",
"ALERT_NOTICE": "提示!",
"SUGGESTIONS_LIMIT": "建议数量上限",
"HTML_ALERT_DO_NOT_USE_THIS_DATABASE": "如果有大量的活跃用户,请不要选择此数据库类型。",

View file

@ -86,22 +86,23 @@
</div>
</div>
</div>
<div class="control-group">
<label></label>
<a class="btn" data-bind="command: testContactsCommand, css: { 'btn-success': testContactsSuccess, 'btn-danger': testContactsError }">
<i class="fontastic" data-bind="css: {'icon-spinner': testing()}"></i>
<span data-i18n="GLOBAL/TEST"></span>
</a>
</div>
</div>
<div data-bind="visible: 'sqlite' === contactsPdoType()">
<div class="control-group">
<label></label>
<div data-bind="component: {
name: 'Checkbox',
params: { value: contactsSQLiteGlobal, label: 'TAB_CONTACTS/SQLITE_GLOBAL' }
}"></div>
</div>
<div class="control-group" data-bind="visible: contactsSQLiteGlobal">
<div class="alert">
<h4 data-i18n="TAB_CONTACTS/ALERT_NOTICE"></h4>
<div data-i18n="[html]TAB_CONTACTS/HTML_ALERT_DO_NOT_USE_THIS_DATABASE"></div>
</div>
</div>
</div>
<div data-bind="visible: contactsPdoType">
<div class="control-group">
<label></label>
<a class="btn" data-bind="command: testContactsCommand, css: { 'btn-success': testContactsSuccess, 'btn-danger': testContactsError }">