mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +03:00
Add contacts configutation page in admin panel
This commit is contained in:
parent
0ec4fc89d4
commit
74af8f793a
9 changed files with 229 additions and 30 deletions
|
|
@ -179,6 +179,7 @@ module.exports = function (grunt) {
|
|||
|
||||
"dev/Admin/General.js",
|
||||
"dev/Admin/Login.js",
|
||||
"dev/Admin/Contacts.js",
|
||||
"dev/Admin/Domains.js",
|
||||
"dev/Admin/Security.js",
|
||||
"dev/Admin/Social.js",
|
||||
|
|
|
|||
60
dev/Admin/Contacts.js
Normal file
60
dev/Admin/Contacts.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminContacts()
|
||||
{
|
||||
// var oData = RL.data();
|
||||
|
||||
this.contactsSupported = !!RL.settingsGet('ContactsIsSupported');
|
||||
this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable'));
|
||||
|
||||
this.pdoDsn = ko.observable(RL.settingsGet('ContactsPdoDsn'));
|
||||
this.pdoUser = ko.observable(RL.settingsGet('ContactsPdoUser'));
|
||||
this.pdoPassword = ko.observable(RL.settingsGet('ContactsPdoPassword'));
|
||||
|
||||
this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
||||
Utils.addSettingsViewModel(AdminContacts, 'AdminSettingsContacts', 'Contacts', 'contacts');
|
||||
|
||||
AdminContacts.prototype.onBuild = function ()
|
||||
{
|
||||
var self = this;
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self)
|
||||
;
|
||||
|
||||
self.enableContacts.subscribe(function (bValue) {
|
||||
RL.remote().saveAdminConfig(null, {
|
||||
'ContactsEnable': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoDsn.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f1, {
|
||||
'ContactsPdoDsn': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoUser.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f2, {
|
||||
'ContactsPdoUser': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoPassword.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f3, {
|
||||
'ContactsPdoPassword': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
|
@ -980,31 +980,37 @@ class Actions
|
|||
else
|
||||
{
|
||||
$aResult['Auth'] = $this->IsAdminLoggined(false);
|
||||
$aResult['AdminLogin'] = $oConfig->Get('security', 'admin_login', '');
|
||||
$aResult['AdminDomain'] = APP_SITE;
|
||||
$aResult['UseTokenProtection'] = (bool) $oConfig->Get('security', 'csrf_protection', true);
|
||||
$aResult['EnabledPlugins'] = (bool) $oConfig->Get('plugins', 'enable', false);
|
||||
|
||||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||
$aResult['GoogleClientID'] = (string) $oConfig->Get('social', 'google_client_id', '');
|
||||
$aResult['GoogleClientSecret'] = (string) $oConfig->Get('social', 'google_client_secret', '');
|
||||
|
||||
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
||||
$aResult['FacebookAppID'] = (string) $oConfig->Get('social', 'fb_app_id', '');
|
||||
$aResult['FacebookAppSecret'] = (string) $oConfig->Get('social', 'fb_app_secret', '');
|
||||
|
||||
$aResult['AllowTwitterSocial'] = (bool) $oConfig->Get('social', 'twitter_enable', false);
|
||||
$aResult['TwitterConsumerKey'] = (string) $oConfig->Get('social', 'twitter_consumer_key', '');
|
||||
$aResult['TwitterConsumerSecret'] = (string) $oConfig->Get('social', 'twitter_consumer_secret', '');
|
||||
|
||||
$aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
|
||||
$aResult['DropboxApiKey'] = (string) $oConfig->Get('social', 'dropbox_api_key', '');
|
||||
|
||||
$aResult['SubscriptionEnabled'] = \MailSo\Base\Utils::ValidateDomain($aResult['AdminDomain']);
|
||||
|
||||
$aResult['WeakPassword'] = false;
|
||||
if ($aResult['Auth'])
|
||||
{
|
||||
$aResult['AdminLogin'] = $oConfig->Get('security', 'admin_login', '');
|
||||
$aResult['AdminDomain'] = APP_SITE;
|
||||
$aResult['UseTokenProtection'] = (bool) $oConfig->Get('security', 'csrf_protection', true);
|
||||
$aResult['EnabledPlugins'] = (bool) $oConfig->Get('plugins', 'enable', false);
|
||||
|
||||
$aResult['ContactsIsSupported'] = (bool) $this->PersonalAddressBookProvider()->IsSupported();
|
||||
|
||||
$aResult['ContactsEnable'] = (bool) $oConfig->Get('contacts', 'enable', false);
|
||||
$aResult['ContactsPdoDsn'] = (string) $oConfig->Get('contacts', 'pdo_dsn', '');
|
||||
$aResult['ContactsPdoUser'] = (string) $oConfig->Get('contacts', 'pdo_user', '');
|
||||
$aResult['ContactsPdoPassword'] = APP_DUMMY;
|
||||
|
||||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||
$aResult['GoogleClientID'] = (string) $oConfig->Get('social', 'google_client_id', '');
|
||||
$aResult['GoogleClientSecret'] = (string) $oConfig->Get('social', 'google_client_secret', '');
|
||||
|
||||
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
||||
$aResult['FacebookAppID'] = (string) $oConfig->Get('social', 'fb_app_id', '');
|
||||
$aResult['FacebookAppSecret'] = (string) $oConfig->Get('social', 'fb_app_secret', '');
|
||||
|
||||
$aResult['AllowTwitterSocial'] = (bool) $oConfig->Get('social', 'twitter_enable', false);
|
||||
$aResult['TwitterConsumerKey'] = (string) $oConfig->Get('social', 'twitter_consumer_key', '');
|
||||
$aResult['TwitterConsumerSecret'] = (string) $oConfig->Get('social', 'twitter_consumer_secret', '');
|
||||
|
||||
$aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
|
||||
$aResult['DropboxApiKey'] = (string) $oConfig->Get('social', 'dropbox_api_key', '');
|
||||
|
||||
$aResult['SubscriptionEnabled'] = \MailSo\Base\Utils::ValidateDomain($aResult['AdminDomain']);
|
||||
|
||||
$aResult['WeakPassword'] = $oConfig->ValidatePassword('12345');
|
||||
}
|
||||
}
|
||||
|
|
@ -1772,6 +1778,14 @@ class Actions
|
|||
$oConfig->Set($sConfigSector, $sConfigName, (string) $sValue);
|
||||
break;
|
||||
|
||||
case 'dummy':
|
||||
$sValue = (string) $this->GetActionParam('ContactsPdoPassword', APP_DUMMY);
|
||||
if (APP_DUMMY !== $sValue)
|
||||
{
|
||||
$oConfig->Set($sConfigSector, $sConfigName, (string) $sValue);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'int':
|
||||
$iValue = (int) $sValue;
|
||||
$oConfig->Set($sConfigSector, $sConfigName, $iValue);
|
||||
|
|
@ -1848,6 +1862,11 @@ class Actions
|
|||
$this->setConfigFromParams($oConfig, 'AllowCustomLogin', 'login', 'allow_custom_login', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'LoginDefaultDomain', 'login', 'default_domain', 'string');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'ContactsEnable', 'contacts', 'enable', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoDsn', 'contacts', 'pdo_dsn', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoUser', 'contacts', 'pdo_user', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'AllowAdditionalAccounts', 'webmail', 'allow_additional_accounts', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'AllowIdentities', 'webmail', 'allow_identities', 'bool');
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,15 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider
|
|||
$this->oDriver->IsSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsSupported()
|
||||
{
|
||||
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface &&
|
||||
$this->oDriver->IsSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param \RainLoop\Providers\PersonalAddressBook\Classes\Contact $oContact
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
<div class="b-admin-general">
|
||||
<div class="row" data-bind="visible: !contactsSupported">
|
||||
<div class="alert span8">
|
||||
<h4>Notice!</h4>
|
||||
<br />
|
||||
Your system doesn't support contacts.
|
||||
<br />
|
||||
You need to install or enable <strong>PDO (MySQL)</strong> exstenstion on your web server.
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-horizontal" data-bind="visible: contactsSupported">
|
||||
<div class="legend">
|
||||
Contacts
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label data-bind="click: function () { enableContacts(!enableContacts()); }">
|
||||
<i data-bind="css: enableContacts() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
|
||||
Enable contacts
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
PDO dsn
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span6" data-bind="value: pdoDsn, saveTrigger: pdoDsnTrigger" />
|
||||
<div data-bind="saveTrigger: pdoDsnTrigger"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
PDO user
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" data-bind="value: pdoUser, saveTrigger: pdoUserTrigger" />
|
||||
<div data-bind="saveTrigger: pdoUserTrigger"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
PDO password
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="password" data-bind="value: pdoPassword, saveTrigger: pdoPasswordTrigger" />
|
||||
<div data-bind="saveTrigger: pdoPasswordTrigger"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
Theme
|
||||
</label>
|
||||
<div class="controls">
|
||||
<select data-bind="options: themesOptions, value: mainTheme, optionsText: 'optText', optionsValue: 'optValue', saveTrigger: themeTrigger"></select>
|
||||
<select class="span2" data-bind="options: themesOptions, value: mainTheme, optionsText: 'optText', optionsValue: 'optValue', saveTrigger: themeTrigger"></select>
|
||||
<div data-bind="saveTrigger: themeTrigger"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
Title
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" data-bind="value: title, saveTrigger: titleTrigger" />
|
||||
<input type="text" class="span5" data-bind="value: title, saveTrigger: titleTrigger" />
|
||||
<div data-bind="saveTrigger: titleTrigger"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
Loading Description
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" data-bind="value: loadingDesc, saveTrigger: loadingDescTrigger" />
|
||||
<input type="text" class="span5" data-bind="value: loadingDesc, saveTrigger: loadingDescTrigger" />
|
||||
<div data-bind="saveTrigger: loadingDescTrigger"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
Default Domain
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" data-bind="value: defaultDomain, saveTrigger: defaultDomainTrigger" />
|
||||
<input type="text" class="span3" data-bind="value: defaultDomain, saveTrigger: defaultDomainTrigger" />
|
||||
<div data-bind="saveTrigger: defaultDomainTrigger"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5166,6 +5166,65 @@ AdminLogin.prototype.onBuild = function ()
|
|||
}, 50);
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminContacts()
|
||||
{
|
||||
// var oData = RL.data();
|
||||
|
||||
this.contactsSupported = !!RL.settingsGet('ContactsIsSupported');
|
||||
this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable'));
|
||||
|
||||
this.pdoDsn = ko.observable(RL.settingsGet('ContactsPdoDsn'));
|
||||
this.pdoUser = ko.observable(RL.settingsGet('ContactsPdoUser'));
|
||||
this.pdoPassword = ko.observable(RL.settingsGet('ContactsPdoPassword'));
|
||||
|
||||
this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
||||
Utils.addSettingsViewModel(AdminContacts, 'AdminSettingsContacts', 'Contacts', 'contacts');
|
||||
|
||||
AdminContacts.prototype.onBuild = function ()
|
||||
{
|
||||
var self = this;
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self)
|
||||
;
|
||||
|
||||
self.enableContacts.subscribe(function (bValue) {
|
||||
RL.remote().saveAdminConfig(null, {
|
||||
'ContactsEnable': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoDsn.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f1, {
|
||||
'ContactsPdoDsn': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoUser.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f2, {
|
||||
'ContactsPdoUser': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoPassword.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f3, {
|
||||
'ContactsPdoPassword': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
|
|
|
|||
6
rainloop/v/0.0.0/static/js/admin.min.js
vendored
6
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue