From 8387cd8ae35a0ad94a49a27ad8622bb7b8ed2b06 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 12 Feb 2014 17:21:41 +0100 Subject: Add option to change email settings in admin section Fix issue #7166 --- settings/admin.php | 10 +++++ settings/admin/controller.php | 83 ++++++++++++++++++++++++++++++++++++++++ settings/css/settings.css | 12 ++++++ settings/js/admin.js | 38 +++++++++++++++++++ settings/routes.php | 3 ++ settings/templates/admin.php | 88 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 234 insertions(+) create mode 100644 settings/admin/controller.php (limited to 'settings') diff --git a/settings/admin.php b/settings/admin.php index c0e4570658a..42477bfc1ca 100755 --- a/settings/admin.php +++ b/settings/admin.php @@ -21,6 +21,16 @@ $entries=OC_Log_Owncloud::getEntries(3); $entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3; $tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 )); +$tmpl->assign('mail_domain', OC_Config::getValue( "mail_domain", '' )); +$tmpl->assign('mail_from_address', OC_Config::getValue( "mail_from_address", '' )); +$tmpl->assign('mail_smtpmode', OC_Config::getValue( "mail_smtpmode", '' )); +$tmpl->assign('mail_smtpsecure', OC_Config::getValue( "mail_smtpsecure", '' )); +$tmpl->assign('mail_smtphost', OC_Config::getValue( "mail_smtphost", '' )); +$tmpl->assign('mail_smtpport', OC_Config::getValue( "mail_smtpport", '' )); +$tmpl->assign('mail_smtpauthtype', OC_Config::getValue( "mail_smtpauthtype", '' )); +$tmpl->assign('mail_smtpauth', OC_Config::getValue( "mail_smtpauth", false )); +$tmpl->assign('mail_smtpname', OC_Config::getValue( "mail_smtpname", '' )); +$tmpl->assign('mail_smtppassword', OC_Config::getValue( "mail_smtppassword", '' )); $tmpl->assign('entries', $entries); $tmpl->assign('entriesremain', $entriesremain); $tmpl->assign('htaccessworking', $htaccessworking); diff --git a/settings/admin/controller.php b/settings/admin/controller.php new file mode 100644 index 00000000000..9bbcd356580 --- /dev/null +++ b/settings/admin/controller.php @@ -0,0 +1,83 @@ +. +*/ + +namespace OC\Settings\Admin; + +class Controller { + public static function setMailSettings($args) { + \OC_Util::checkAdminUser(); + \OCP\JSON::callCheck(); + + $l = \OC_L10N::get('settings'); + + $smtp_settings = array( + 'mail_domain' => null, + 'mail_from_address' => null, + 'mail_smtpmode' => array('sendmail', 'smtp', 'qmail', 'php'), + 'mail_smtpsecure' => array('', 'ssl', 'tls'), + 'mail_smtphost' => null, + 'mail_smtpport' => null, + 'mail_smtpauthtype' => array('LOGIN', 'PLAIN', 'NTLM'), + 'mail_smtpauth' => true, + 'mail_smtpname' => null, + 'mail_smtppassword' => null, + ); + + foreach ($smtp_settings as $setting => $validate) { + if (!$validate) { + if (!isset($_POST[$setting]) || $_POST[$setting] === '') { + \OC_Config::deleteKey( $setting ); + } else { + \OC_Config::setValue( $setting, $_POST[$setting] ); + } + } + else if (is_bool($validate)) { + if (!empty($_POST[$setting])) { + \OC_Config::setValue( $setting, (bool) $_POST[$setting] ); + } else { + \OC_Config::deleteKey( $setting ); + } + } + else if (is_array($validate)) { + if (!isset($_POST[$setting]) || $_POST[$setting] === '') { + \OC_Config::deleteKey( $setting ); + } else if (in_array($_POST[$setting], $validate)) { + \OC_Config::setValue( $setting, $_POST[$setting] ); + } else { + $message = $l->t('Invalid value supplied for %s', array(self::getFieldname($setting, $l))); + \OC_JSON::error( array( "data" => array( "message" => $message)) ); + exit; + } + } + } + + \OC_JSON::success(array("data" => array( "message" => $l->t("Saved") ))); + } + + public static function getFieldname($setting, $l) { + switch ($setting) { + case 'mail_smtpmode': + return $l->t( 'SMTP mode' ); + case 'mail_smtpsecure': + return $l->t( 'Secure SMTP' ); + case 'mail_smtpauthtype': + return $l->t( 'Authentification method for SMTP' ); + } + } +} diff --git a/settings/css/settings.css b/settings/css/settings.css index 8a96885b789..ad205e761cb 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -150,6 +150,18 @@ span.connectionwarning {color:#933; font-weight:bold; } input[type=radio] { width:1em; } table.shareAPI td { padding-bottom: 0.8em; } +#mail_settings p label:first-child { + display: inline-block; + width: 300px; + text-align: right; +} +#mail_settings p select:nth-child(2) { + width: 143px; +} +#mail_smtpport { + width: 40px; +} + /* HELP */ .pressed {background-color:#DDD;} diff --git a/settings/js/admin.js b/settings/js/admin.js index e957bd68f1f..f39f53d413a 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -34,4 +34,42 @@ $(document).ready(function(){ $('#security').change(function(){ $.post(OC.filePath('settings','ajax','setsecurity.php'), { enforceHTTPS: $('#forcessl').val() },function(){} ); }); + + $('#mail_smtpauth').change(function() { + if (!this.checked) { + $('#mail_credentials').toggle(false); + } else { + $('#mail_credentials').toggle(true); + } + }); + + $('#mail_settings').change(function(){ + OC.msg.startSaving('#mail_settings .msg'); + var post = $( "#mail_settings" ).serialize(); + $.post(OC.Router.generate('settings_mail_settings'), post, function(data){ + OC.msg.finishedSaving('#mail_settings .msg', data); + }); + }); }); + +OC.msg={ + startSaving:function(selector){ + $(selector) + .html( t('settings', 'Saving...') ) + .removeClass('success') + .removeClass('error') + .stop(true, true) + .show(); + }, + finishedSaving:function(selector, data){ + if( data.status === "success" ){ + $(selector).html( data.data.message ) + .addClass('success') + .stop(true, true) + .delay(3000) + .fadeOut(900); + }else{ + $(selector).html( data.data.message ).addClass('error'); + } + } +}; diff --git a/settings/routes.php b/settings/routes.php index 60f9d8e1001..aa16ad491f8 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -70,6 +70,9 @@ $this->create('settings_ajax_getlog', '/settings/ajax/getlog.php') ->actionInclude('settings/ajax/getlog.php'); $this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php') ->actionInclude('settings/ajax/setloglevel.php'); +$this->create('settings_mail_settings', '/settings/admin/mailsettings') + ->post() + ->action('OC\Settings\Admin\Controller', 'setMailSettings'); $this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php') ->actionInclude('settings/ajax/setsecurity.php'); $this->create('isadmin', '/settings/js/isadmin.js') diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 0eabffb9316..d81840b5b66 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -11,6 +11,27 @@ $levelLabels = array( $l->t( 'Errors and fatal issues' ), $l->t( 'Fatal issues only' ), ); + +$mail_smtpauthtype = array( + '' => $l->t('None'), + 'LOGIN' => $l->t('Login'), + 'PLAIN' => $l->t('Plain'), + 'NTLM' => $l->t('NT LAN Manager'), +); + +$mail_smtpsecure = array( + '' => $l->t('None'), + 'ssl' => $l->t('SSL'), + 'tls' => $l->t('TLS'), +); + +$mail_smtpmode = array( + 'sendmail', + 'smtp', + 'qmail', + 'php', +); + ?> +
+

