diff --git a/Gruntfile.js b/Gruntfile.js index 8969a0d9c..3887090e8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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", diff --git a/dev/Admin/Contacts.js b/dev/Admin/Contacts.js new file mode 100644 index 000000000..3cee6be7e --- /dev/null +++ b/dev/Admin/Contacts.js @@ -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); +}; diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index ebaec6bf1..bdf366fe1 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -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'); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php index 1811f5669..d84922d36 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php @@ -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 diff --git a/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html b/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html new file mode 100644 index 000000000..05cd37709 --- /dev/null +++ b/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html @@ -0,0 +1,51 @@ +