[Web] Restart SOGo after adding a new domain, fixes #864

This commit is contained in:
andre.peters
2018-01-11 22:40:43 +01:00
parent 0d8c7e446a
commit 278f1c2a37
6 changed files with 37 additions and 6 deletions

View File

@@ -13,6 +13,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/modals/footer.php';
<script src="/js/u2f-api.js"></script>
<script src="/js/api.js"></script>
<script>
var loading_text = '<?= $lang['footer']['loading']; ?>'
$(window).scroll(function() {
sessionStorage.scrollTop = $(this).scrollTop();
});
@@ -157,7 +158,7 @@ $(document).ready(function() {
}
})();
// Disable submit after submitting form
// Disable submit after submitting form (not API driven buttons)
$('form').submit(function() {
if ($('form button[type="submit"]').data('submitted') == '1') {
return false;

View File

@@ -333,6 +333,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
$aliases = $_data['aliases'];
$mailboxes = $_data['mailboxes'];
$maxquota = $_data['maxquota'];
$restart_sogo = $_data['restart_sogo'];
$quota = $_data['quota'];
if ($maxquota > $quota) {
$_SESSION['return'] = array(
@@ -416,10 +417,21 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
);
return false;
}
$_SESSION['return'] = array(
'type' => 'success',
'msg' => sprintf($lang['success']['domain_added'], htmlspecialchars($domain))
);
if (!empty($restart_sogo)) {
$restart_reponse = json_decode(docker('sogo-mailcow', 'post', 'restart'), true);
if ($restart_reponse['type'] == "success") {
$_SESSION['return'] = array(
'type' => 'success',
'msg' => sprintf($lang['success']['domain_added'], htmlspecialchars($domain))
);
}
else {
$_SESSION['return'] = array(
'type' => 'warning',
'msg' => 'Added domain but failed to restart SOGo, please check your server logs.'
);
}
}
}
catch (PDOException $e) {
mailbox('delete', 'domain', array('domain' => $domain));