t('Email Server'));?>

+ +

t('This is used for sending out notifications.')); ?>

+ +

+ + + + + +

+ +

+ + + + /> + +

+ + + +

+ + ' /> + : + ' /> +

+ +

+ + ' /> + @ + ' /> +

+ +
+

t('Log'));?>

t('Log level'));?> - - > $name): $selected = ''; if ($secure == $_['mail_smtpsecure']): @@ -301,7 +301,14 @@ if (!$_['internetconnectionworking']) {

- + + ' /> + @ + ' /> +

+ + - -

- +

-

- - ' /> - @ - ' /> +

-- cgit v1.2.3 From bc1c136cd6c27905d9e9118f355680b26a607eb6 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Wed, 26 Feb 2014 10:34:38 +0100 Subject: coding style fixes: cut long lines, whitespace --- settings/js/apps.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'settings') diff --git a/settings/js/apps.js b/settings/js/apps.js index 2c6f77d9314..26aecbee310 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -207,12 +207,24 @@ OC.Settings.Apps = OC.Settings.Apps || { a.prepend(filename); a.prepend(img); li.append(a); - // append the new app as last item in the list (.push is from sticky footer) + + // append the new app as last item in the list + // (.push is from sticky footer) $('#apps .wrapper .push').before(li); - // scroll the app navigation down so the newly added app is seen - $('#navigation').animate({ scrollTop: $('#navigation').height() }, 'slow'); - // draw attention to the newly added app entry by flashing it twice - container.children('li[data-id="'+entry.id+'"]').animate({opacity:.3}).animate({opacity:1}).animate({opacity:.3}).animate({opacity:1}); + + // scroll the app navigation down + // so the newly added app is seen + $('#navigation').animate({ + scrollTop: $('#navigation').height() + }, 'slow'); + + // draw attention to the newly added app entry + // by flashing it twice + container.children('li[data-id="' + entry.id + '"]') + .animate({opacity: 0.3}) + .animate({opacity: 1}) + .animate({opacity: 0.3}) + .animate({opacity: 1}); if (!SVGSupport() && entry.icon.match(/\.svg$/i)) { $(img).addClass('svg'); -- cgit v1.2.3 From 593adab2583cb70ebccf6e687073c6f4a55baf9e Mon Sep 17 00:00:00 2001 From: kondou Date: Wed, 26 Feb 2014 11:41:32 +0100 Subject: Fix scrutinizer issue in settings/js/apps.js --- settings/js/apps.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'settings') diff --git a/settings/js/apps.js b/settings/js/apps.js index 7c71453e105..b6bd9ee7205 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -248,9 +248,9 @@ $(document).ready(function(){ var item = tgt.is('li') ? $(tgt) : $(tgt).parent(); var app = item.data('app'); OC.Settings.Apps.loadApp(app); + $('#leftcontent .selected').removeClass('selected'); + item.addClass('selected'); } - $('#leftcontent .selected').removeClass('selected'); - item.addClass('selected'); return false; }); $('#rightcontent input.enable').click(function(){ -- cgit v1.2.3 From 9847912257de1910f99879caac8ea925fb85caed Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 26 Feb 2014 13:10:46 +0100 Subject: Remove unused variables, add doc blocks and break lines Fix #7166 --- core/js/js.js | 4 ++-- settings/admin/controller.php | 18 ++++++++++++++---- settings/js/admin.js | 2 +- settings/templates/admin.php | 29 ++++++++++++++++++++--------- 4 files changed, 37 insertions(+), 16 deletions(-) (limited to 'settings') diff --git a/core/js/js.js b/core/js/js.js index ac79f13a6d1..88b70723dd1 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -468,8 +468,8 @@ OC.addStyle.loaded=[]; OC.addScript.loaded=[]; OC.msg={ - startSaving:function(selector, message){ - OC.msg.startAction(selector, t('settings', 'Saving...')); + startSaving:function(selector){ + OC.msg.startAction(selector, t('core', 'Saving...')); }, finishedSaving:function(selector, data){ OC.msg.finishedAction(selector, data); diff --git a/settings/admin/controller.php b/settings/admin/controller.php index 9bbcd356580..a075d774361 100644 --- a/settings/admin/controller.php +++ b/settings/admin/controller.php @@ -20,7 +20,10 @@ namespace OC\Settings\Admin; class Controller { - public static function setMailSettings($args) { + /** + * Set mail settings + */ + public static function setMailSettings() { \OC_Util::checkAdminUser(); \OCP\JSON::callCheck(); @@ -70,14 +73,21 @@ class Controller { \OC_JSON::success(array("data" => array( "message" => $l->t("Saved") ))); } + /** + * Get the field name to use it in error messages + * + * @param $setting string + * @param $l \OC_L10N + * @return string + */ public static function getFieldname($setting, $l) { switch ($setting) { case 'mail_smtpmode': - return $l->t( 'SMTP mode' ); + return $l->t( 'Send mode' ); case 'mail_smtpsecure': - return $l->t( 'Secure SMTP' ); + return $l->t( 'Encryption' ); case 'mail_smtpauthtype': - return $l->t( 'Authentification method for SMTP' ); + return $l->t( 'Authentification method' ); } } } diff --git a/settings/js/admin.js b/settings/js/admin.js index e2bc125b8f5..5ea6a5af2df 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -44,7 +44,7 @@ $(document).ready(function(){ }); $('#mail_smtpmode').change(function() { - if ($(this).val() != 'smtp') { + if ($(this).val() !== 'smtp') { $('#setting_smtpauth').addClass('hidden'); $('#setting_smtphost').addClass('hidden'); $('#mail_smtpsecure_label').addClass('hidden'); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 377c05eb4b9..139a9dd076c 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -288,8 +288,12 @@ if (!$_['internetconnectionworking']) { - - > $name): $selected = ''; if ($secure == $_['mail_smtpsecure']): @@ -302,9 +306,11 @@ if (!$_['internetconnectionworking']) {

- ' /> + ' /> @ - ' /> + ' />

-- cgit v1.2.3 From 86b3cdc132a2ae19caf327985d5613a58804d1b5 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 26 Feb 2014 17:18:38 +0100 Subject: close encryption session after decryption was finished --- apps/files_encryption/lib/session.php | 8 ++++++++ apps/files_encryption/lib/util.php | 8 ++++++++ settings/ajax/decryptall.php | 2 ++ 3 files changed, 18 insertions(+) (limited to 'settings') diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php index aa58e33e9d2..3daaa06425f 100644 --- a/apps/files_encryption/lib/session.php +++ b/apps/files_encryption/lib/session.php @@ -134,6 +134,14 @@ class Session { } + /** + * @brief remove encryption keys and init status from session + */ + public function closeSession() { + \OC::$session->remove('encryptionInitialized'); + \OC::$session->remove('privateKey'); + } + /** * @brief Gets status if we already tried to initialize the encryption app diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index ec06bd52f5e..6bf69cd8ee1 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -1772,4 +1772,12 @@ class Util { return $session; } + /* + * @brief remove encryption related keys from the session + */ + public function closeEncryptionSession() { + $session = new \OCA\Encryption\Session($this->view); + $session->closeSession(); + } + } diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php index d7c104ab151..4782a4cfc81 100644 --- a/settings/ajax/decryptall.php +++ b/settings/ajax/decryptall.php @@ -24,6 +24,8 @@ if ($result !== false) { $successful = false; } + $util->closeEncryptionSession(); + if ($successful === true) { \OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully'))); } else { -- cgit v1.2.3 From e78da036c11b600bfcf15387ecb053a87150444a Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Fri, 28 Feb 2014 10:09:34 +0100 Subject: profile image: relabel technical 'Abort' to more widely used 'Cancel' --- settings/templates/personal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'settings') diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 188ff75f96b..470b8180bcc 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -108,7 +108,7 @@ if($_['passwordChangeSupported']) { -- cgit v1.2.3