Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Christoph Borchardt <hey@jancborchardt.net>2014-02-26 17:41:07 +0400
committerJan-Christoph Borchardt <hey@jancborchardt.net>2014-02-26 17:41:07 +0400
commitd9a153dbe91a775be533869b4d80ddaa33609ca8 (patch)
tree6096cf0653a95d9ac941cbd0f4dffc5bf080bd2d /settings
parent84eea47991d33922345e4fb15f7e74638e2a7ccc (diff)
parent9847912257de1910f99879caac8ea925fb85caed (diff)
Merge pull request #7174 from owncloud/issue/7166
Add option to change email settings in admin section
Diffstat (limited to 'settings')
-rwxr-xr-xsettings/admin.php10
-rw-r--r--settings/admin/controller.php93
-rw-r--r--settings/css/settings.css12
-rw-r--r--settings/js/admin.js34
-rw-r--r--settings/js/personal.js22
-rw-r--r--settings/routes.php3
-rw-r--r--settings/templates/admin.php99
7 files changed, 251 insertions, 22 deletions
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..a075d774361
--- /dev/null
+++ b/settings/admin/controller.php
@@ -0,0 +1,93 @@
+<?php
+/**
+* @author Joas Schilling
+* @copyright 2014 Joas Schilling nickvergessen@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+namespace OC\Settings\Admin;
+
+class Controller {
+ /**
+ * Set mail settings
+ */
+ public static function setMailSettings() {
+ \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") )));
+ }
+
+ /**
+ * 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( 'Send mode' );
+ case 'mail_smtpsecure':
+ return $l->t( 'Encryption' );
+ case 'mail_smtpauthtype':
+ return $l->t( 'Authentification method' );
+ }
+ }
+}
diff --git a/settings/css/settings.css b/settings/css/settings.css
index 60abbc10862..a47e7bf6563 100644
--- a/settings/css/settings.css
+++ b/settings/css/settings.css
@@ -155,6 +155,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..5ea6a5af2df 100644
--- a/settings/js/admin.js
+++ b/settings/js/admin.js
@@ -34,4 +34,38 @@ $(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').addClass('hidden');
+ } else {
+ $('#mail_credentials').removeClass('hidden');
+ }
+ });
+
+ $('#mail_smtpmode').change(function() {
+ if ($(this).val() !== 'smtp') {
+ $('#setting_smtpauth').addClass('hidden');
+ $('#setting_smtphost').addClass('hidden');
+ $('#mail_smtpsecure_label').addClass('hidden');
+ $('#mail_smtpsecure').addClass('hidden');
+ $('#mail_credentials').addClass('hidden');
+ } else {
+ $('#setting_smtpauth').removeClass('hidden');
+ $('#setting_smtphost').removeClass('hidden');
+ $('#mail_smtpsecure_label').removeClass('hidden');
+ $('#mail_smtpsecure').removeClass('hidden');
+ if ($('#mail_smtpauth').attr('checked')) {
+ $('#mail_credentials').removeClass('hidden');
+ }
+ }
+ });
+
+ $('#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);
+ });
+ });
});
diff --git a/settings/js/personal.js b/settings/js/personal.js
index 5944272067b..98bfe7132d4 100644
--- a/settings/js/personal.js
+++ b/settings/js/personal.js
@@ -315,25 +315,3 @@ OC.Encryption.msg={
}
}
};
-
-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 895a9f5ccea..64f7122f0cf 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -70,5 +70,8 @@ $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');
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index 0eabffb9316..139a9dd076c 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',
+);
+
?>
<?php
@@ -250,6 +271,84 @@ if (!$_['internetconnectionworking']) {
</table>
</fieldset>
+<fieldset id="mail_settings" class="personalblock">
+ <h2><?php p($l->t('Email Server'));?> <span class="msg"></span></h2>
+
+ <p><?php p($l->t('This is used for sending out notifications.')); ?></p>
+
+ <p>
+ <label for="mail_smtpmode"><?php p($l->t( 'Send mode' )); ?></label>
+ <select name='mail_smtpmode' id='mail_smtpmode'>
+ <?php foreach ($mail_smtpmode as $smtpmode):
+ $selected = '';
+ if ($smtpmode == $_['mail_smtpmode']):
+ $selected = 'selected="selected"';
+ endif; ?>
+ <option value='<?php p($smtpmode)?>' <?php p($selected) ?>><?php p($smtpmode) ?></option>
+ <?php endforeach;?>
+ </select>
+
+ <label id="mail_smtpsecure_label" for="mail_smtpsecure"
+ <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
+ <?php p($l->t( 'Encryption' )); ?>
+ </label>
+ <select name="mail_smtpsecure" id="mail_smtpsecure"
+ <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
+ <?php foreach ($mail_smtpsecure as $secure => $name):
+ $selected = '';
+ if ($secure == $_['mail_smtpsecure']):
+ $selected = 'selected="selected"';
+ endif; ?>
+ <option value='<?php p($secure)?>' <?php p($selected) ?>><?php p($name) ?></option>
+ <?php endforeach;?>
+ </select>
+ </p>
+
+ <p>
+ <label for="mail_from_address"><?php p($l->t( 'From address' )); ?></label>
+ <input type="text" name='mail_from_address' id="mail_from_address" placeholder="<?php p('mail')?>"
+ value='<?php p($_['mail_from_address']) ?>' />
+ @
+ <input type="text" name='mail_domain' id="mail_domain" placeholder="<?php p('example.com')?>"
+ value='<?php p($_['mail_domain']) ?>' />
+ </p>
+
+ <p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
+ <label for="mail_smtpauthtype"><?php p($l->t( 'Authentification method' )); ?></label>
+ <select name='mail_smtpauthtype' id='mail_smtpauthtype'>
+ <?php foreach ($mail_smtpauthtype as $authtype => $name):
+ $selected = '';
+ if ($authtype == $_['mail_smtpauthtype']):
+ $selected = 'selected="selected"';
+ endif; ?>
+ <option value='<?php p($authtype)?>' <?php p($selected) ?>><?php p($name) ?></option>
+ <?php endforeach;?>
+ </select>
+
+ <input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" value="1"
+ <?php if ($_['mail_smtpauth']) print_unescaped('checked="checked"'); ?> />
+ <label for="mail_smtpauth"><?php p($l->t( 'Authentication required' )); ?></label>
+ </p>
+
+ <p id="setting_smtphost" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
+ <label for="mail_smtphost"><?php p($l->t( 'Server address' )); ?></label>
+ <input type="text" name='mail_smtphost' id="mail_smtphost" placeholder="<?php p('smtp.example.com')?>"
+ value='<?php p($_['mail_smtphost']) ?>' />
+ :
+ <input type="text" name='mail_smtpport' id="mail_smtpport" placeholder="<?php p($l->t('Port'))?>"
+ value='<?php p($_['mail_smtpport']) ?>' />
+ </p>
+
+ <p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
+ <label for="mail_smtpname"><?php p($l->t( 'Credentials' )); ?></label>
+ <input type="text" name='mail_smtpname' id="mail_smtpname" placeholder="<?php p($l->t('SMTP Username'))?>"
+ value='<?php p($_['mail_smtpname']) ?>' />
+ <input type="password" name='mail_smtppassword' id="mail_smtppassword"
+ placeholder="<?php p($l->t('SMTP Password'))?>" value='<?php p($_['mail_smtppassword']) ?>' />
+ </p>
+
+</fieldset>
+
<fieldset class="personalblock">
<h2><?php p($l->t('Log'));?></h2>
<?php p($l->t('Log level'));?> <select name='loglevel' id='loglevel'>