diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-03-06 00:15:08 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-03-06 00:15:08 +0100 |
commit | 32b29c9d735ae235641a7ea3869c14d7eb69cb4f (patch) | |
tree | 63e4e269bd33b0688965c9b3b1059466a8f502b8 /settings | |
parent | 6de370b64cb8f7fcd9d3bd090b8d801d91d2fcca (diff) | |
parent | 1785c0c9b9fcdc6e9a8e58f13f45e5b53364882a (diff) | |
download | nextcloud-server-32b29c9d735ae235641a7ea3869c14d7eb69cb4f.tar.gz nextcloud-server-32b29c9d735ae235641a7ea3869c14d7eb69cb4f.zip |
Merge branch 'master' into fix-7307
Conflicts:
core/js/router.js
settings/js/admin.js
Diffstat (limited to 'settings')
-rw-r--r-- | settings/admin/controller.php | 30 | ||||
-rw-r--r-- | settings/js/admin.js | 10 | ||||
-rw-r--r-- | settings/routes.php | 3 | ||||
-rw-r--r-- | settings/templates/admin.php | 6 | ||||
-rw-r--r-- | settings/templates/personal.php | 2 |
5 files changed, 48 insertions, 3 deletions
diff --git a/settings/admin/controller.php b/settings/admin/controller.php index a075d774361..7019f9a4d2a 100644 --- a/settings/admin/controller.php +++ b/settings/admin/controller.php @@ -74,6 +74,36 @@ class Controller { } /** + * Send a mail to test the settings + */ + public static function sendTestMail() { + \OC_Util::checkAdminUser(); + \OCP\JSON::callCheck(); + + $l = \OC_L10N::get('settings'); + $email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', ''); + if (!empty($email)) { + $defaults = new \OC_Defaults(); + + try { + \OC_Mail::send($email, $_POST['user'], + $l->t('test email settings'), + $l->t('If you received this email, the settings seem to be correct.'), + \OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName()); + } catch (\Exception $e) { + $message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.'); + \OC_JSON::error( array( "data" => array( "message" => $message)) ); + exit; + } + + \OC_JSON::success(array("data" => array( "message" => $l->t("Email sent") ))); + } else { + $message = $l->t('You need to set your user email before being able to send test emails.'); + \OC_JSON::error( array( "data" => array( "message" => $message)) ); + } + } + + /** * Get the field name to use it in error messages * * @param $setting string diff --git a/settings/js/admin.js b/settings/js/admin.js index cfb1cb788d0..c04c0505deb 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -62,10 +62,18 @@ $(document).ready(function(){ }); $('#mail_settings').change(function(){ - OC.msg.startSaving('#mail_settings .msg'); + OC.msg.startSaving('#mail_settings_msg'); var post = $( "#mail_settings" ).serialize(); $.post(OC.generateUrl('/settings/admin/mailsettings'), post, function(data){ OC.msg.finishedSaving('#mail_settings .msg', data); }); }); + + $('#sendtestemail').click(function(){ + OC.msg.startAction('#sendtestmail_msg', t('settings', 'Sending...')); + var post = $( "#sendtestemail" ).serialize(); + $.post(OC.generateUrl('/settings/admin/mailtest'), post, function(data){ + OC.msg.finishedAction('#sendtestmail_msg', data); + }); + }); }); diff --git a/settings/routes.php b/settings/routes.php index 7d94f130088..6954bd3823d 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -75,5 +75,8 @@ $this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php') $this->create('settings_mail_settings', '/settings/admin/mailsettings') ->post() ->action('OC\Settings\Admin\Controller', 'setMailSettings'); +$this->create('settings_admin_mail_test', '/settings/admin/mailtest') + ->post() + ->action('OC\Settings\Admin\Controller', 'sendTestMail'); $this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php') ->actionInclude('settings/ajax/setsecurity.php'); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 139a9dd076c..487da036e74 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -272,7 +272,7 @@ if (!$_['internetconnectionworking']) { </fieldset> <fieldset id="mail_settings" class="personalblock"> - <h2><?php p($l->t('Email Server'));?> <span class="msg"></span></h2> + <h2><?php p($l->t('Email Server'));?> <span id="mail_settings_msg" class="msg"></span></h2> <p><?php p($l->t('This is used for sending out notifications.')); ?></p> @@ -347,6 +347,10 @@ if (!$_['internetconnectionworking']) { placeholder="<?php p($l->t('SMTP Password'))?>" value='<?php p($_['mail_smtppassword']) ?>' /> </p> + <br /> + <em><?php p($l->t( 'Test email settings' )); ?></em> + <input type="submit" name="sendtestemail" id="sendtestemail" value="<?php p($l->t( 'Send email' )); ?>"/> + <span id="sendtestmail_msg" class="msg"></span> </fieldset> <fieldset class="personalblock"> diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 470b8180bcc..9024f435657 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -83,7 +83,7 @@ if($_['passwordChangeSupported']) { placeholder="<?php p($l->t('Your email address'));?>" autocomplete="on" autocapitalize="off" autocorrect="off" /> <span class="msg"></span><br /> - <em><?php p($l->t('Fill in an email address to enable password recovery'));?></em> + <em><?php p($l->t('Fill in an email address to enable password recovery and receive notifications'));?></em> </fieldset> </form> <?php |