From 14a9a1c616ae0a217cb53a3a86c9b84140bb0553 Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 11 May 2017 23:10:32 +0200 Subject: [PATCH] A lot of changes... still not finished, use with caution. Edit actions can be done with the internal API, trying to get rid of edit and add files --- data/web/add.php | 35 +- data/web/admin.php | 66 +- data/web/css/mailbox.css | 15 +- data/web/css/mailcow.css | 10 +- data/web/css/noty.css | 650 ------------ data/web/edit.php | 45 +- data/web/inc/footer.inc.php | 5 +- data/web/inc/functions.inc.php | 1791 ++++++++++++++++---------------- data/web/inc/vars.inc.php | 5 +- data/web/js/admin.js | 407 ++++---- data/web/js/mailbox.js | 704 +++++++------ data/web/js/notify.min.js | 1 - data/web/js/noty.min.js | 9 - data/web/json_api.php | 527 ++++++++-- data/web/lang/lang.de.php | 4 +- data/web/lang/lang.en.php | 2 +- data/web/mailbox.php | 75 +- data/web/user.php | 6 +- 18 files changed, 2095 insertions(+), 2262 deletions(-) delete mode 100644 data/web/css/noty.css delete mode 100644 data/web/js/notify.min.js delete mode 100644 data/web/js/noty.min.js diff --git a/data/web/add.php b/data/web/add.php index 5f1aa0d6..88e60b06 100644 --- a/data/web/add.php +++ b/data/web/add.php @@ -21,6 +21,9 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> + + +
@@ -61,9 +64,9 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
- +

@@ -71,7 +74,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
@@ -89,6 +92,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm

"> +
@@ -106,7 +110,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
@@ -122,6 +126,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> +
@@ -144,7 +149,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
@@ -160,6 +165,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> +
@@ -207,7 +213,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
@@ -223,6 +229,8 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> + +
@@ -254,14 +262,14 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
- +
@@ -285,6 +293,9 @@ elseif (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] ==

"> + + +
@@ -346,27 +357,27 @@ elseif (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] ==
- +
- +
- +
- +
diff --git a/data/web/admin.php b/data/web/admin.php index 9a7f2ba2..2d800622 100644 --- a/data/web/admin.php +++ b/data/web/admin.php @@ -100,6 +100,7 @@ $tfa_data = get_tfa();
+
@@ -134,7 +135,7 @@ $tfa_data = get_tfa();
- +
@@ -155,36 +156,39 @@ $tfa_data = get_tfa();
- +
+
+ + +
+
-
+
+

Domain:
Selector '' bit

-
+
-
- -
-
+
+

Domain:

-
-
-
 
+
-
-
+
+

↳ Alias-Domain:
Selector '' bit

-
+
-
- -
-
+
+

↳ Alias-Domain:

-
-
-
 
+
-
-
+
+

Domain:
Selector '' bit

-
+
-
- -
-
@@ -270,21 +269,20 @@ $tfa_data = get_tfa();

- -
- - -
-
-
-
+
+
+ +
- +
+
+
+

- +
diff --git a/data/web/css/mailbox.css b/data/web/css/mailbox.css index 2e6c1afe..8db97c31 100644 --- a/data/web/css/mailbox.css +++ b/data/web/css/mailbox.css @@ -13,21 +13,12 @@ table.footable>tbody>tr.footable-empty>td { } .footer-add-item { display:block; + text-align: center; + font-style: italic; padding: 10px; background: #F5F5F5; } -.mass-each-action { - padding: 0 3px 0 3px; - user-select: none; -} -.mass-actions { - user-select: none; - padding:10px; -} -.mass-select-all { - cursor:pointer; - color:#555; -} + #alias_table { cursor:pointer; } diff --git a/data/web/css/mailcow.css b/data/web/css/mailcow.css index 90dccf93..3978fcd9 100644 --- a/data/web/css/mailcow.css +++ b/data/web/css/mailcow.css @@ -62,4 +62,12 @@ body.modal-open { min-width: 350px; max-width: 550px; z-index: 2000; -} \ No newline at end of file +} +.mass-actions-mailbox { + user-select: none; + padding:10px 0 10px 10px; +} +.mass-actions-admin { + user-select: none; + padding:10px 0 10px 0; +} diff --git a/data/web/css/noty.css b/data/web/css/noty.css deleted file mode 100644 index 2df92f1f..00000000 --- a/data/web/css/noty.css +++ /dev/null @@ -1,650 +0,0 @@ -.noty_layout_mixin, #noty_layout__top, #noty_layout__topLeft, #noty_layout__topCenter, #noty_layout__topRight, #noty_layout__bottom, #noty_layout__bottomLeft, #noty_layout__bottomCenter, #noty_layout__bottomRight, #noty_layout__center, #noty_layout__centerLeft, #noty_layout__centerRight { - position: fixed; - margin: 0; - padding: 0; - z-index: 9999999; - -webkit-transform: translateZ(0) scale(1, 1); - transform: translateZ(0) scale(1, 1); - -webkit-backface-visibility: hidden; - backface-visibility: hidden; - -webkit-font-smoothing: subpixel-antialiased; - filter: blur(0); - -webkit-filter: blur(0); - max-width: 90%; } - -#noty_layout__top { - top: 0; - left: 5%; - width: 90%; } - -#noty_layout__topLeft { - top: 20px; - left: 20px; - width: 325px; } - -#noty_layout__topCenter { - top: 5%; - left: 50%; - width: 325px; - -webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__topRight { - top: 20px; - right: 20px; - width: 325px; } - -#noty_layout__bottom { - bottom: 0; - left: 5%; - width: 90%; } - -#noty_layout__bottomLeft { - bottom: 20px; - left: 20px; - width: 325px; } - -#noty_layout__bottomCenter { - bottom: 5%; - left: 50%; - width: 325px; - -webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__bottomRight { - bottom: 20px; - right: 20px; - width: 325px; } - -#noty_layout__center { - top: 50%; - left: 50%; - width: 325px; - -webkit-transform: translate(-webkit-calc(-50% - .5px), -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(calc(-50% - .5px), calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__centerLeft { - top: 50%; - left: 20px; - width: 325px; - -webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__centerRight { - top: 50%; - right: 20px; - width: 325px; - -webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -.noty_progressbar { - display: none; } - -.noty_has_timeout .noty_progressbar { - display: block; - position: absolute; - left: 0; - bottom: 0; - height: 3px; - width: 100%; - background-color: #646464; - opacity: 0.2; - filter: alpha(opacity=10); } - -.noty_bar { - -webkit-backface-visibility: hidden; - -webkit-transform: translate(0, 0) translateZ(0) scale(1, 1); - -ms-transform: translate(0, 0) scale(1, 1); - transform: translate(0, 0) scale(1, 1); - -webkit-font-smoothing: subpixel-antialiased; - overflow: hidden; } - -.noty_effects_open { - opacity: 0; - -webkit-transform: translate(50%); - -ms-transform: translate(50%); - transform: translate(50%); - -webkit-animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; } - -.noty_effects_close { - -webkit-animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; } - -.noty_fix_effects_height { - -webkit-animation: noty_anim_height 75ms ease-out; - animation: noty_anim_height 75ms ease-out; } - -.noty_close_with_click { - cursor: pointer; } - -.noty_close_button { - position: absolute; - top: 2px; - right: 2px; - font-weight: bold; - width: 20px; - height: 20px; - text-align: center; - line-height: 20px; - background-color: rgba(0, 0, 0, 0.05); - border-radius: 2px; - cursor: pointer; - -webkit-transition: all .2s ease-out; - transition: all .2s ease-out; } - -.noty_close_button:hover { - background-color: rgba(0, 0, 0, 0.1); } - -.noty_modal { - position: fixed; - width: 100%; - height: 100%; - background-color: #000; - z-index: 10000; - opacity: .3; - left: 0; - top: 0; } - -.noty_modal.noty_modal_open { - opacity: 0; - -webkit-animation: noty_modal_in .3s ease-out; - animation: noty_modal_in .3s ease-out; } - -.noty_modal.noty_modal_close { - -webkit-animation: noty_modal_out .3s ease-out; - animation: noty_modal_out .3s ease-out; - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; } - -@-webkit-keyframes noty_modal_in { - 100% { - opacity: .3; } } - -@keyframes noty_modal_in { - 100% { - opacity: .3; } } - -@-webkit-keyframes noty_modal_out { - 100% { - opacity: 0; } } - -@keyframes noty_modal_out { - 100% { - opacity: 0; } } - -@keyframes noty_modal_out { - 100% { - opacity: 0; } } - -@-webkit-keyframes noty_anim_in { - 100% { - -webkit-transform: translate(0); - transform: translate(0); - opacity: 1; } } - -@keyframes noty_anim_in { - 100% { - -webkit-transform: translate(0); - transform: translate(0); - opacity: 1; } } - -@-webkit-keyframes noty_anim_out { - 100% { - -webkit-transform: translate(50%); - transform: translate(50%); - opacity: 0; } } - -@keyframes noty_anim_out { - 100% { - -webkit-transform: translate(50%); - transform: translate(50%); - opacity: 0; } } - -@-webkit-keyframes noty_anim_height { - 100% { - height: 0; } } - -@keyframes noty_anim_height { - 100% { - height: 0; } } - -.noty_theme__relax.noty_bar { - margin: 4px 0; - overflow: hidden; - border-radius: 2px; - position: relative; } - .noty_theme__relax.noty_bar .noty_body { - padding: 10px; } - .noty_theme__relax.noty_bar .noty_buttons { - border-top: 1px solid #e7e7e7; - padding: 5px 10px; } - -.noty_theme__relax.noty_type__alert, -.noty_theme__relax.noty_type__notification { - background-color: #fff; - border: 1px solid #dedede; - color: #444; } - -.noty_theme__relax.noty_type__warning { - background-color: #FFEAA8; - border: 1px solid #FFC237; - color: #826200; } - .noty_theme__relax.noty_type__warning .noty_buttons { - border-color: #dfaa30; } - -.noty_theme__relax.noty_type__error { - background-color: #FF8181; - border: 1px solid #e25353; - color: #FFF; } - .noty_theme__relax.noty_type__error .noty_buttons { - border-color: darkred; } - -.noty_theme__relax.noty_type__info, -.noty_theme__relax.noty_type__information { - background-color: #78C5E7; - border: 1px solid #3badd6; - color: #FFF; } - .noty_theme__relax.noty_type__info .noty_buttons, - .noty_theme__relax.noty_type__information .noty_buttons { - border-color: #0B90C4; } - -.noty_theme__relax.noty_type__success { - background-color: #BCF5BC; - border: 1px solid #7cdd77; - color: darkgreen; } - .noty_theme__relax.noty_type__success .noty_buttons { - border-color: #50C24E; } - -.noty_theme__metroui.noty_bar { - margin: 4px 0; - overflow: hidden; - position: relative; - box-shadow: rgba(0, 0, 0, 0.298039) 0 0 5px 0; } - .noty_theme__metroui.noty_bar .noty_progressbar { - position: absolute; - left: 0; - bottom: 0; - height: 3px; - width: 100%; - background-color: #000; - opacity: 0.2; - filter: alpha(opacity=20); } - .noty_theme__metroui.noty_bar .noty_body { - padding: 1.25em; - font-size: 14px; } - .noty_theme__metroui.noty_bar .noty_buttons { - padding: 0 10px .5em 10px; } - -.noty_theme__metroui.noty_type__alert, -.noty_theme__metroui.noty_type__notification { - background-color: #fff; - color: #1d1d1d; } - -.noty_theme__metroui.noty_type__warning { - background-color: #FA6800; - color: #fff; } - -.noty_theme__metroui.noty_type__error { - background-color: #CE352C; - color: #FFF; } - -.noty_theme__metroui.noty_type__info, -.noty_theme__metroui.noty_type__information { - background-color: #1BA1E2; - color: #FFF; } - -.noty_theme__metroui.noty_type__success { - background-color: #60A917; - color: #fff; } - -.noty_theme__mint.noty_bar { - margin: 4px 0; - overflow: hidden; - border-radius: 2px; - position: relative; } - .noty_theme__mint.noty_bar .noty_body { - padding: 10px; - font-size: 14px; } - .noty_theme__mint.noty_bar .noty_buttons { - padding: 10px; } - -.noty_theme__mint.noty_type__alert, -.noty_theme__mint.noty_type__notification { - background-color: #fff; - border-bottom: 1px solid #D1D1D1; - color: #2F2F2F; } - -.noty_theme__mint.noty_type__warning { - background-color: #FFAE42; - border-bottom: 1px solid #E89F3C; - color: #fff; } - -.noty_theme__mint.noty_type__error { - background-color: #DE636F; - border-bottom: 1px solid #CA5A65; - color: #fff; } - -.noty_theme__mint.noty_type__info, -.noty_theme__mint.noty_type__information { - background-color: #7F7EFF; - border-bottom: 1px solid #7473E8; - color: #fff; } - -.noty_theme__mint.noty_type__success { - background-color: #AFC765; - border-bottom: 1px solid #A0B55C; - color: #fff; } - -.noty_theme__sunset.noty_bar { - margin: 4px 0; - overflow: hidden; - border-radius: 2px; - position: relative; } - .noty_theme__sunset.noty_bar .noty_body { - padding: 10px; - font-size: 14px; - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); } - .noty_theme__sunset.noty_bar .noty_buttons { - padding: 10px; } - -.noty_theme__sunset.noty_type__alert, -.noty_theme__sunset.noty_type__notification { - background-color: #073B4C; - color: #fff; } - .noty_theme__sunset.noty_type__alert .noty_progressbar, - .noty_theme__sunset.noty_type__notification .noty_progressbar { - background-color: #fff; } - -.noty_theme__sunset.noty_type__warning { - background-color: #FFD166; - color: #fff; } - -.noty_theme__sunset.noty_type__error { - background-color: #EF476F; - color: #fff; } - .noty_theme__sunset.noty_type__error .noty_progressbar { - opacity: .4; } - -.noty_theme__sunset.noty_type__info, -.noty_theme__sunset.noty_type__information { - background-color: #118AB2; - color: #fff; } - .noty_theme__sunset.noty_type__info .noty_progressbar, - .noty_theme__sunset.noty_type__information .noty_progressbar { - opacity: .6; } - -.noty_theme__sunset.noty_type__success { - background-color: #06D6A0; - color: #fff; } - -.noty_theme__bootstrap-v3.noty_bar { - margin: 4px 0; - overflow: hidden; - position: relative; - border: 1px solid transparent; - border-radius: 4px; } - .noty_theme__bootstrap-v3.noty_bar .noty_body { - padding: 15px; } - .noty_theme__bootstrap-v3.noty_bar .noty_buttons { - padding: 10px; } - .noty_theme__bootstrap-v3.noty_bar .noty_close_button { - font-size: 21px; - font-weight: 700; - line-height: 1; - color: #000; - text-shadow: 0 1px 0 #fff; - filter: alpha(opacity=20); - opacity: .2; - background: transparent; } - .noty_theme__bootstrap-v3.noty_bar .noty_close_button:hover { - background: transparent; - text-decoration: none; - cursor: pointer; - filter: alpha(opacity=50); - opacity: .5; } - -.noty_theme__bootstrap-v3.noty_type__alert, -.noty_theme__bootstrap-v3.noty_type__notification { - background-color: #fff; - color: inherit; } - -.noty_theme__bootstrap-v3.noty_type__warning { - background-color: #fcf8e3; - color: #8a6d3b; - border-color: #faebcc; } - -.noty_theme__bootstrap-v3.noty_type__error { - background-color: #f2dede; - color: #a94442; - border-color: #ebccd1; } - -.noty_theme__bootstrap-v3.noty_type__info, -.noty_theme__bootstrap-v3.noty_type__information { - background-color: #d9edf7; - color: #31708f; - border-color: #bce8f1; } - -.noty_theme__bootstrap-v3.noty_type__success { - background-color: #dff0d8; - color: #3c763d; - border-color: #d6e9c6; } - -.noty_theme__bootstrap-v4.noty_bar { - margin: 4px 0; - overflow: hidden; - position: relative; - border: 1px solid transparent; - border-radius: .25rem; } - .noty_theme__bootstrap-v4.noty_bar .noty_body { - padding: .75rem 1.25rem; } - .noty_theme__bootstrap-v4.noty_bar .noty_buttons { - padding: 10px; } - .noty_theme__bootstrap-v4.noty_bar .noty_close_button { - font-size: 1.5rem; - font-weight: 700; - line-height: 1; - color: #000; - text-shadow: 0 1px 0 #fff; - filter: alpha(opacity=20); - opacity: .5; - background: transparent; } - .noty_theme__bootstrap-v4.noty_bar .noty_close_button:hover { - background: transparent; - text-decoration: none; - cursor: pointer; - filter: alpha(opacity=50); - opacity: .75; } - -.noty_theme__bootstrap-v4.noty_type__alert, -.noty_theme__bootstrap-v4.noty_type__notification { - background-color: #fff; - color: inherit; } - -.noty_theme__bootstrap-v4.noty_type__warning { - background-color: #fcf8e3; - color: #8a6d3b; - border-color: #faebcc; } - -.noty_theme__bootstrap-v4.noty_type__error { - background-color: #f2dede; - color: #a94442; - border-color: #ebccd1; } - -.noty_theme__bootstrap-v4.noty_type__info, -.noty_theme__bootstrap-v4.noty_type__information { - background-color: #d9edf7; - color: #31708f; - border-color: #bce8f1; } - -.noty_theme__bootstrap-v4.noty_type__success { - background-color: #dff0d8; - color: #3c763d; - border-color: #d6e9c6; } - -.noty_theme__semanticui.noty_bar { - margin: 4px 0; - overflow: hidden; - position: relative; - border: 1px solid transparent; - font-size: 1em; - border-radius: .28571429rem; - box-shadow: 0 0 0 1px rgba(34, 36, 38, 0.22) inset, 0 0 0 0 transparent; } - .noty_theme__semanticui.noty_bar .noty_body { - padding: 1em 1.5em; - line-height: 1.4285em; } - .noty_theme__semanticui.noty_bar .noty_buttons { - padding: 10px; } - -.noty_theme__semanticui.noty_type__alert, -.noty_theme__semanticui.noty_type__notification { - background-color: #f8f8f9; - color: rgba(0, 0, 0, 0.87); } - -.noty_theme__semanticui.noty_type__warning { - background-color: #fffaf3; - color: #573a08; - box-shadow: 0 0 0 1px #c9ba9b inset, 0 0 0 0 transparent; } - -.noty_theme__semanticui.noty_type__error { - background-color: #fff6f6; - color: #9f3a38; - box-shadow: 0 0 0 1px #e0b4b4 inset, 0 0 0 0 transparent; } - -.noty_theme__semanticui.noty_type__info, -.noty_theme__semanticui.noty_type__information { - background-color: #f8ffff; - color: #276f86; - box-shadow: 0 0 0 1px #a9d5de inset, 0 0 0 0 transparent; } - -.noty_theme__semanticui.noty_type__success { - background-color: #fcfff5; - color: #2c662d; - box-shadow: 0 0 0 1px #a3c293 inset, 0 0 0 0 transparent; } - -.noty_theme__nest.noty_bar { - margin: 0 0 15px 0; - overflow: hidden; - border-radius: 2px; - position: relative; - box-shadow: rgba(0, 0, 0, 0.098039) 5px 4px 10px 0; } - .noty_theme__nest.noty_bar .noty_body { - padding: 10px; - font-size: 14px; - text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); } - .noty_theme__nest.noty_bar .noty_buttons { - padding: 10px; } - -.noty_layout .noty_theme__nest.noty_bar { - z-index: 5; } - -.noty_layout .noty_theme__nest.noty_bar:nth-child(2) { - position: absolute; - top: 0; - margin-top: 4px; - margin-right: -4px; - margin-left: 4px; - z-index: 4; - width: 100%; } - -.noty_layout .noty_theme__nest.noty_bar:nth-child(3) { - position: absolute; - top: 0; - margin-top: 8px; - margin-right: -8px; - margin-left: 8px; - z-index: 3; - width: 100%; } - -.noty_layout .noty_theme__nest.noty_bar:nth-child(4) { - position: absolute; - top: 0; - margin-top: 12px; - margin-right: -12px; - margin-left: 12px; - z-index: 2; - width: 100%; } - -.noty_layout .noty_theme__nest.noty_bar:nth-child(5) { - position: absolute; - top: 0; - margin-top: 16px; - margin-right: -16px; - margin-left: 16px; - z-index: 1; - width: 100%; } - -.noty_layout .noty_theme__nest.noty_bar:nth-child(n+6) { - position: absolute; - top: 0; - margin-top: 20px; - margin-right: -20px; - margin-left: 20px; - z-index: -1; - width: 100%; } - -#noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(2), -#noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(2) { - margin-top: 4px; - margin-left: -4px; - margin-right: 4px; } - -#noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(3), -#noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(3) { - margin-top: 8px; - margin-left: -8px; - margin-right: 8px; } - -#noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(4), -#noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(4) { - margin-top: 12px; - margin-left: -12px; - margin-right: 12px; } - -#noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(5), -#noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(5) { - margin-top: 16px; - margin-left: -16px; - margin-right: 16px; } - -#noty_layout__bottomLeft .noty_theme__nest.noty_bar:nth-child(n+6), -#noty_layout__topLeft .noty_theme__nest.noty_bar:nth-child(n+6) { - margin-top: 20px; - margin-left: -20px; - margin-right: 20px; } - -.noty_theme__nest.noty_type__alert, -.noty_theme__nest.noty_type__notification { - background-color: #073B4C; - color: #fff; } - .noty_theme__nest.noty_type__alert .noty_progressbar, - .noty_theme__nest.noty_type__notification .noty_progressbar { - background-color: #fff; } - -.noty_theme__nest.noty_type__warning { - background-color: #FFD166; - color: #fff; } - -.noty_theme__nest.noty_type__error { - background-color: #EF476F; - color: #fff; } - .noty_theme__nest.noty_type__error .noty_progressbar { - opacity: .4; } - -.noty_theme__nest.noty_type__info, -.noty_theme__nest.noty_type__information { - background-color: #118AB2; - color: #fff; } - .noty_theme__nest.noty_type__info .noty_progressbar, - .noty_theme__nest.noty_type__information .noty_progressbar { - opacity: .6; } - -.noty_theme__nest.noty_type__success { - background-color: #06D6A0; - color: #fff; } - -/*# sourceMappingURL=noty.css.map*/ \ No newline at end of file diff --git a/data/web/edit.php b/data/web/edit.php index 3f3311d0..1532d06b 100644 --- a/data/web/edit.php +++ b/data/web/edit.php @@ -26,6 +26,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm


"> +
@@ -36,7 +37,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
@@ -66,6 +67,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm


"> +
@@ -107,14 +109,14 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
- +
@@ -141,6 +143,9 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> + + +
@@ -179,9 +184,9 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
- +

@@ -192,7 +197,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
@@ -350,17 +355,18 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> - + +
- +
- +
- +
@@ -398,6 +404,8 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> + +
@@ -481,7 +489,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
@@ -501,6 +509,8 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm ?>

"> + +
@@ -521,14 +531,14 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
- +
- +
@@ -561,6 +571,9 @@ elseif (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == ?>

"> + + +
@@ -623,21 +636,21 @@ elseif (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] ==
- +
- +
- +
diff --git a/data/web/inc/footer.inc.php b/data/web/inc/footer.inc.php index 08fd6d00..d809a160 100644 --- a/data/web/inc/footer.inc.php +++ b/data/web/inc/footer.inc.php @@ -226,12 +226,15 @@ $(document).ready(function() { } }); }); + + if ($('#mailcow-alert').hasClass('alert-success')) { + $('#mailcow-alert').delay(5000).animate({right: '-50%'}, 1000); + }; });
diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index ac99a014..7d1594ad 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -733,9 +733,9 @@ function add_policy_list_item($postarray) { // If 'delete_prefid' then delete item id global $lang; global $pdo; - (isset($postarray['username'])) ? $object = $postarray['username'] : null; - (isset($postarray['domain'])) ? $object = $postarray['domain'] : null; - (!isset($object)) ? $object = $_SESSION['mailcow_cc_username'] : null; + $object = (isset($postarray['username'])) ? $postarray['username'] : null; + $object = (isset($postarray['domain'])) ? $postarray['domain'] : null; + (!isset($object)) ? $object = $_SESSION['mailcow_cc_username'] : null; if (is_valid_domain_name($object)) { if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $object)) { @@ -826,9 +826,9 @@ function delete_policy_list_item($postarray) { // 'delete_prefid' is item to be deleted global $lang; global $pdo; - (isset($postarray['username'])) ? $object = $postarray['username'] : null; - (isset($postarray['domain'])) ? $object = $postarray['domain'] : null; - (!isset($object)) ? $object = $_SESSION['mailcow_cc_username'] : null; + $object = (isset($postarray['username'])) ? $postarray['username'] : null; + $object = (isset($postarray['domain'])) ? $postarray['domain'] : null; + (!isset($object)) ? $object = $_SESSION['mailcow_cc_username'] : null; if (is_valid_domain_name($object)) { if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $object)) { @@ -1010,9 +1010,10 @@ function add_syncjob($postarray) { else { $username = $_SESSION['mailcow_cc_username']; } - isset($postarray['active']) ? $active = '1' : $active = '0'; - isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0'; - isset($postarray['delete1']) ? $delete1 = '1' : $delete1 = '0'; + + $active = intval($postarray['active']); + $delete2duplicates = intval($postarray['delete2duplicates']); + $delete1 = intval($postarray['delete1']); $port1 = $postarray['port1']; $host1 = $postarray['host1']; $password1 = $postarray['password1']; @@ -1137,9 +1138,10 @@ function edit_syncjob($postarray) { else { $username = $_SESSION['mailcow_cc_username']; } - isset($postarray['active']) ? $active = '1' : $active = '0'; - isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0'; - isset($postarray['delete1']) ? $delete1 = '1' : $delete1 = '0'; + + $active = intval($postarray['active']); + $delete2duplicates = intval($postarray['delete2duplicates']); + $delete1 = intval($postarray['delete1']); $id = $postarray['id']; $port1 = $postarray['port1']; $host1 = $postarray['host1']; @@ -1263,8 +1265,8 @@ function edit_tls_policy($postarray) { else { $username = $_SESSION['mailcow_cc_username']; } - isset($postarray['tls_in']) ? $tls_in = '1' : $tls_in = '0'; - isset($postarray['tls_out']) ? $tls_out = '1' : $tls_out = '0'; + $tls_out = intval($postarray['tls_out']); + $tls_in = intval($postarray['tls_in']); $username = $_SESSION['mailcow_cc_username']; if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { $_SESSION['return'] = array( @@ -1480,7 +1482,8 @@ function add_domain_admin($postarray) { $username = strtolower(trim($postarray['username'])); $password = $postarray['password']; $password2 = $postarray['password2']; - isset($postarray['active']) ? $active = '1' : $active = '0'; + $active = intval($postarray['active']); + if ($_SESSION['mailcow_cc_role'] != "admin") { $_SESSION['return'] = array( 'type' => 'danger', @@ -1793,7 +1796,7 @@ function set_tfa($postarray) { switch ($postarray["tfa_method"]) { case "yubi_otp": - (!isset($postarray["key_id"])) ? $key_id = 'unidentified' : $key_id = $postarray["key_id"]; + $key_id = (!isset($postarray["key_id"])) ? 'unidentified' : $postarray["key_id"]; $yubico_id = $postarray['yubico_id']; $yubico_key = $postarray['yubico_key']; $yubi = new Auth_Yubico($yubico_id, $yubico_key); @@ -1845,8 +1848,8 @@ function set_tfa($postarray) { break; case "u2f": + $key_id = (!isset($postarray["key_id"])) ? 'unidentified' : $postarray["key_id"]; try { - (!isset($postarray["key_id"])) ? $key_id = 'unidentified' : $key_id = $postarray["key_id"]; $reg = $u2f->doRegister(json_decode($_SESSION['regReq']), json_decode($postarray['token'])); $stmt = $pdo->prepare("DELETE FROM `tfa` WHERE `username` = :username AND `authmech` != 'u2f'"); $stmt->execute(array(':username' => $username)); @@ -1869,7 +1872,7 @@ function set_tfa($postarray) { break; case "totp": - (!isset($postarray["key_id"])) ? $key_id = 'unidentified' : $key_id = $postarray["key_id"]; + $key_id = (!isset($postarray["key_id"])) ? 'unidentified' : $postarray["key_id"]; if ($tfa->verifyCode($_POST['totp_secret'], $_POST['totp_confirm_token']) === true) { try { $stmt = $pdo->prepare("DELETE FROM `tfa` WHERE `username` = :username"); @@ -2139,7 +2142,7 @@ function edit_domain_admin($postarray) { $username_now = $postarray['username_now']; $password = $postarray['password']; $password2 = $postarray['password2']; - isset($postarray['active']) ? $active = '1' : $active = '0'; + $active = intval($postarray['active']); if(isset($postarray['domain'])) { foreach ($postarray['domain'] as $domain) { @@ -2520,11 +2523,10 @@ function dkim_delete_key($postarray) { return false; } try { - foreach ($redis->hGetAll('DKIM_SELECTORS') as $domain_name => $selector) { - $redis->hDel('DKIM_PUB_KEYS', $domain_name); - $redis->hDel('DKIM_PRIV_KEYS', $selector . '.' . $domain_name); - $redis->hDel('DKIM_SELECTORS', $domain_name); - } + $selector = $redis->hGet('DKIM_SELECTORS', $domain); + $redis->hDel('DKIM_PUB_KEYS', $domain); + $redis->hDel('DKIM_PRIV_KEYS', $selector . '.' . $domain); + $redis->hDel('DKIM_SELECTORS', $selector); } catch (RedisException $e) { $_SESSION['return'] = array( @@ -2536,7 +2538,7 @@ function dkim_delete_key($postarray) { } $_SESSION['return'] = array( 'type' => 'success', - 'msg' => sprintf($lang['success']['dkim_removed']) + 'msg' => sprintf($lang['success']['dkim_removed'], htmlspecialchars(implode(', ', $domains))) ); return true; } @@ -2584,10 +2586,10 @@ function mailbox_add_domain($postarray) { return false; } - isset($postarray['active']) ? $active = '1' : $active = '0'; - isset($postarray['relay_all_recipients']) ? $relay_all_recipients = '1' : $relay_all_recipients = '0'; - isset($postarray['backupmx']) ? $backupmx = '1' : $backupmx = '0'; - isset($postarray['relay_all_recipients']) ? $backupmx = '1' : true; + $active = intval($postarray['active']); + $relay_all_recipients = intval($postarray['relay_all_recipients']); + $backupmx = intval($postarray['backupmx']); + ($relay_all_recipients == 1) ? $backupmx = '1' : null; if (!is_valid_domain_name($domain)) { $_SESSION['return'] = array( @@ -2679,7 +2681,7 @@ function mailbox_add_alias($postarray) { global $pdo; $addresses = array_map('trim', preg_split( "/( |,|;|\n)/", $postarray['address'])); $gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $postarray['goto'])); - isset($postarray['active']) ? $active = '1' : $active = '0'; + $active = intval($postarray['active']); if (empty($addresses[0])) { $_SESSION['return'] = array( 'type' => 'danger', @@ -2695,24 +2697,23 @@ function mailbox_add_alias($postarray) { ); return false; } - - $stmt = $pdo->prepare("SELECT `address` FROM `alias` - WHERE `address`= :address"); - $stmt->execute(array(':address' => $address)); - $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); - if ($num_results != 0) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['is_alias_or_mailbox'], htmlspecialchars($address)) - ); - return false; - } - foreach ($addresses as $address) { if (empty($address)) { continue; } + $stmt = $pdo->prepare("SELECT `address` FROM `alias` + WHERE `address`= :address"); + $stmt->execute(array(':address' => $address)); + $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); + if ($num_results != 0) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['is_alias_or_mailbox'], htmlspecialchars($address)) + ); + return false; + } + $domain = idn_to_ascii(substr(strstr($address, '@'), 1)); $local_part = strstr($address, '@', true); $address = $local_part.'@'.$domain; @@ -2725,7 +2726,7 @@ function mailbox_add_alias($postarray) { ); return false; } - + try { $stmt = $pdo->prepare("SELECT `domain` FROM `domain` WHERE `domain`= :domain1 OR `domain` = (SELECT `target_domain` FROM `alias_domain` WHERE `alias_domain` = :domain2)"); @@ -2734,7 +2735,7 @@ function mailbox_add_alias($postarray) { if ($num_results == 0) { $_SESSION['return'] = array( 'type' => 'danger', - 'msg' => sprintf($lang['danger']['domain_not_found'], $domain) + 'msg' => sprintf($lang['danger']['domain_not_found'], htmlspecialchars($domain)) ); return false; } @@ -2874,7 +2875,7 @@ function mailbox_add_alias_domain($postarray) { // target_domain string global $lang; global $pdo; - isset($postarray['active']) ? $active = '1' : $active = '0'; + $active = intval($postarray['active']); $alias_domain = idn_to_ascii(strtolower(trim($postarray['alias_domain']))); $target_domain = idn_to_ascii(strtolower(trim($postarray['target_domain']))); @@ -3005,7 +3006,7 @@ function mailbox_add_mailbox($postarray) { $name = $local_part; } - isset($postarray['active']) ? $active = '1' : $active = '0'; + $active = intval($postarray['active']); $quota_b = ($quota_m * 1048576); $maildir = $domain."/".$local_part."/"; @@ -3207,8 +3208,8 @@ function mailbox_add_resource($postarray) { $local_part = preg_replace('/[^\da-z]/i', '', preg_quote($description, '/')); $name = $local_part . '@' . $domain; $kind = $postarray['kind']; - isset($postarray['active']) ? $active = '1' : $active = '0'; - isset($postarray['multiple_bookings']) ? $multiple_bookings = '1' : $multiple_bookings = '0'; + $active = intval($postarray['active']); + $multiple_bookings = intval($postarray['multiple_bookings']); if (!filter_var($name, FILTER_VALIDATE_EMAIL)) { $_SESSION['return'] = array( @@ -3331,95 +3332,75 @@ function mailbox_add_resource($postarray) { } } function mailbox_edit_alias_domain($postarray) { - // Array elements - // active int - // alias_domain_now string - // alias_domain string + // active int + // target_domain string + // alias_domain string/array of strings global $lang; global $pdo; - isset($postarray['active']) ? $active = '1' : $active = '0'; - $alias_domain = idn_to_ascii(strtolower(trim($postarray['alias_domain']))); - $alias_domain_now = strtolower(trim($postarray['alias_domain_now'])); - if (!is_valid_domain_name($alias_domain)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['alias_domain_invalid']) - ); - return false; - } - - if (!is_valid_domain_name($alias_domain_now)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['alias_domain_invalid']) - ); - return false; - } - - try { - $stmt = $pdo->prepare("SELECT `target_domain` FROM `alias_domain` - WHERE `alias_domain`= :alias_domain_now"); - $stmt->execute(array(':alias_domain_now' => $alias_domain_now)); - $DomainData = $stmt->fetch(PDO::FETCH_ASSOC); - } - catch(PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $DomainData['target_domain'])) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; - } - - try { - $stmt = $pdo->prepare("SELECT `target_domain` FROM `alias_domain` - WHERE `target_domain`= :alias_domain"); - $stmt->execute(array(':alias_domain' => $alias_domain)); - $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); - } - catch(PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - if ($num_results != 0) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['aliasd_targetd_identical']) - ); - return false; - } - - try { - $stmt = $pdo->prepare("UPDATE `alias_domain` SET - `alias_domain` = :alias_domain, - `active` = :active - WHERE `alias_domain` = :alias_domain_now"); - $stmt->execute(array( - ':alias_domain' => $alias_domain, - ':alias_domain_now' => $alias_domain_now, - ':active' => $active - )); - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - + if (!is_array($postarray['alias_domain'])) { + $alias_domains = array(); + $alias_domains[] = $postarray['alias_domain']; + } + else { + $alias_domains = $postarray['alias_domain']; + } + foreach ($alias_domains as $alias_domain) { + $alias_domain = idn_to_ascii(strtolower(trim($alias_domain))); + $is_now = mailbox_get_alias_domain_details($alias_domain); + if (!empty($is_now)) { + $active = (isset($postarray['active'])) ? $postarray['active'] : $is_now['active_int']; + $target_domain = (!empty($postarray['target_domain'])) ? idn_to_ascii(strtolower(trim($postarray['target_domain']))) : $is_now['target_domain']; + } + else { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['alias_domain_invalid']) + ); + return false; + } + if (!is_valid_domain_name($target_domain)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['target_domain_invalid']) + ); + return false; + } + if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $target_domain)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } + if (empty(mailbox_get_domain_details($target_domain))) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['target_domain_invalid']) + ); + return false; + } + try { + $stmt = $pdo->prepare("UPDATE `alias_domain` SET + `target_domain` = :target_domain, + `active` = :active + WHERE `alias_domain` = :alias_domain"); + $stmt->execute(array( + ':alias_domain' => $alias_domain, + ':target_domain' => $target_domain, + ':active' => $active + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + } $_SESSION['return'] = array( 'type' => 'success', - 'msg' => sprintf($lang['success']['aliasd_modified'], htmlspecialchars($alias_domain)) + 'msg' => sprintf($lang['success']['aliasd_modified'], htmlspecialchars(implode(', ', $alias_domains))) ); } function mailbox_edit_alias($postarray) { @@ -3430,13 +3411,26 @@ function mailbox_edit_alias($postarray) { global $lang; global $pdo; if (!is_array($postarray['address'])) { - $address_array = array(); - $address_array[] = $postarray['address']; + $addresses = array(); + $addresses[] = $postarray['address']; } else { - $address_array = $postarray['address']; + $addresses = $postarray['address']; } - if (isset($postarray['goto']) || !empty($postarray['goto'])) { + foreach ($addresses as $address) { + $is_now = mailbox_get_alias_details($address); + if (!empty($is_now)) { + $active = (isset($postarray['active'])) ? $postarray['active'] : $is_now['active_int']; + $goto = (!empty($postarray['goto'])) ? $postarray['goto'] : $is_now['goto']; + } + else { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['alias_invalid']) + ); + return false; + } + $gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $postarray['goto'])); foreach ($gotos as &$goto) { if (empty($goto)) { @@ -3459,11 +3453,10 @@ function mailbox_edit_alias($postarray) { } $gotos = array_filter($gotos); $goto = implode(",", $gotos); - } - isset($postarray['active']) ? $active = '1' : $active = '0'; - foreach ($address_array as $address) { - $domain = idn_to_ascii(substr(strstr($address, '@'), 1)); - $local_part = strstr($address, '@', true); + + $domain = idn_to_ascii(substr(strstr($address, '@'), 1)); + $local_part = strstr($address, '@', true); + if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) { $_SESSION['return'] = array( 'type' => 'danger', @@ -3471,6 +3464,7 @@ function mailbox_edit_alias($postarray) { ); return false; } + if ((!filter_var($address, FILTER_VALIDATE_EMAIL) === true) && !empty($local_part)) { $_SESSION['return'] = array( 'type' => 'danger', @@ -3478,8 +3472,9 @@ function mailbox_edit_alias($postarray) { ); return false; } + try { - if (isset($goto) && !empty($goto)) { + if (!empty($goto)) { $stmt = $pdo->prepare("UPDATE `alias` SET `goto` = :goto, `active`= :active @@ -3510,7 +3505,7 @@ function mailbox_edit_alias($postarray) { } $_SESSION['return'] = array( 'type' => 'success', - 'msg' => sprintf($lang['success']['alias_modified'], htmlspecialchars(implode(', ', $address_array))) + 'msg' => sprintf($lang['success']['alias_modified'], htmlspecialchars(implode(', ', $addresses))) ); } function mailbox_edit_domain($postarray) { @@ -3529,68 +3524,220 @@ function mailbox_edit_domain($postarray) { global $lang; global $pdo; - $domain = idn_to_ascii($postarray['domain']); - if (!is_valid_domain_name($domain)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['domain_invalid']) - ); - return false; - } - - if ($_SESSION['mailcow_cc_role'] == "domainadmin" && hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) { - $description = $postarray['description']; - isset($postarray['active']) ? $active = '1' : $active = '0'; - try { - $stmt = $pdo->prepare("UPDATE `domain` SET - `description` = :description - WHERE `domain` = :domain"); - $stmt->execute(array( - ':description' => $description, - ':domain' => $domain - )); - $_SESSION['return'] = array( - 'type' => 'success', - 'msg' => sprintf($lang['success']['domain_modified'], htmlspecialchars($domain)) - ); - } - catch (PDOException $e) { + if (!is_array($postarray['domain'])) { + $domains = array(); + $domains[] = $postarray['domain']; + } + else { + $domains = $postarray['domain']; + } + foreach ($domains as $domain) { + $domain = idn_to_ascii($domain); + if (!is_valid_domain_name($domain)) { $_SESSION['return'] = array( 'type' => 'danger', - 'msg' => 'MySQL: '.$e + 'msg' => sprintf($lang['danger']['domain_invalid']) ); return false; } + if ($_SESSION['mailcow_cc_role'] == "domainadmin" && + hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) { + $description = $postarray['description']; + $active = intval($postarray['active']); + try { + $stmt = $pdo->prepare("UPDATE `domain` SET + `description` = :description + WHERE `domain` = :domain"); + $stmt->execute(array( + ':description' => $description, + ':domain' => $domain + )); + $_SESSION['return'] = array( + 'type' => 'success', + 'msg' => sprintf($lang['success']['domain_modified'], htmlspecialchars($domain)) + ); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + } + elseif ($_SESSION['mailcow_cc_role'] == "admin") { + $is_now = mailbox_get_domain_details($domain); + if (!empty($is_now)) { + $active = (isset($postarray['active'])) ? $postarray['active'] : $is_now['active_int']; + $backupmx = (isset($postarray['backupmx'])) ? $postarray['backupmx'] : $is_now['backupmx_int']; + $relay_all_recipients = (isset($postarray['relay_all_recipients'])) ? $postarray['relay_all_recipients'] : $is_now['relay_all_recipients_int']; + $aliases = (!empty($postarray['aliases'])) ? $postarray['aliases'] : $is_now['max_num_aliases_for_domain']; + $mailboxes = (!empty($postarray['mailboxes'])) ? $postarray['mailboxes'] : $is_now['max_num_mboxes_for_domain']; + $maxquota = (!empty($postarray['maxquota'])) ? $postarray['maxquota'] : ($is_now['max_new_mailbox_quota'] / 1048576); + $quota = (!empty($postarray['quota'])) ? $postarray['quota'] : ($is_now['max_quota_for_domain'] / 1048576); + $description = (!empty($postarray['description'])) ? $postarray['description'] : $is_now['description']; + ($relay_all_recipients == '1') ? $backupmx = '1' : null; + } + else { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['domain_invalid']) + ); + return false; + } + try { + // todo: should be using api here + $stmt = $pdo->prepare("SELECT + COUNT(*) AS count, + MAX(COALESCE(ROUND(`quota`/1048576), 0)) AS `biggest_mailbox`, + COALESCE(ROUND(SUM(`quota`)/1048576), 0) AS `quota_all` + FROM `mailbox` + WHERE `kind` NOT REGEXP 'location|thing|group' + AND domain = :domain"); + $stmt->execute(array(':domain' => $domain)); + $MailboxData = $stmt->fetch(PDO::FETCH_ASSOC); + // todo: should be using api here + $stmt = $pdo->prepare("SELECT COUNT(*) AS `count` FROM `alias` + WHERE domain = :domain + AND address NOT IN ( + SELECT `username` FROM `mailbox` + )"); + $stmt->execute(array(':domain' => $domain)); + $AliasData = $stmt->fetch(PDO::FETCH_ASSOC); + } + catch(PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + + if ($maxquota > $quota) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['mailbox_quota_exceeds_domain_quota']) + ); + return false; + } + + if ($maxquota == "0" || empty($maxquota)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['maxquota_empty']) + ); + return false; + } + + if ($MailboxData['biggest_mailbox'] > $maxquota) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['max_quota_in_use'], $MailboxData['biggest_mailbox']) + ); + return false; + } + + if ($MailboxData['quota_all'] > $quota) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['domain_quota_m_in_use'], $MailboxData['quota_all']) + ); + return false; + } + + if ($MailboxData['count'] > $mailboxes) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['mailboxes_in_use'], $MailboxData['count']) + ); + return false; + } + + if ($AliasData['count'] > $aliases) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['aliases_in_use'], $AliasData['count']) + ); + return false; + } + try { + $stmt = $pdo->prepare("UPDATE `domain` SET + `relay_all_recipients` = :relay_all_recipients, + `backupmx` = :backupmx, + `active` = :active, + `quota` = :quota, + `maxquota` = :maxquota, + `mailboxes` = :mailboxes, + `aliases` = :aliases, + `description` = :description + WHERE `domain` = :domain"); + $stmt->execute(array( + ':relay_all_recipients' => $relay_all_recipients, + ':backupmx' => $backupmx, + ':active' => $active, + ':quota' => $quota, + ':maxquota' => $maxquota, + ':mailboxes' => $mailboxes, + ':aliases' => $aliases, + ':description' => $description, + ':domain' => $domain + )); + $_SESSION['return'] = array( + 'type' => 'success', + 'msg' => sprintf($lang['success']['domain_modified'], htmlspecialchars($domain)) + ); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + } } - elseif ($_SESSION['mailcow_cc_role'] == "admin") { - $description = $postarray['description']; - isset($postarray['active']) ? $active = '1' : $active = '0'; - $aliases = filter_var($postarray['aliases'], FILTER_SANITIZE_NUMBER_FLOAT); - $mailboxes = filter_var($postarray['mailboxes'], FILTER_SANITIZE_NUMBER_FLOAT); - $maxquota = filter_var($postarray['maxquota'], FILTER_SANITIZE_NUMBER_FLOAT); - $quota = filter_var($postarray['quota'], FILTER_SANITIZE_NUMBER_FLOAT); - isset($postarray['relay_all_recipients']) ? $relay_all_recipients = '1' : $relay_all_recipients = '0'; - isset($postarray['backupmx']) ? $backupmx = '1' : $backupmx = '0'; - isset($postarray['relay_all_recipients']) ? $backupmx = '1' : true; +} +function mailbox_edit_mailbox($postarray) { + global $lang; + global $pdo; + if (!is_array($postarray['username'])) { + $usernames = array(); + $usernames[] = $postarray['username']; + } + else { + $usernames = $postarray['username']; + } + foreach ($usernames as $username) { + if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['username_invalid']) + ); + return false; + } + $is_now = mailbox_get_mailbox_details($username); + if (!empty($is_now)) { + $active = (isset($postarray['active'])) ? $postarray['active'] : $is_now['active_int']; + $name = (!empty($postarray['name'])) ? $postarray['name'] : $is_now['name']; + $domain = $is_now['domain']; + $quota_m = (!empty($postarray['quota'])) ? $postarray['quota'] : ($is_now['quota'] / 1048576); + $quota_b = $quota_m * 1048576; + $password = (!empty($postarray['password'])) ? $postarray['password'] : null; + $password2 = (!empty($postarray['password2'])) ? $postarray['password2'] : null; + } + else { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } try { - // GET MAILBOX DATA - $stmt = $pdo->prepare("SELECT - COUNT(*) AS count, - MAX(COALESCE(ROUND(`quota`/1048576), 0)) AS `maxquota`, - COALESCE(ROUND(SUM(`quota`)/1048576), 0) AS `quota` - FROM `mailbox` - WHERE `kind` NOT REGEXP 'location|thing|group' - AND domain = :domain"); + $stmt = $pdo->prepare("SELECT `quota`, `maxquota` + FROM `domain` + WHERE `domain` = :domain"); $stmt->execute(array(':domain' => $domain)); - $MailboxData = $stmt->fetch(PDO::FETCH_ASSOC); - // GET ALIAS DATA - $stmt = $pdo->prepare("SELECT COUNT(*) AS `count` FROM `alias` - WHERE domain = :domain - AND address NOT IN ( - SELECT `username` FROM `mailbox` - )"); - $stmt->execute(array(':domain' => $domain)); - $AliasData = $stmt->fetch(PDO::FETCH_ASSOC); + $DomainData = $stmt->fetch(PDO::FETCH_ASSOC); } catch(PDOException $e) { $_SESSION['return'] = array( @@ -3600,79 +3747,195 @@ function mailbox_edit_domain($postarray) { return false; } - if ($maxquota > $quota) { + if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) { $_SESSION['return'] = array( 'type' => 'danger', - 'msg' => sprintf($lang['danger']['mailbox_quota_exceeds_domain_quota']) + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } + if (!is_numeric($quota_m) || $quota_m == "0") { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['quota_not_0_not_numeric'], htmlspecialchars($quota_m)) + ); + return false; + } + if ($quota_m > $DomainData['maxquota']) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['mailbox_quota_exceeded'], $DomainData['maxquota']) + ); + return false; + } + if (((($is_now['quota_used'] / 1048576) - $quota_m) + $quota_m) > $DomainData['quota']) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['mailbox_quota_left_exceeded'], ($is_now['max_new_quota'] / 1048576)) ); return false; } - if ($maxquota == "0" || empty($maxquota)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['maxquota_empty']) + if (isset($postarray['sender_acl'])) { + // Get sender_acl items set by admin + $sender_acl_admin = array_merge( + mailbox_get_sender_acl_handles($username)['sender_acl_domains']['ro'], + mailbox_get_sender_acl_handles($username)['sender_acl_addresses']['ro'] ); - return false; - } - if ($MailboxData['maxquota'] > $maxquota) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['max_quota_in_use'], $MailboxData['maxquota']) - ); - return false; - } + // Get sender_acl items from POST array + $sender_acl_domain_admin = ($postarray['sender_acl'] == "0") ? array() : $postarray['sender_acl']; - if ($MailboxData['quota'] > $quota) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['domain_quota_m_in_use'], $MailboxData['quota']) - ); - return false; - } + if (!empty($sender_acl_domain_admin) || !empty($sender_acl_admin)) { + // Check items in POST array + foreach ($sender_acl_domain_admin as $sender_acl) { + if (!filter_var($sender_acl, FILTER_VALIDATE_EMAIL) && !is_valid_domain_name(ltrim($sender_acl, '@'))) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['sender_acl_invalid']) + ); + return false; + } + if (is_valid_domain_name(ltrim($sender_acl, '@'))) { + if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], ltrim($sender_acl, '@'))) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['sender_acl_invalid']) + ); + return false; + } + } + if (filter_var($sender_acl, FILTER_VALIDATE_EMAIL)) { + if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $sender_acl)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['sender_acl_invalid']) + ); + return false; + } + } + } - if ($MailboxData['count'] > $mailboxes) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['mailboxes_in_use'], $MailboxData['count']) - ); - return false; - } + // Merge both arrays + $sender_acl_merged = array_merge($sender_acl_domain_admin, $sender_acl_admin); - if ($AliasData['count'] > $aliases) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['aliases_in_use'], $AliasData['count']) - ); - return false; + try { + $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` = :username"); + $stmt->execute(array( + ':username' => $username + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + + foreach ($sender_acl_merged as $sender_acl) { + $domain = ltrim($sender_acl, '@'); + if (is_valid_domain_name($domain)) { + $sender_acl = '@' . $domain; + } + try { + $stmt = $pdo->prepare("INSERT INTO `sender_acl` (`send_as`, `logged_in_as`) + VALUES (:sender_acl, :username)"); + $stmt->execute(array( + ':sender_acl' => $sender_acl, + ':username' => $username + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + } + } + else { + try { + $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` = :username"); + $stmt->execute(array( + ':username' => $username + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + } + } + if (!empty($password) && !empty($password2)) { + if (!preg_match('/' . $GLOBALS['PASSWD_REGEP'] . '/', $password)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['password_complexity']) + ); + return false; + } + if ($password != $password2) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['password_mismatch']) + ); + return false; + } + $password_hashed = hash_password($password); + try { + $stmt = $pdo->prepare("UPDATE `alias` SET + `active` = :active + WHERE `address` = :address"); + $stmt->execute(array( + ':address' => $username, + ':active' => $active + )); + $stmt = $pdo->prepare("UPDATE `mailbox` SET + `active` = :active, + `password` = :password_hashed, + `name`= :name, + `quota` = :quota_b + WHERE `username` = :username"); + $stmt->execute(array( + ':password_hashed' => $password_hashed, + ':active' => $active, + ':name' => $name, + ':quota_b' => $quota_b, + ':username' => $username + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } } try { - $stmt = $pdo->prepare("UPDATE `domain` SET - `relay_all_recipients` = :relay_all_recipients, - `backupmx` = :backupmx, - `active` = :active, - `quota` = :quota, - `maxquota` = :maxquota, - `mailboxes` = :mailboxes, - `aliases` = :aliases, - `description` = :description - WHERE `domain` = :domain"); + $stmt = $pdo->prepare("UPDATE `alias` SET + `active` = :active + WHERE `address` = :address"); + $stmt->execute(array( + ':address' => $username, + ':active' => $active + )); + $stmt = $pdo->prepare("UPDATE `mailbox` SET + `active` = :active, + `name`= :name, + `quota` = :quota_b + WHERE `username` = :username"); $stmt->execute(array( - ':relay_all_recipients' => $relay_all_recipients, - ':backupmx' => $backupmx, ':active' => $active, - ':quota' => $quota, - ':maxquota' => $maxquota, - ':mailboxes' => $mailboxes, - ':aliases' => $aliases, - ':description' => $description, - ':domain' => $domain + ':name' => $name, + ':quota_b' => $quota_b, + ':username' => $username )); - $_SESSION['return'] = array( - 'type' => 'success', - 'msg' => sprintf($lang['success']['domain_modified'], htmlspecialchars($domain)) - ); } catch (PDOException $e) { $_SESSION['return'] = array( @@ -3682,336 +3945,99 @@ function mailbox_edit_domain($postarray) { return false; } } -} -function mailbox_edit_mailbox($postarray) { - global $lang; - global $pdo; - isset($postarray['active']) ? $active = '1' : $active = '0'; - if (!filter_var($postarray['username'], FILTER_VALIDATE_EMAIL)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['username_invalid']) - ); - return false; - } - $quota_m = intval($postarray['quota']); - $quota_b = $quota_m*1048576; - $username = $postarray['username']; - $name = $postarray['name']; - $password = $postarray['password']; - $password2 = $postarray['password2']; - - try { - $stmt = $pdo->prepare("SELECT `domain` - FROM `mailbox` - WHERE username = :username"); - $stmt->execute(array(':username' => $username)); - $MailboxData1 = $stmt->fetch(PDO::FETCH_ASSOC); - - $stmt = $pdo->prepare("SELECT - COALESCE(ROUND(SUM(`quota`)/1048576), 0) as `quota_m_now` - FROM `mailbox` - WHERE `username` = :username"); - $stmt->execute(array(':username' => $username)); - $MailboxData2 = $stmt->fetch(PDO::FETCH_ASSOC); - - $stmt = $pdo->prepare("SELECT - COALESCE(ROUND(SUM(`quota`)/1048576), 0) as `quota_m_in_use` - FROM `mailbox` - WHERE `domain` = :domain"); - $stmt->execute(array(':domain' => $MailboxData1['domain'])); - $MailboxData3 = $stmt->fetch(PDO::FETCH_ASSOC); - - $stmt = $pdo->prepare("SELECT `quota`, `maxquota` - FROM `domain` - WHERE `domain` = :domain"); - $stmt->execute(array(':domain' => $MailboxData1['domain'])); - $DomainData = $stmt->fetch(PDO::FETCH_ASSOC); - } - catch(PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - - if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $MailboxData1['domain'])) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; - } - if (!is_numeric($quota_m) || $quota_m == "0") { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['quota_not_0_not_numeric'], htmlspecialchars($quota_m)) - ); - return false; - } - if ($quota_m > $DomainData['maxquota']) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['mailbox_quota_exceeded'], $DomainData['maxquota']) - ); - return false; - } - if (($MailboxData3['quota_m_in_use'] - $MailboxData2['quota_m_now'] + $quota_m) > $DomainData['quota']) { - $quota_left_m = ($DomainData['quota'] - $MailboxData3['quota_m_in_use'] + $MailboxData2['quota_m_now']); - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['mailbox_quota_left_exceeded'], $quota_left_m) - ); - return false; - } - - // Get sender_acl items set by admin - $sender_acl_admin = array_merge( - mailbox_get_sender_acl_handles($username)['sender_acl_domains']['ro'], - mailbox_get_sender_acl_handles($username)['sender_acl_addresses']['ro'] + $_SESSION['return'] = array( + 'type' => 'success', + 'msg' => sprintf($lang['success']['mailbox_modified'], implode(', ', $usernames)) ); - - // Get sender_acl items from POST array - (isset($postarray['sender_acl'])) ? $sender_acl_domain_admin = $postarray['sender_acl'] : $sender_acl_domain_admin = array(); - - if (!empty($sender_acl_domain_admin) || !empty($sender_acl_admin)) { - // Check items in POST array - foreach ($sender_acl_domain_admin as $sender_acl) { - if (!filter_var($sender_acl, FILTER_VALIDATE_EMAIL) && !is_valid_domain_name(ltrim($sender_acl, '@'))) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['sender_acl_invalid']) - ); - return false; - } - if (is_valid_domain_name(ltrim($sender_acl, '@'))) { - if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], ltrim($sender_acl, '@'))) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['sender_acl_invalid']) - ); - return false; - } - } - if (filter_var($sender_acl, FILTER_VALIDATE_EMAIL)) { - if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $sender_acl)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['sender_acl_invalid']) - ); - return false; - } - } - } - - // Merge both arrays - $sender_acl_merged = array_merge($sender_acl_domain_admin, $sender_acl_admin); - - try { - $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` = :username"); - $stmt->execute(array( - ':username' => $username - )); - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - - foreach ($sender_acl_merged as $sender_acl) { - $domain = ltrim($sender_acl, '@'); - if (is_valid_domain_name($domain)) { - $sender_acl = '@' . $domain; - } - try { - $stmt = $pdo->prepare("INSERT INTO `sender_acl` (`send_as`, `logged_in_as`) - VALUES (:sender_acl, :username)"); - $stmt->execute(array( - ':sender_acl' => $sender_acl, - ':username' => $username - )); - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - } - } - else { - try { - $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` = :username"); - $stmt->execute(array( - ':username' => $username - )); - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - } - if (!empty($password) && !empty($password2)) { - if (!preg_match('/' . $GLOBALS['PASSWD_REGEP'] . '/', $password)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['password_complexity']) - ); - return false; - } - if ($password != $password2) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['password_mismatch']) - ); - return false; - } - $password_hashed = hash_password($password); - try { - $stmt = $pdo->prepare("UPDATE `alias` SET - `active` = :active - WHERE `address` = :address"); - $stmt->execute(array( - ':address' => $username, - ':active' => $active - )); - $stmt = $pdo->prepare("UPDATE `mailbox` SET - `active` = :active, - `password` = :password_hashed, - `name`= :name, - `quota` = :quota_b - WHERE `username` = :username"); - $stmt->execute(array( - ':password_hashed' => $password_hashed, - ':active' => $active, - ':name' => $name, - ':quota_b' => $quota_b, - ':username' => $username - )); - $_SESSION['return'] = array( - 'type' => 'success', - 'msg' => sprintf($lang['success']['mailbox_modified'], $username) - ); - return true; - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - } - try { - $stmt = $pdo->prepare("UPDATE `alias` SET - `active` = :active - WHERE `address` = :address"); - $stmt->execute(array( - ':address' => $username, - ':active' => $active - )); - $stmt = $pdo->prepare("UPDATE `mailbox` SET - `active` = :active, - `name`= :name, - `quota` = :quota_b - WHERE `username` = :username"); - $stmt->execute(array( - ':active' => $active, - ':name' => $name, - ':quota_b' => $quota_b, - ':username' => $username - )); - $_SESSION['return'] = array( - 'type' => 'success', - 'msg' => sprintf($lang['success']['mailbox_modified'], $username) - ); - return true; - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } + return true; } function mailbox_edit_resource($postarray) { global $lang; global $pdo; - isset($postarray['active']) ? $active = '1' : $active = '0'; - isset($postarray['multiple_bookings']) ? $multiple_bookings = '1' : $multiple_bookings = '0'; - $name = $postarray['name']; - $kind = $postarray['kind']; - $description = $postarray['description']; - - if (!filter_var($name, FILTER_VALIDATE_EMAIL)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['resource_invalid']) - ); - return false; - } - - if (empty($description)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['description_invalid']) - ); - return false; + if (!is_array($postarray['name'])) { + $names = array(); + $names[] = $postarray['name']; } - - if ($kind != 'location' && $kind != 'group' && $kind != 'thing') { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['resource_invalid']) - ); - return false; - } - - if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $name)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; + else { + $names = $postarray['name']; } + foreach ($names as $name) { + $is_now = mailbox_get_resource_details($name); + if (!empty($is_now)) { + $active = (isset($postarray['active'])) ? $postarray['active'] : $is_now['active_int']; + $multiple_bookings = (isset($postarray['multiple_bookings'])) ? $postarray['multiple_bookings'] : $is_now['multiple_bookings_int']; + $description = (!empty($postarray['description'])) ? $postarray['description'] : $is_now['description']; + $kind = (!empty($postarray['kind'])) ? $postarray['kind'] : $is_now['kind']; + } + else { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['resource_invalid']) + ); + return false; + } - try { - $stmt = $pdo->prepare("UPDATE `mailbox` SET - `active` = :active, - `name`= :description, - `kind`= :kind, - `multiple_bookings`= :multiple_bookings - WHERE `username` = :name"); - $stmt->execute(array( - ':active' => $active, - ':description' => $description, - ':multiple_bookings' => $multiple_bookings, - ':kind' => $kind, - ':name' => $name - )); - $_SESSION['return'] = array( - 'type' => 'success', - 'msg' => sprintf($lang['success']['resource_modified'], $name) - ); - return true; - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; + if (!filter_var($name, FILTER_VALIDATE_EMAIL)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['resource_invalid']) + ); + return false; + } + + if (empty($description)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['description_invalid']) + ); + return false; + } + + if ($kind != 'location' && $kind != 'group' && $kind != 'thing') { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['resource_invalid']) + ); + return false; + } + + if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $name)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } + + try { + $stmt = $pdo->prepare("UPDATE `mailbox` SET + `active` = :active, + `name`= :description, + `kind`= :kind, + `multiple_bookings`= :multiple_bookings + WHERE `username` = :name"); + $stmt->execute(array( + ':active' => $active, + ':description' => $description, + ':multiple_bookings' => $multiple_bookings, + ':kind' => $kind, + ':name' => $name + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } } + $_SESSION['return'] = array( + 'type' => 'success', + 'msg' => sprintf($lang['success']['resource_modified'], implode(', ', $names)) + ); + return true; } function mailbox_get_mailboxes($domain = null) { global $lang; @@ -4564,8 +4590,15 @@ function mailbox_get_resource_details($resource) { } function mailbox_delete_domain($postarray) { global $lang; + global $redis; global $pdo; - $domain = $postarray['domain']; + if (!is_array($postarray['domain'])) { + $domains = array(); + $domains[] = $postarray['domain']; + } + else { + $domains = $postarray['domain']; + } if ($_SESSION['mailcow_cc_role'] != "admin") { $_SESSION['return'] = array( 'type' => 'danger', @@ -4573,90 +4606,92 @@ function mailbox_delete_domain($postarray) { ); return false; } - if (!is_valid_domain_name($domain)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['domain_invalid']) - ); - return false; - } - $domain = idn_to_ascii(strtolower(trim($domain))); + foreach ($domains as $domain) { + if (!is_valid_domain_name($domain)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['domain_invalid']) + ); + return false; + } + $domain = idn_to_ascii(strtolower(trim($domain))); - try { - $stmt = $pdo->prepare("SELECT `username` FROM `mailbox` - WHERE `domain` = :domain"); - $stmt->execute(array(':domain' => $domain)); - $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); - } - catch(PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - if ($num_results != 0 || !empty($num_results)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['domain_not_empty']) - ); - return false; - } + try { + $stmt = $pdo->prepare("SELECT `username` FROM `mailbox` + WHERE `domain` = :domain"); + $stmt->execute(array(':domain' => $domain)); + $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); + } + catch(PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + if ($num_results != 0 || !empty($num_results)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['domain_not_empty']) + ); + return false; + } - try { - $stmt = $pdo->prepare("DELETE FROM `domain` WHERE `domain` = :domain"); - $stmt->execute(array( - ':domain' => $domain, - )); - $stmt = $pdo->prepare("DELETE FROM `domain_admins` WHERE `domain` = :domain"); - $stmt->execute(array( - ':domain' => $domain, - )); - $stmt = $pdo->prepare("DELETE FROM `alias` WHERE `domain` = :domain"); - $stmt->execute(array( - ':domain' => $domain, - )); - $stmt = $pdo->prepare("DELETE FROM `alias_domain` WHERE `target_domain` = :domain"); - $stmt->execute(array( - ':domain' => $domain, - )); - $stmt = $pdo->prepare("DELETE FROM `mailbox` WHERE `domain` = :domain"); - $stmt->execute(array( - ':domain' => $domain, - )); - $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` LIKE :domain"); - $stmt->execute(array( - ':domain' => '%@'.$domain, - )); - $stmt = $pdo->prepare("DELETE FROM `quota2` WHERE `username` = :domain"); - $stmt->execute(array( - ':domain' => '%@'.$domain, - )); - $stmt = $pdo->prepare("DELETE FROM `spamalias` WHERE `address` = :domain"); - $stmt->execute(array( - ':domain' => '%@'.$domain, - )); - $stmt = $pdo->prepare("DELETE FROM `filterconf` WHERE `object` = :domain"); - $stmt->execute(array( - ':domain' => '%@'.$domain, - )); - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - try { - $redis->hDel('DOMAIN_MAP', $domain); - } - catch (RedisException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'Redis: '.$e - ); - return false; + try { + $stmt = $pdo->prepare("DELETE FROM `domain` WHERE `domain` = :domain"); + $stmt->execute(array( + ':domain' => $domain, + )); + $stmt = $pdo->prepare("DELETE FROM `domain_admins` WHERE `domain` = :domain"); + $stmt->execute(array( + ':domain' => $domain, + )); + $stmt = $pdo->prepare("DELETE FROM `alias` WHERE `domain` = :domain"); + $stmt->execute(array( + ':domain' => $domain, + )); + $stmt = $pdo->prepare("DELETE FROM `alias_domain` WHERE `target_domain` = :domain"); + $stmt->execute(array( + ':domain' => $domain, + )); + $stmt = $pdo->prepare("DELETE FROM `mailbox` WHERE `domain` = :domain"); + $stmt->execute(array( + ':domain' => $domain, + )); + $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` LIKE :domain"); + $stmt->execute(array( + ':domain' => '%@'.$domain, + )); + $stmt = $pdo->prepare("DELETE FROM `quota2` WHERE `username` = :domain"); + $stmt->execute(array( + ':domain' => '%@'.$domain, + )); + $stmt = $pdo->prepare("DELETE FROM `spamalias` WHERE `address` = :domain"); + $stmt->execute(array( + ':domain' => '%@'.$domain, + )); + $stmt = $pdo->prepare("DELETE FROM `filterconf` WHERE `object` = :domain"); + $stmt->execute(array( + ':domain' => '%@'.$domain, + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + try { + $redis->hDel('DOMAIN_MAP', $domain); + } + catch (RedisException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'Redis: '.$e + ); + return false; + } } $_SESSION['return'] = array( 'type' => 'success', @@ -4669,13 +4704,13 @@ function mailbox_delete_alias($postarray) { global $lang; global $pdo; if (!is_array($postarray['address'])) { - $address_array = array(); - $address_array[] = $postarray['address']; + $addresses = array(); + $addresses[] = $postarray['address']; } else { - $address_array = $postarray['address']; + $addresses = $postarray['address']; } - foreach ($address_array as $address) { + foreach ($addresses as $address) { $local_part = strstr($address, '@', true); $domain = mailbox_get_alias_details($address)['domain']; try { @@ -4715,172 +4750,185 @@ function mailbox_delete_alias($postarray) { } $_SESSION['return'] = array( 'type' => 'success', - 'msg' => sprintf($lang['success']['alias_removed'], htmlspecialchars(implode(', ', $address_array))) + 'msg' => sprintf($lang['success']['alias_removed'], htmlspecialchars(implode(', ', $addresses))) ); } function mailbox_delete_alias_domain($postarray) { global $lang; global $pdo; - $alias_domain = $postarray['alias_domain']; - if (!is_valid_domain_name($postarray['alias_domain'])) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['domain_invalid']) - ); - return false; - } - try { - $stmt = $pdo->prepare("SELECT `target_domain` FROM `alias_domain` - WHERE `alias_domain`= :alias_domain"); - $stmt->execute(array(':alias_domain' => $alias_domain)); - $DomainData = $stmt->fetch(PDO::FETCH_ASSOC); - } - catch(PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; - } - - if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $DomainData['target_domain'])) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; - } - - try { - $stmt = $pdo->prepare("DELETE FROM `alias_domain` WHERE `alias_domain` = :alias_domain"); - $stmt->execute(array( - ':alias_domain' => $alias_domain, - )); - $stmt = $pdo->prepare("DELETE FROM `alias` WHERE `domain` = :alias_domain"); - $stmt->execute(array( - ':alias_domain' => $alias_domain, - )); - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; + if (!is_array($postarray['alias_domain'])) { + $alias_domains = array(); + $alias_domains[] = $postarray['alias_domain']; + } + else { + $alias_domains = $postarray['alias_domain']; + } + foreach ($alias_domains as $alias_domain) { + if (!is_valid_domain_name($alias_domain)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['domain_invalid']) + ); + return false; + } + try { + $stmt = $pdo->prepare("SELECT `target_domain` FROM `alias_domain` + WHERE `alias_domain`= :alias_domain"); + $stmt->execute(array(':alias_domain' => $alias_domain)); + $DomainData = $stmt->fetch(PDO::FETCH_ASSOC); + } + catch(PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } + if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $DomainData['target_domain'])) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } + try { + $stmt = $pdo->prepare("DELETE FROM `alias_domain` WHERE `alias_domain` = :alias_domain"); + $stmt->execute(array( + ':alias_domain' => $alias_domain, + )); + $stmt = $pdo->prepare("DELETE FROM `alias` WHERE `domain` = :alias_domain"); + $stmt->execute(array( + ':alias_domain' => $alias_domain, + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } } $_SESSION['return'] = array( 'type' => 'success', - 'msg' => sprintf($lang['success']['alias_domain_removed'], htmlspecialchars($alias_domain)) + 'msg' => sprintf($lang['success']['alias_domain_removed'], htmlspecialchars(implode(', ', $alias_domains))) ); } function mailbox_delete_mailbox($postarray) { global $lang; global $pdo; - $username = $postarray['username']; + if (!is_array($postarray['username'])) { + $usernames = array(); + $usernames[] = $postarray['username']; + } + else { + $usernames = $postarray['username']; + } + foreach ($usernames as $username) { + if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } - if (!filter_var($postarray['username'], FILTER_VALIDATE_EMAIL)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; - } + if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } - if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; - } - - try { - $stmt = $pdo->prepare("DELETE FROM `alias` WHERE `goto` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `quota2` WHERE `username` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `mailbox` WHERE `username` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `spamalias` WHERE `goto` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `imapsync` WHERE `user2` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `filterconf` WHERE `object` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_user_profile` WHERE `c_uid` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_cache_folder` WHERE `c_uid` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_acl` WHERE `c_object` LIKE '%/" . $username . "/%' OR `c_uid` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_store` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_quick_contact` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_quick_appointment` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_folder_info` WHERE `c_path2` = :username"); - $stmt->execute(array( - ':username' => $username - )); - $stmt = $pdo->prepare("SELECT `address`, `goto` FROM `alias` - WHERE `goto` REGEXP :username"); - $stmt->execute(array(':username' => '(^|,)'.$username.'($|,)')); - $GotoData = $stmt->fetchAll(PDO::FETCH_ASSOC); - foreach ($GotoData as $gotos) { - $goto_exploded = explode(',', $gotos['goto']); - if (($key = array_search($username, $goto_exploded)) !== false) { - unset($goto_exploded[$key]); - } - $gotos_rebuild = implode(',', $goto_exploded); - $stmt = $pdo->prepare("UPDATE `alias` SET - `goto` = :goto - WHERE `address` = :address"); - $stmt->execute(array( - ':goto' => $gotos_rebuild, - ':address' => $gotos['address'] - )); - } - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; + try { + $stmt = $pdo->prepare("DELETE FROM `alias` WHERE `goto` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `quota2` WHERE `username` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `mailbox` WHERE `username` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sender_acl` WHERE `logged_in_as` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `spamalias` WHERE `goto` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `imapsync` WHERE `user2` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `filterconf` WHERE `object` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_user_profile` WHERE `c_uid` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_cache_folder` WHERE `c_uid` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_acl` WHERE `c_object` LIKE '%/" . $username . "/%' OR `c_uid` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_store` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_quick_contact` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_quick_appointment` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_folder_info` WHERE `c_path2` = :username"); + $stmt->execute(array( + ':username' => $username + )); + $stmt = $pdo->prepare("SELECT `address`, `goto` FROM `alias` + WHERE `goto` REGEXP :username"); + $stmt->execute(array(':username' => '(^|,)'.$username.'($|,)')); + $GotoData = $stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($GotoData as $gotos) { + $goto_exploded = explode(',', $gotos['goto']); + if (($key = array_search($username, $goto_exploded)) !== false) { + unset($goto_exploded[$key]); + } + $gotos_rebuild = implode(',', $goto_exploded); + $stmt = $pdo->prepare("UPDATE `alias` SET + `goto` = :goto + WHERE `address` = :address"); + $stmt->execute(array( + ':goto' => $gotos_rebuild, + ':address' => $gotos['address'] + )); + } + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } } $_SESSION['return'] = array( 'type' => 'success', - 'msg' => sprintf($lang['success']['mailbox_removed'], htmlspecialchars($username)) + 'msg' => sprintf($lang['success']['mailbox_removed'], htmlspecialchars(implode(', ', $usernames))) ); } function mailbox_reset_eas($username) { @@ -4926,67 +4974,73 @@ function mailbox_reset_eas($username) { function mailbox_delete_resource($postarray) { global $lang; global $pdo; - $name = $postarray['name']; - if (!filter_var($postarray['name'], FILTER_VALIDATE_EMAIL)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; - } - - if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $name)) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['access_denied']) - ); - return false; - } - - try { - $stmt = $pdo->prepare("DELETE FROM `mailbox` WHERE `username` = :username"); - $stmt->execute(array( - ':username' => $name - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_user_profile` WHERE `c_uid` = :username"); - $stmt->execute(array( - ':username' => $name - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_cache_folder` WHERE `c_uid` = :username"); - $stmt->execute(array( - ':username' => $name - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_acl` WHERE `c_object` LIKE '%/" . $name . "/%' OR `c_uid` = :username"); - $stmt->execute(array( - ':username' => $name - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_store` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); - $stmt->execute(array( - ':username' => $name - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_quick_contact` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); - $stmt->execute(array( - ':username' => $name - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_quick_appointment` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); - $stmt->execute(array( - ':username' => $name - )); - $stmt = $pdo->prepare("DELETE FROM `sogo_folder_info` WHERE `c_path2` = :username"); - $stmt->execute(array( - ':username' => $name - )); - } - catch (PDOException $e) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => 'MySQL: '.$e - ); - return false; + if (!is_array($postarray['name'])) { + $names = array(); + $names[] = $postarray['name']; + } + else { + $names = $postarray['name']; + } + foreach ($names as $name) { + if (!filter_var($name, FILTER_VALIDATE_EMAIL)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } + if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $name)) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['access_denied']) + ); + return false; + } + try { + $stmt = $pdo->prepare("DELETE FROM `mailbox` WHERE `username` = :username"); + $stmt->execute(array( + ':username' => $name + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_user_profile` WHERE `c_uid` = :username"); + $stmt->execute(array( + ':username' => $name + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_cache_folder` WHERE `c_uid` = :username"); + $stmt->execute(array( + ':username' => $name + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_acl` WHERE `c_object` LIKE '%/" . $name . "/%' OR `c_uid` = :username"); + $stmt->execute(array( + ':username' => $name + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_store` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); + $stmt->execute(array( + ':username' => $name + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_quick_contact` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); + $stmt->execute(array( + ':username' => $name + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_quick_appointment` WHERE `c_folder_id` IN (SELECT `c_folder_id` FROM `sogo_folder_info` WHERE `c_path2` = :username)"); + $stmt->execute(array( + ':username' => $name + )); + $stmt = $pdo->prepare("DELETE FROM `sogo_folder_info` WHERE `c_path2` = :username"); + $stmt->execute(array( + ':username' => $name + )); + } + catch (PDOException $e) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => 'MySQL: '.$e + ); + return false; + } } $_SESSION['return'] = array( 'type' => 'success', - 'msg' => sprintf($lang['success']['resource_removed'], htmlspecialchars($name)) + 'msg' => sprintf($lang['success']['resource_removed'], htmlspecialchars(implode(', ', $names))) ); } function mailbox_get_sender_acl_handles($mailbox) { @@ -5178,7 +5232,6 @@ function add_forwarding_host($postarray) { else { $hosts = get_outgoing_hosts_best_guess($host); } - print_r($hosts); if (empty($hosts)) { $_SESSION['return'] = array( 'type' => 'danger', diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php index 67c6c34e..4c8a10cd 100644 --- a/data/web/inc/vars.inc.php +++ b/data/web/inc/vars.inc.php @@ -1,6 +1,7 @@ ' + - ' ' + lang.edit + '' + - ' ' + lang.remove + '' + - '
'; - }); - $('#domainadminstable').footable({ - "columns": [ - {"sorted": true,"name":"username","title":lang.username,"style":{"width":"250px"}}, - {"name":"selected_domains","title":lang.admin_domains,"breakpoints":"xs sm"}, - {"name":"tfa_active","title":"TFA", "filterable": false,"style":{"maxWidth":"80px","width":"80px"}}, - {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "rows": data, - "empty": lang.empty, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true - } - }); - } - }); - - // Draw fwd hosts table - $.ajax({ - dataType: 'json', - url: '/api/v1/get/fwdhost/all', - jsonp: false, - error: function () { - console.log('Cannot draw forwarding hosts table'); - }, - success: function (data) { - $.each(data, function (i, item) { - item.action = '
' + - ' ' + lang.remove + '' + - '
'; - if (item.keep_spam == "yes") { - item.keep_spam = lang.no; - } - else { - item.keep_spam = lang.yes; - } - item.chkbox = ''; - }); - $('#forwardinghoststable').footable({ - "columns": [ - {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, - {"name":"host","type":"text","title":lang.host,"style":{"width":"250px"}}, - {"name":"source","title":lang.source,"breakpoints":"xs sm"}, - {"name":"keep_spam","title":lang.spamfilter, "type": "text","style":{"maxWidth":"80px","width":"80px"}}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "rows": data, - "empty": lang.empty, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "sorting": { - "enabled": true - } - }); - } - }); - - $(document).on('click', '#delete_fwdhosts', function(e) { + // General API edit function + $(document).on('click', '#delete_selected', function(e) { e.preventDefault(); - var id = $(this).closest("form").attr('data-id'); - if (typeof multi_data[id] == "undefined") return; + var id = $(this).data('id'); + if (typeof multi_data[id] == "undefined" || multi_data[id] == "") return; data_array = multi_data[id]; - if (Object.keys(data_array).length !== 0) { + api_url = $(this).data('api-url'); $(document).on('show.bs.modal','#ConfirmDeleteModal', function () { $("#ItemsToDelete").empty(); for (var i in data_array) { @@ -136,41 +52,11 @@ $(document).ready(function() { $.ajax({ type: "POST", dataType: "json", - data: { "forwardinghost": JSON.stringify(data_array) }, - url: '/api/v1/delete/fwdhost', + data: { "items": JSON.stringify(data_array) }, + url: '/api/v1/' + api_url, jsonp: false, complete: function (data) { - window.location.href = window.location.href; - } - }); - }) - .one('click', '#isCanceled', function(e) { - $('#ConfirmDeleteModal').modal('hide'); - });; - } - }); - - $(document).on('click', '#delete_dkim_key', function(e) { - e.preventDefault(); - var dkim_domain = $(this).data('dkim-domain'); - var dkim_selector = $(this).data('dkim-selector'); - $(document).on('show.bs.modal','#ConfirmDeleteModal', function () { - $("#ItemsToDelete").empty(); - $("#ItemsToDelete").append("
  • " + dkim_domain + ", " + dkim_selector + "
  • "); - }) - $('#ConfirmDeleteModal').modal({ - backdrop: 'static', - keyboard: false - }) - .one('click', '#IsConfirmed', function(e) { - $.ajax({ - type: "POST", - dataType: "json", - data: { "domains": JSON.stringify(dkim_domain) }, - url: '/api/v1/delete/dkim', - jsonp: false, - complete: function (data) { - mailcow_alert_box("warn", "asd"); + location.assign(window.location); } }); }) @@ -179,72 +65,28 @@ $(document).ready(function() { });; }); - $("#refresh_dovecot_log").on('click', function(e) { - function unix_time_format(tm) { - var date = new Date(tm ? tm * 1000 : 0); - return date.toLocaleString(); - } - e.preventDefault(); - if (typeof ft_dovecot_logs != 'undefined') { - ft_dovecot_logs.destroy(); - } - $.ajax({ - dataType: 'json', - url: '/api/v1/get/logs/dovecot/1000', - jsonp: false, - error: function () { - console.log('Cannot draw dovecot log table'); - }, - success: function (data) { - $.each(data, function (i, item) { - var danger_class = ["emerg", "alert", "crit"]; - var warning_class = ["warning"]; - var info_class = ["notice", "info", "debug"]; - if (jQuery.inArray(item.priority, danger_class) !== -1) { - item.priority = '' + item.priority + ''; - } - else if (jQuery.inArray(item.priority, warning_class) !== -1) { - item.priority = '' + item.priority + ''; - } - else if (jQuery.inArray(item.priority, info_class) !== -1) { - item.priority = '' + item.priority + ''; - } - }); - ft_dovecot_logs = FooTable.init("#dovecot_log", { - "columns": [ - {"name":"time","formatter":function unix_time_format(tm) {var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}}, - {"name":"priority","title":lang.priority,"style":{"width":"80px"}}, - {"name":"message","title":lang.message}, - ], - "rows": data, - "empty": lang.empty, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true - } - }); - } - }); - }); +}); +jQuery(function($){ + function unix_time_format(tm) { + var date = new Date(tm ? tm * 1000 : 0); + return date.toLocaleString(); + } $("#refresh_postfix_log").on('click', function(e) { - function unix_time_format(tm) { - var date = new Date(tm ? tm * 1000 : 0); - return date.toLocaleString(); - } - e.preventDefault(); - if (typeof ft_postfix_logs != 'undefined') { - ft_postfix_logs.destroy(); - } - $.ajax({ + e.preventDefault(); + draw_postfix_logs(); + }); + $("#refresh_dovecot_log").on('click', function(e) { + e.preventDefault(); + draw_dovecot_logs(); + }); + function draw_postfix_logs() { + ft_postfix_logs = FooTable.init('#postfix_log', { + "columns": [ + {"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}}, + {"name":"priority","title":lang.priority,"style":{"width":"80px"}}, + {"name":"message","title":lang.message}, + ], + "rows": $.ajax({ dataType: 'json', url: '/api/v1/get/logs/postfix/1000', jsonp: false, @@ -266,31 +108,158 @@ $(document).ready(function() { item.priority = '' + item.priority + ''; } }); - ft_postfix_logs = FooTable.init("#postfix_log", { - "columns": [ - {"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}}, - {"name":"priority","title":lang.priority,"style":{"width":"80px"}}, - {"name":"message","title":lang.message}, - ], - "rows": data, - "empty": lang.empty, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true + } + }), + "empty": lang.empty, + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } + function draw_dovecot_logs() { + ft_postfix_logs = FooTable.init('#dovecot_log', { + "columns": [ + {"name":"time","formatter":function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString();},"title":lang.time,"style":{"width":"170px"}}, + {"name":"priority","title":lang.priority,"style":{"width":"80px"}}, + {"name":"message","title":lang.message}, + ], + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/logs/dovecot/1000', + jsonp: false, + error: function () { + console.log('Cannot draw dovecot log table'); + }, + success: function (data) { + $.each(data, function (i, item) { + var danger_class = ["emerg", "alert", "crit"]; + var warning_class = ["warning"]; + var info_class = ["notice", "info", "debug"]; + if (jQuery.inArray(item.priority, danger_class) !== -1) { + item.priority = '' + item.priority + ''; + } + else if (jQuery.inArray(item.priority, warning_class) !== -1) { + item.priority = '' + item.priority + ''; + } + else if (jQuery.inArray(item.priority, info_class) !== -1) { + item.priority = '' + item.priority + ''; } }); } - }); - }); - $("#refresh_dovecot_log").trigger('click'); - $("#refresh_postfix_log").trigger('click'); + }), + "empty": lang.empty, + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } + function draw_domain_admins() { + ft_domainadmins = FooTable.init('#domainadminstable', { + "columns": [ + {"sorted": true,"name":"username","title":lang.username,"style":{"width":"250px"}}, + {"name":"selected_domains","title":lang.admin_domains,"breakpoints":"xs sm"}, + {"name":"tfa_active","title":"TFA", "filterable": false,"style":{"maxWidth":"80px","width":"80px"}}, + {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, + {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} + ], + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/domain-admin/all', + jsonp: false, + error: function () { + console.log('Cannot draw domain admin table'); + }, + success: function (data) { + $.each(data, function (i, item) { + item.action = ''; + }); + } + }), + "empty": lang.empty, + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } + + function draw_fwd_hosts() { + ft_domainadmins = FooTable.init('#forwardinghoststable', { + "columns": [ + {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, + {"name":"host","type":"text","title":lang.host,"style":{"width":"250px"}}, + {"name":"source","title":lang.source,"breakpoints":"xs sm"}, + {"name":"keep_spam","title":lang.spamfilter, "type": "text","style":{"maxWidth":"80px","width":"80px"}}, + {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} + ], + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/fwdhost/all', + jsonp: false, + error: function () { + console.log('Cannot draw forwarding hosts table'); + }, + success: function (data) { + $.each(data, function (i, item) { + item.action = '
    ' + + ' ' + lang.remove + '' + + '
    '; + if (item.keep_spam == "yes") { + item.keep_spam = lang.no; + } + else { + item.keep_spam = lang.yes; + } + item.chkbox = ''; + }); + } + }), + "empty": lang.empty, + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "sorting": { + "enabled": true + } + }); + } + + draw_postfix_logs(); + draw_dovecot_logs(); + draw_domain_admins(); + draw_fwd_hosts(); }); \ No newline at end of file diff --git a/data/web/js/mailbox.js b/data/web/js/mailbox.js index 39f2d976..70435ca1 100644 --- a/data/web/js/mailbox.js +++ b/data/web/js/mailbox.js @@ -1,5 +1,98 @@ $(document).ready(function() { - $('[data-toggle="tooltip"]').tooltip(); + // Collect values of input fields with name multi_select with same data-id to js array multi_data[data-id] + var multi_data = []; + $(document).on('change', 'input[name=multi_select]:checkbox', function() { + if ($(this).is(':checked') && $(this).data('id')) { + var id = $(this).data('id'); + if (typeof multi_data[id] == "undefined") { + multi_data[id] = []; + } + multi_data[id].push($(this).val()); + } + else { + var id = $(this).data('id'); + multi_data[id].splice($.inArray($(this).val(), multi_data[id]),1); + } + }); + // Select checkbox by click on parent tr + $(document).on('click', 'tr', function(e) { + if (e.target.type == "checkbox") { + e.stopPropagation(); + } else { + var checkbox = $(this).find(':checkbox'); + checkbox.trigger('click'); + } + }); + // Select or deselect all checkboxes with same data-id + $(document).on('click', '#toggle_multi_select_all', function(e) { + e.preventDefault(); + id = $(this).data("id"); + multi_data[id] = []; + var all_checkboxes = $("input[data-id=" + id + "]:enabled"); + all_checkboxes.prop("checked", !all_checkboxes.prop("checked")).change(); + }); + // General API edit actions + $(document).on('click', '#edit_selected', function(e) { + e.preventDefault(); + var id = $(this).data('id'); + if (typeof multi_data[id] == "undefined") return; + data_array = multi_data[id]; + api_url = $(this).data('api-url'); + api_attr = $(this).data('api-attr'); + if (Object.keys(data_array).length !== 0) { + $.ajax({ + type: "POST", + dataType: "json", + data: { "items": JSON.stringify(data_array), "attr": JSON.stringify(api_attr) }, + url: '/api/v1/' + api_url, + jsonp: false, + complete: function (data) { + // var reponse = (JSON.parse(data.responseText)); + // alert(reponse.type); + // alert(reponse.msg); + location.assign(window.location); + } + }); + } + }); + // General API delete actions + $(document).on('click', '#delete_selected', function(e) { + e.preventDefault(); + var id = $(this).data('id'); + if (typeof multi_data[id] == "undefined" || multi_data[id] == "") return; + data_array = multi_data[id]; + api_url = $(this).data('api-url'); + $(document).on('show.bs.modal','#ConfirmDeleteModal', function () { + $("#ItemsToDelete").empty(); + for (var i in data_array) { + $("#ItemsToDelete").append("
  • " + data_array[i] + "
  • "); + } + }) + $('#ConfirmDeleteModal').modal({ + backdrop: 'static', + keyboard: false + }) + .one('click', '#IsConfirmed', function(e) { + $.ajax({ + type: "POST", + dataType: "json", + data: { "items": JSON.stringify(data_array) }, + url: '/api/v1/' + api_url, + jsonp: false, + complete: function (data) { + location.assign(window.location); + } + }); + }) + .one('click', '#isCanceled', function(e) { + $('#ConfirmDeleteModal').modal('hide'); + });; + }); + +}); + +jQuery(function($){ + // Calculation human readable file sizes function humanFileSize(bytes) { if(Math.abs(bytes) < 1024) { return bytes + ' B'; @@ -12,358 +105,285 @@ $(document).ready(function() { } while(Math.abs(bytes) >= 1024 && u < units.length - 1); return bytes.toFixed(1)+' '+units[u]; } - - $.ajax({ - dataType: 'json', - url: '/api/v1/get/domain/all', - jsonp: false, - error: function () { - alert('Cannot draw domain table'); - }, - success: function (data) { - $.each(data, function (i, item) { - item.aliases = item.aliases_in_domain + " / " + item.max_num_aliases_for_domain; - item.mailboxes = item.mboxes_in_domain + " / " + item.max_num_mboxes_for_domain; - item.quota = item.quota_used_in_domain + "/" + item.max_quota_for_domain; - item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox); - if (role == "admin") { - item.action = ''; - } - else { - item.action = '
    ' + - ' ' + lang.edit + '' + - '
    '; - } - }); - $('#domain_table').footable({ - "columns": [ - {"sorted": true,"name":"domain_name","title":lang.domain,"style":{"width":"250px"}}, - {"name":"aliases","title":lang.aliases,"breakpoints":"xs sm"}, - {"name":"mailboxes","title":lang.mailboxes}, - {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota,"formatter": function(value){ - res = value.split("/"); - return humanFileSize(res[0]) + " / " + humanFileSize(res[1]); - }, - "sortValue": function(value){ - res = value.split("/"); - return res[0]; - }, - }, - {"name":"max_quota_for_mbox","title":lang.mailbox_quota,"breakpoints":"xs sm"}, - {"name":"backupmx","filterable": false,"style":{"maxWidth":"120px","width":"120px"},"title":lang.backup_mx,"breakpoints":"xs sm"}, - {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "rows": data, - "empty": lang.empty, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size + function unix_time_format(tm) { + var date = new Date(tm ? tm * 1000 : 0); + return date.toLocaleString(); + } + function draw_domain_table() { + ft_domain_table = FooTable.init('#domain_table', { + "columns": [ + {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, + {"sorted": true,"name":"domain_name","title":lang.domain,"style":{"width":"250px"}}, + {"name":"aliases","title":lang.aliases,"breakpoints":"xs sm"}, + {"name":"mailboxes","title":lang.mailboxes}, + {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota,"formatter": function(value){ + res = value.split("/"); + return humanFileSize(res[0]) + " / " + humanFileSize(res[1]); }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table + "sortValue": function(value){ + res = value.split("/"); + return res[0]; }, - "sorting": { - "enabled": true - } - }); - } - }); - - $.ajax({ - dataType: 'json', - url: '/api/v1/get/mailbox/all', - jsonp: false, - error: function () { - alert('Cannot draw mailbox table'); - }, - success: function (data) { - $.each(data, function (i, item) { - item.quota = item.quota_used + "/" + item.quota; - item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox); - if (role == "admin") { - item.action = ''; - } - else { - item.action = ''; - } - item.in_use = '
    ' + - '
    ' + item.percent_in_use + '%' + '
    '; - - }); - $('#mailbox_table').footable({ - "columns": [ - {"sorted": true,"name":"username","style":{"word-break":"break-all","min-width":"120px"},"title":lang.username}, - {"name":"name","title":lang.fname,"style":{"word-break":"break-all","min-width":"120px"},"breakpoints":"xs sm"}, - {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, - {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota,"formatter": function(value){ - res = value.split("/"); - return humanFileSize(res[0]) + " / " + humanFileSize(res[1]); - }, - "sortValue": function(value){ - res = value.split("/"); - return res[0]; - }, - }, - {"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"xs sm md"}, - {"name":"in_use","filterable": false,"type":"html","title":lang.in_use}, - {"name":"messages","filterable": false,"title":lang.msg_num,"breakpoints":"xs sm md"}, - {"name":"active","filterable": false,"title":lang.active}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"250px"},"type":"html","title":lang.action,"breakpoints":"xs sm md"} - ], - "empty": lang.empty, - "rows": data, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table + {"name":"max_quota_for_mbox","title":lang.mailbox_quota,"breakpoints":"xs sm"}, + {"name":"backupmx","filterable": false,"style":{"maxWidth":"120px","width":"120px"},"title":lang.backup_mx,"breakpoints":"xs sm"}, + {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, + ], + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/domain/all', + jsonp: false, + error: function () { + alert('Cannot draw domain table'); }, - "sorting": { - "enabled": true - } - }); - } - }); - - $.ajax({ - dataType: 'json', - url: '/api/v1/get/resource/all', - jsonp: false, - error: function () { - alert('Cannot draw resource table'); - }, - success: function (data) { - $.each(data, function (i, item) { - item.action = ''; - }); - $('#resources_table').footable({ - "columns": [ - {"sorted": true,"name":"description","title":lang.description,"style":{"width":"250px"}}, - {"name":"kind","title":lang.kind}, - {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, - {"name":"multiple_bookings","filterable": false,"style":{"maxWidth":"120px","width":"120px"},"title":lang.multiple_bookings,"breakpoints":"xs sm"}, - {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "empty": lang.empty, - "rows": data, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true - } - }); - } - }); - - $.ajax({ - dataType: 'json', - url: '/api/v1/get/alias-domain/all', - jsonp: false, - error: function () { - alert('Cannot draw alias domain table'); - }, - success: function (data) { - $.each(data, function (i, item) { - item.action = ''; - }); - $('#aliasdomain_table').footable({ - "columns": [ - {"sorted": true,"name":"alias_domain","title":lang.alias,"style":{"width":"250px"}}, - {"name":"target_domain","title":lang.target_domain}, - {"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "empty": lang.empty, - "rows": data, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true - } - }); - } - }); - - $.ajax({ - dataType: 'json', - url: '/api/v1/get/alias/all', - jsonp: false, - error: function () { - alert('Cannot draw alias table'); - }, - success: function (data) { - $.each(data, function (i, item) { - item.action = ''; - item.chkbox = ''; - if (item.is_catch_all == 1) { - item.address = '
    Catch-All
    ' + item.address; - } - if (item.in_primary_domain !== "") { - item.domain = "↳ " + item.domain + " (" + item.in_primary_domain + ")"; - } - }); - ft_aliases = FooTable.init("#alias_table", { - "columns": [ - {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, - {"sorted": true,"name":"address","title":lang.alias,"style":{"width":"250px"}}, - {"name":"goto","title":lang.target_address}, - {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, - {"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active}, - {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} - ], - "empty": lang.empty, - "rows": data, - "paging": { - "enabled": true, - "limit": 5, - "size": pagination_size - }, - "filtering": { - "enabled": true, - "position": "left", - "placeholder": lang.filter_table - }, - "sorting": { - "enabled": true - } - }); - - var selected_aliases = []; - - $(document).on('click', 'tr', function(e) { - if (e.target.type == "checkbox") { - e.stopPropagation(); - } else { - var checkbox = $(this).find(':checkbox'); - checkbox.trigger('click'); - } - }); - - $(document).on('change', 'input[name=sel_aliases]:checkbox', function() { - if ($(this).is(':checked')) { - selected_aliases.push($(this).val()); - } - else { - selected_aliases.splice($.inArray($(this).val(), selected_aliases),1); - } - }); - - $(document).on('click', '#select_all_aliases', function(e) { - e.preventDefault(); - var alias_chkbxs = $("input[name=sel_aliases]"); - alias_chkbxs.prop("checked", !alias_chkbxs.prop("checked")).change(); - }); - - $(document).on('click', '#activate_selected_alias', function(e) { - e.preventDefault(); - if (Object.keys(selected_aliases).length !== 0) { - $.ajax({ - type: "POST", - dataType: "json", - data: { "address": JSON.stringify(selected_aliases), "active": "1" }, - url: '/api/v1/edit/alias', - jsonp: false, - complete: function (data) { - window.location.href = window.location.href; + success: function (data) { + $.each(data, function (i, item) { + item.aliases = item.aliases_in_domain + " / " + item.max_num_aliases_for_domain; + item.mailboxes = item.mboxes_in_domain + " / " + item.max_num_mboxes_for_domain; + item.quota = item.quota_used_in_domain + "/" + item.max_quota_for_domain; + item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox); + item.chkbox = ''; + if (role == "admin") { + item.action = ''; + } + else { + item.action = '
    ' + + ' ' + lang.edit + '' + + '
    '; } }); } - }); + }), + "empty": lang.empty, + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } + function draw_mailbox_table() { + ft_mailbox_table = FooTable.init('#mailbox_table', { + "columns": [ + {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, + {"sorted": true,"name":"username","style":{"word-break":"break-all","min-width":"120px"},"title":lang.username}, + {"name":"name","title":lang.fname,"style":{"word-break":"break-all","min-width":"120px"},"breakpoints":"xs sm"}, + {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, + {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota,"formatter": function(value){ + res = value.split("/"); + return humanFileSize(res[0]) + " / " + humanFileSize(res[1]); + }, + "sortValue": function(value){ + res = value.split("/"); + return res[0]; + }, + }, + {"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"xs sm md"}, + {"name":"in_use","filterable": false,"type":"html","title":lang.in_use}, + {"name":"messages","filterable": false,"title":lang.msg_num,"breakpoints":"xs sm md"}, + {"name":"active","filterable": false,"title":lang.active}, + {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"250px"},"type":"html","title":lang.action,"breakpoints":"xs sm md"} + ], + "empty": lang.empty, + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/mailbox/all', + jsonp: false, + error: function () { + alert('Cannot draw mailbox table'); + }, + success: function (data) { + $.each(data, function (i, item) { + item.quota = item.quota_used + "/" + item.quota; + item.max_quota_for_mbox = humanFileSize(item.max_quota_for_mbox); + item.chkbox = ''; + if (role == "admin") { + item.action = ''; + } + else { + item.action = ''; + } + item.in_use = '
    ' + + '
    ' + item.percent_in_use + '%' + '
    '; - $(document).on('click', '#deactivate_selected_alias', function(e) { - e.preventDefault(); - if (Object.keys(selected_aliases).length !== 0) { - $.ajax({ - type: "POST", - dataType: "json", - data: { "address": JSON.stringify(selected_aliases), "active": "0" }, - url: '/api/v1/edit/alias', - jsonp: false, - complete: function (data) { - window.location.href = window.location.href; + }); + } + }), + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } + function draw_resource_table() { + ft_resource_table = FooTable.init('#resource_table', { + "columns": [ + {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, + {"sorted": true,"name":"description","title":lang.description,"style":{"width":"250px"}}, + {"name":"kind","title":lang.kind}, + {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, + {"name":"multiple_bookings","filterable": false,"style":{"maxWidth":"120px","width":"120px"},"title":lang.multiple_bookings,"breakpoints":"xs sm"}, + {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, + {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} + ], + "empty": lang.empty, + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/resource/all', + jsonp: false, + error: function () { + alert('Cannot draw resource table'); + }, + success: function (data) { + $.each(data, function (i, item) { + item.action = ''; + item.chkbox = ''; + }); + } + }), + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } + + function draw_alias_table() { + ft_alias_table = FooTable.init('#alias_table', { + "columns": [ + {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, + {"sorted": true,"name":"address","title":lang.alias,"style":{"width":"250px"}}, + {"name":"goto","title":lang.target_address}, + {"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, + {"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active}, + {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} + ], + "empty": lang.empty, + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/alias/all', + jsonp: false, + error: function () { + alert('Cannot draw alias table'); + }, + success: function (data) { + $.each(data, function (i, item) { + item.action = ''; + item.chkbox = ''; + if (item.is_catch_all == 1) { + item.address = '
    Catch-All
    ' + item.address; + } + if (item.in_primary_domain !== "") { + item.domain = "↳ " + item.domain + " (" + item.in_primary_domain + ")"; } }); } - }); - - $(document).on('click', '#delete_selected_alias', function(e) { - e.preventDefault(); - if (Object.keys(selected_aliases).length !== 0) { - $(document).on('show.bs.modal','#ConfirmDeleteModal', function () { - $("#ItemsToDelete").empty(); - for (var i in selected_aliases) { - $("#ItemsToDelete").append("
  • " + selected_aliases[i] + "
  • "); - } - }) - $('#ConfirmDeleteModal').modal({ - backdrop: 'static', - keyboard: false - }) - .one('click', '#IsConfirmed', function(e) { - $.ajax({ - type: "POST", - dataType: "json", - data: { "address": JSON.stringify(selected_aliases) }, - url: '/api/v1/delete/alias', - jsonp: false, - complete: function (data) { - window.location.href = window.location.href; - } - }); - }) - .one('click', '#isCanceled', function(e) { - $('#ConfirmDeleteModal').modal('hide'); - });; + }), + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } + function draw_aliasdomain_table() { + ft_aliasdomain_table = FooTable.init('#aliasdomain_table', { + "columns": [ + {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"}, + {"sorted": true,"name":"alias_domain","title":lang.alias,"style":{"width":"250px"}}, + {"name":"target_domain","title":lang.target_domain}, + {"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active}, + {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} + ], + "empty": lang.empty, + "rows": $.ajax({ + dataType: 'json', + url: '/api/v1/get/alias-domain/all', + jsonp: false, + error: function () { + alert('Cannot draw alias domain table'); + }, + success: function (data) { + $.each(data, function (i, item) { + item.action = ''; + item.chkbox = ''; + }); } - }); + }), + "paging": { + "enabled": true, + "limit": 5, + "size": pagination_size + }, + "filtering": { + "enabled": true, + "position": "left", + "placeholder": lang.filter_table + }, + "sorting": { + "enabled": true + } + }); + } - } - - }); -}); + draw_domain_table(); + draw_mailbox_table(); + draw_resource_table(); + draw_alias_table(); + draw_aliasdomain_table(); +}); \ No newline at end of file diff --git a/data/web/js/notify.min.js b/data/web/js/notify.min.js deleted file mode 100644 index 6766fd1d..00000000 --- a/data/web/js/notify.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(e){typeof define=="function"&&define.amd?define(["jquery"],e):typeof module=="object"&&module.exports?module.exports=function(t,n){return n===undefined&&(typeof window!="undefined"?n=require("jquery"):n=require("jquery")(t)),e(n),n}:e(jQuery)})(function(e){function A(t,n,i){typeof i=="string"&&(i={className:i}),this.options=E(w,e.isPlainObject(i)?i:{}),this.loadHTML(),this.wrapper=e(h.html),this.options.clickToHide&&this.wrapper.addClass(r+"-hidable"),this.wrapper.data(r,this),this.arrow=this.wrapper.find("."+r+"-arrow"),this.container=this.wrapper.find("."+r+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=N(t),this.elem.data(r,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(n)}var t=[].indexOf||function(e){for(var t=0,n=this.length;t\n
    \n
    \n
    ',css:"."+r+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+r+"-corner ."+r+"-wrapper,\n."+r+"-corner ."+r+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+r+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+r+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n}\n\n."+r+"-hidable {\n cursor: pointer;\n}\n\n[data-notify-text],[data-notify-html] {\n position: relative;\n}\n\n."+r+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},p={"border-radius":["-webkit-","-moz-"]},d=function(e){return c[e]},v=function(e){if(!e)throw"Missing Style name";c[e]&&delete c[e]},m=function(t,i){if(!t)throw"Missing Style name";if(!i)throw"Missing Style definition";if(!i.html)throw"Missing Style HTML";var s=c[t];s&&s.cssElem&&(window.console&&console.warn(n+": overwriting style '"+t+"'"),c[t].cssElem.remove()),i.name=t,c[t]=i;var o="";i.classes&&e.each(i.classes,function(t,n){return o+="."+r+"-"+i.name+"-"+t+" {\n",e.each(n,function(t,n){return p[t]&&e.each(p[t],function(e,r){return o+=" "+r+t+": "+n+";\n"}),o+=" "+t+": "+n+";\n"}),o+="}\n"}),i.css&&(o+="/* styles for "+i.name+" */\n"+i.css),o&&(i.cssElem=g(o),i.cssElem.attr("id","notify-"+i.name));var u={},a=e(i.html);y("html",a,u),y("text",a,u),i.fields=u},g=function(t){var n,r,i;r=x("style"),r.attr("type","text/css"),e("head").append(r);try{r.html(t)}catch(s){r[0].styleSheet.cssText=t}return r},y=function(t,n,r){var s;return t!=="html"&&(t="text"),s="data-notify-"+t,b(n,"["+s+"]").each(function(){var n;n=e(this).attr(s),n||(n=i),r[n]=t})},b=function(e,t){return e.is(t)?e:e.find(t)},w={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,breakNewLines:!0,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},E=function(t,n){var r;return r=function(){},r.prototype=t,e.extend(!0,new r,n)},S=function(t){return e.extend(w,t)},x=function(t){return e("<"+t+">")},T={},N=function(t){var n;return t.is("[type=radio]")&&(n=t.parents("form:first").find("[type=radio]").filter(function(n,r){return e(r).attr("name")===t.attr("name")}),t=n.first()),t},C=function(e,t,n){var r,i;if(typeof n=="string")n=parseInt(n,10);else if(typeof n!="number")return;if(isNaN(n))return;return r=s[f[t.charAt(0)]],i=t,e[r]!==undefined&&(t=s[r.charAt(0)],n=-n),e[t]===undefined?e[t]=n:e[t]+=n,null},k=function(e,t,n){if(e==="l"||e==="t")return 0;if(e==="c"||e==="m")return n/2-t/2;if(e==="r"||e==="b")return n-t;throw"Invalid alignment"},L=function(e){return L.e=L.e||x("div"),L.e.text(e).html()};A.prototype.loadHTML=function(){var t;t=this.getStyle(),this.userContainer=e(t.html),this.userFields=t.fields},A.prototype.show=function(e,t){var n,r,i,s,o;r=function(n){return function(){!e&&!n.elem&&n.destroy();if(t)return t()}}(this),o=this.container.parent().parents(":hidden").length>0,i=this.container.add(this.arrow),n=[];if(o&&e)s="show";else if(o&&!e)s="hide";else if(!o&&e)s=this.options.showAnimation,n.push(this.options.showDuration);else{if(!!o||!!e)return r();s=this.options.hideAnimation,n.push(this.options.hideDuration)}return n.push(r),i[s].apply(i,n)},A.prototype.setGlobalPosition=function(){var t=this.getPosition(),n=t[0],i=t[1],o=s[n],u=s[i],a=n+"|"+i,f=T[a];if(!f||!document.body.contains(f[0])){f=T[a]=x("div");var l={};l[o]=0,u==="middle"?l.top="45%":u==="center"?l.left="45%":l[u]=0,f.css(l).addClass(r+"-corner"),e("body").append(f)}return f.prepend(this.wrapper)},A.prototype.setElementPosition=function(){var n,r,i,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,L,A,O,M,_,D,P,H,B,j;H=this.getPosition(),_=H[0],O=H[1],M=H[2],g=this.elem.position(),d=this.elem.outerHeight(),y=this.elem.outerWidth(),v=this.elem.innerHeight(),m=this.elem.innerWidth(),j=this.wrapper.position(),c=this.container.height(),h=this.container.width(),T=s[_],L=f[_],A=s[L],p={},p[A]=_==="b"?d:_==="r"?y:0,C(p,"top",g.top-j.top),C(p,"left",g.left-j.left),B=["top","left"];for(w=0,S=B.length;w=0&&C(r,s[O],i*2)}t.call(u,_)>=0?(C(p,"left",k(O,h,y)),r&&C(r,"left",k(O,i,m))):t.call(o,_)>=0&&(C(p,"top",k(O,c,d)),r&&C(r,"top",k(O,i,v))),this.container.is(":visible")&&(p.display="block"),this.container.removeAttr("style").css(p);if(r)return this.arrow.removeAttr("style").css(r)},A.prototype.getPosition=function(){var e,n,r,i,s,f,c,h;h=this.options.position||(this.elem?this.options.elementPosition:this.options.globalPosition),e=l(h),e.length===0&&(e[0]="b");if(n=e[0],t.call(a,n)<0)throw"Must be one of ["+a+"]";if(e.length===1||(r=e[0],t.call(u,r)>=0)&&(i=e[1],t.call(o,i)<0)||(s=e[0],t.call(o,s)>=0)&&(f=e[1],t.call(u,f)<0))e[1]=(c=e[0],t.call(o,c)>=0)?"m":"l";return e.length===2&&(e[2]=e[1]),e},A.prototype.getStyle=function(e){var t;e||(e=this.options.style),e||(e="default"),t=c[e];if(!t)throw"Missing style: "+e;return t},A.prototype.updateClasses=function(){var t,n;return t=["base"],e.isArray(this.options.className)?t=t.concat(this.options.className):this.options.className&&t.push(this.options.className),n=this.getStyle(),t=e.map(t,function(e){return r+"-"+n.name+"-"+e}).join(" "),this.userContainer.attr("class",t)},A.prototype.run=function(t,n){var r,s,o,u,a;e.isPlainObject(n)?e.extend(this.options,n):e.type(n)==="string"&&(this.options.className=n);if(this.container&&!t){this.show(!1);return}if(!this.container&&!t)return;s={},e.isPlainObject(t)?s=t:s[i]=t;for(o in s){r=s[o],u=this.userFields[o];if(!u)continue;u==="text"&&(r=L(r),this.options.breakNewLines&&(r=r.replace(/\n/g,"
    "))),a=o===i?"":"="+o,b(this.userContainer,"[data-notify-"+u+a+"]").html(r)}this.updateClasses(),this.elem?this.setElementPosition():this.setGlobalPosition(),this.show(!0),this.options.autoHide&&(clearTimeout(this.autohideTimer),this.autohideTimer=setTimeout(this.show.bind(this,!1),this.options.autoHideDelay))},A.prototype.destroy=function(){this.wrapper.data(r,null),this.wrapper.remove()},e[n]=function(t,r,i){return t&&t.nodeName||t.jquery?e(t)[n](r,i):(i=r,r=t,new A(null,r,i)),t},e.fn[n]=function(t,n){return e(this).each(function(){var i=N(e(this)).data(r);i&&i.destroy();var s=new A(e(this),t,n)}),this},e.extend(e[n],{defaults:S,addStyle:m,removeStyle:v,pluginOptions:w,getStyle:d,insertCSS:g}),m("bootstrap",{html:"
    \n\n
    ",classes:{base:{"font-weight":"bold",padding:"8px 15px 8px 14px","text-shadow":"0 1px 0 rgba(255, 255, 255, 0.5)","background-color":"#fcf8e3",border:"1px solid #fbeed5","border-radius":"4px","white-space":"nowrap","padding-left":"25px","background-repeat":"no-repeat","background-position":"3px 7px"},error:{color:"#B94A48","background-color":"#F2DEDE","border-color":"#EED3D7","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=)"},success:{color:"#468847","background-color":"#DFF0D8","border-color":"#D6E9C6","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAutJREFUeNq0lctPE0Ecx38zu/RFS1EryqtgJFA08YCiMZIAQQ4eRG8eDGdPJiYeTIwHTfwPiAcvXIwXLwoXPaDxkWgQ6islKlJLSQWLUraPLTv7Gme32zoF9KSTfLO7v53vZ3d/M7/fIth+IO6INt2jjoA7bjHCJoAlzCRw59YwHYjBnfMPqAKWQYKjGkfCJqAF0xwZjipQtA3MxeSG87VhOOYegVrUCy7UZM9S6TLIdAamySTclZdYhFhRHloGYg7mgZv1Zzztvgud7V1tbQ2twYA34LJmF4p5dXF1KTufnE+SxeJtuCZNsLDCQU0+RyKTF27Unw101l8e6hns3u0PBalORVVVkcaEKBJDgV3+cGM4tKKmI+ohlIGnygKX00rSBfszz/n2uXv81wd6+rt1orsZCHRdr1Imk2F2Kob3hutSxW8thsd8AXNaln9D7CTfA6O+0UgkMuwVvEFFUbbAcrkcTA8+AtOk8E6KiQiDmMFSDqZItAzEVQviRkdDdaFgPp8HSZKAEAL5Qh7Sq2lIJBJwv2scUqkUnKoZgNhcDKhKg5aH+1IkcouCAdFGAQsuWZYhOjwFHQ96oagWgRoUov1T9kRBEODAwxM2QtEUl+Wp+Ln9VRo6BcMw4ErHRYjH4/B26AlQoQQTRdHWwcd9AH57+UAXddvDD37DmrBBV34WfqiXPl61g+vr6xA9zsGeM9gOdsNXkgpEtTwVvwOklXLKm6+/p5ezwk4B+j6droBs2CsGa/gNs6RIxazl4Tc25mpTgw/apPR1LYlNRFAzgsOxkyXYLIM1V8NMwyAkJSctD1eGVKiq5wWjSPdjmeTkiKvVW4f2YPHWl3GAVq6ymcyCTgovM3FzyRiDe2TaKcEKsLpJvNHjZgPNqEtyi6mZIm4SRFyLMUsONSSdkPeFtY1n0mczoY3BHTLhwPRy9/lzcziCw9ACI+yql0VLzcGAZbYSM5CCSZg1/9oc/nn7+i8N9p/8An4JMADxhH+xHfuiKwAAAABJRU5ErkJggg==)"},info:{color:"#3A87AD","background-color":"#D9EDF7","border-color":"#BCE8F1","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QYFAhkSsdes/QAAA8dJREFUOMvVlGtMW2UYx//POaWHXg6lLaW0ypAtw1UCgbniNOLcVOLmAjHZolOYlxmTGXVZdAnRfXQm+7SoU4mXaOaiZsEpC9FkiQs6Z6bdCnNYruM6KNBw6YWewzl9z+sHImEWv+vz7XmT95f/+3/+7wP814v+efDOV3/SoX3lHAA+6ODeUFfMfjOWMADgdk+eEKz0pF7aQdMAcOKLLjrcVMVX3xdWN29/GhYP7SvnP0cWfS8caSkfHZsPE9Fgnt02JNutQ0QYHB2dDz9/pKX8QjjuO9xUxd/66HdxTeCHZ3rojQObGQBcuNjfplkD3b19Y/6MrimSaKgSMmpGU5WevmE/swa6Oy73tQHA0Rdr2Mmv/6A1n9w9suQ7097Z9lM4FlTgTDrzZTu4StXVfpiI48rVcUDM5cmEksrFnHxfpTtU/3BFQzCQF/2bYVoNbH7zmItbSoMj40JSzmMyX5qDvriA7QdrIIpA+3cdsMpu0nXI8cV0MtKXCPZev+gCEM1S2NHPvWfP/hL+7FSr3+0p5RBEyhEN5JCKYr8XnASMT0xBNyzQGQeI8fjsGD39RMPk7se2bd5ZtTyoFYXftF6y37gx7NeUtJJOTFlAHDZLDuILU3j3+H5oOrD3yWbIztugaAzgnBKJuBLpGfQrS8wO4FZgV+c1IxaLgWVU0tMLEETCos4xMzEIv9cJXQcyagIwigDGwJgOAtHAwAhisQUjy0ORGERiELgG4iakkzo4MYAxcM5hAMi1WWG1yYCJIcMUaBkVRLdGeSU2995TLWzcUAzONJ7J6FBVBYIggMzmFbvdBV44Corg8vjhzC+EJEl8U1kJtgYrhCzgc/vvTwXKSib1paRFVRVORDAJAsw5FuTaJEhWM2SHB3mOAlhkNxwuLzeJsGwqWzf5TFNdKgtY5qHp6ZFf67Y/sAVadCaVY5YACDDb3Oi4NIjLnWMw2QthCBIsVhsUTU9tvXsjeq9+X1d75/KEs4LNOfcdf/+HthMnvwxOD0wmHaXr7ZItn2wuH2SnBzbZAbPJwpPx+VQuzcm7dgRCB57a1uBzUDRL4bfnI0RE0eaXd9W89mpjqHZnUI5Hh2l2dkZZUhOqpi2qSmpOmZ64Tuu9qlz/SEXo6MEHa3wOip46F1n7633eekV8ds8Wxjn37Wl63VVa+ej5oeEZ/82ZBETJjpJ1Rbij2D3Z/1trXUvLsblCK0XfOx0SX2kMsn9dX+d+7Kf6h8o4AIykuffjT8L20LU+w4AZd5VvEPY+XpWqLV327HR7DzXuDnD8r+ovkBehJ8i+y8YAAAAASUVORK5CYII=)"},warn:{color:"#C09853","background-color":"#FCF8E3","border-color":"#FBEED5","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABJlBMVEXr6eb/2oD/wi7/xjr/0mP/ykf/tQD/vBj/3o7/uQ//vyL/twebhgD/4pzX1K3z8e349vK6tHCilCWbiQymn0jGworr6dXQza3HxcKkn1vWvV/5uRfk4dXZ1bD18+/52YebiAmyr5S9mhCzrWq5t6ufjRH54aLs0oS+qD751XqPhAybhwXsujG3sm+Zk0PTwG6Shg+PhhObhwOPgQL4zV2nlyrf27uLfgCPhRHu7OmLgAafkyiWkD3l49ibiAfTs0C+lgCniwD4sgDJxqOilzDWowWFfAH08uebig6qpFHBvH/aw26FfQTQzsvy8OyEfz20r3jAvaKbhgG9q0nc2LbZxXanoUu/u5WSggCtp1anpJKdmFz/zlX/1nGJiYmuq5Dx7+sAAADoPUZSAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfdBgUBGhh4aah5AAAAlklEQVQY02NgoBIIE8EUcwn1FkIXM1Tj5dDUQhPU502Mi7XXQxGz5uVIjGOJUUUW81HnYEyMi2HVcUOICQZzMMYmxrEyMylJwgUt5BljWRLjmJm4pI1hYp5SQLGYxDgmLnZOVxuooClIDKgXKMbN5ggV1ACLJcaBxNgcoiGCBiZwdWxOETBDrTyEFey0jYJ4eHjMGWgEAIpRFRCUt08qAAAAAElFTkSuQmCC)"}}}),e(function(){g(h.css).attr("id","core-notify"),e(document).on("click","."+r+"-hidable",function(t){e(this).trigger("notify-hide")}),e(document).on("notify-hide","."+r+"-wrapper",function(t){var n=e(this).data(r);n&&n.show(!1)})})}) \ No newline at end of file diff --git a/data/web/js/noty.min.js b/data/web/js/noty.min.js deleted file mode 100644 index 2cdeac52..00000000 --- a/data/web/js/noty.min.js +++ /dev/null @@ -1,9 +0,0 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Noty",[],e):"object"==typeof exports?exports.Noty=e():t.Noty=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=6)}([function(t,e,n){"use strict";function o(t,e,n){var o=void 0;if(!n){for(o in e)if(e.hasOwnProperty(o)&&e[o]===t)return!0}else for(o in e)if(e.hasOwnProperty(o)&&e[o]===t)return!0;return!1}function i(t){t=t||window.event,void 0!==t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e="noty_"+t+"_";return e+="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function s(t){var e=t.offsetHeight,n=window.getComputedStyle(t);return e+=parseInt(n.marginTop)+parseInt(n.marginBottom)}function u(t,e,n){var o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e=e.split(" ");for(var i=0;i=0}function c(t,e){var n=f(t),o=n+e;a(n,e)||(t.className=o.substring(1))}function l(t,e){var n=f(t),o=void 0;a(t,e)&&(o=n.replace(" "+e+" "," "),t.className=o.substring(1,o.length-1))}function d(t){t.parentNode&&t.parentNode.removeChild(t)}function f(t){return(" "+(t&&t.className||"")+" ").replace(/\s+/gi," ")}function h(){function t(){b.PageHidden=document[s],o()}function e(){b.PageHidden=!0,o()}function n(){b.PageHidden=!1,o()}function o(){b.PageHidden?i():r()}function i(){setTimeout(function(){Object.keys(b.Store).forEach(function(t){b.Store.hasOwnProperty(t)&&b.Store[t].options.visibilityControl&&b.Store[t].stop()})},100)}function r(){setTimeout(function(){Object.keys(b.Store).forEach(function(t){b.Store.hasOwnProperty(t)&&b.Store[t].options.visibilityControl&&b.Store[t].resume()}),b.queueRenderAll()},100)}var s=void 0,a=void 0;void 0!==document.hidden?(s="hidden",a="visibilitychange"):void 0!==document.msHidden?(s="msHidden",a="msvisibilitychange"):void 0!==document.webkitHidden&&(s="webkitHidden",a="webkitvisibilitychange"),u(document,a,t),u(window,"blur",e),u(window,"focus",n)}function p(t){if(t.hasSound){var e=document.createElement("audio");t.options.sounds.sources.forEach(function(t){var n=document.createElement("source");n.src=t,n.type="audio/"+m(t),e.appendChild(n)}),t.barDom?t.barDom.appendChild(e):document.querySelector("body").appendChild(e),e.volume=t.options.sounds.volume,t.soundPlayed||(e.play(),t.soundPlayed=!0),e.onended=function(){d(e)}}}function m(t){return t.match(/\.([^.]+)$/)[1]}Object.defineProperty(e,"__esModule",{value:!0}),e.css=e.deepExtend=e.animationEndEvents=void 0;var v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.inArray=o,e.stopPropagation=i,e.generateID=r,e.outerHeight=s,e.addListener=u,e.hasClass=a,e.addClass=c,e.removeClass=l,e.remove=d,e.classList=f,e.visibilityChangeFlow=h,e.createAudioElements=p;var y=n(1),b=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(y);e.animationEndEvents="webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",e.deepExtend=function t(e){e=e||{};for(var n=1;n0&&void 0!==arguments[0]?arguments[0]:"global",e=0,n=x;return E.hasOwnProperty(t)&&(n=E[t].maxVisible,Object.keys(P).forEach(function(n){P[n].options.queue!==t||P[n].closed||e++})),{current:e,maxVisible:n}}function i(t){E.hasOwnProperty(t.options.queue)||(E[t.options.queue]={maxVisible:x,queue:[]}),E[t.options.queue].queue.push(t)}function r(t){if(E.hasOwnProperty(t.options.queue)){var e=[];Object.keys(E[t.options.queue].queue).forEach(function(n){E[t.options.queue].queue[n].id!==t.id&&e.push(E[t.options.queue].queue[n])}),E[t.options.queue].queue=e}}function s(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"global";if(E.hasOwnProperty(t)){var e=E[t].queue.shift();e&&e.show()}}function u(){Object.keys(E).forEach(function(t){s(t)})}function a(t){var e=k.generateID("ghost"),n=document.createElement("div");n.setAttribute("id",e),k.css(n,{height:k.outerHeight(t.barDom)+"px"}),t.barDom.insertAdjacentHTML("afterend",n.outerHTML),k.remove(t.barDom),n=document.getElementById(e),k.addClass(n,"noty_fix_effects_height"),k.addListener(n,k.animationEndEvents,function(){k.remove(n)})}function c(t){m(t);var e='
    '+t.options.text+"
    "+d(t)+'
    ';t.barDom=document.createElement("div"),t.barDom.setAttribute("id",t.id),k.addClass(t.barDom,"noty_bar noty_type__"+t.options.type+" noty_theme__"+t.options.theme),t.barDom.innerHTML=e,b(t,"onTemplate")}function l(t){return!(!t.options.buttons||!Object.keys(t.options.buttons).length)}function d(t){if(l(t)){var e=document.createElement("div");return k.addClass(e,"noty_buttons"),Object.keys(t.options.buttons).forEach(function(n){e.appendChild(t.options.buttons[n].dom)}),t.options.buttons.forEach(function(t){e.appendChild(t.dom)}),e.outerHTML}return""}function f(t){t.options.modal&&(0===S&&p(),e.DocModalCount=S+=1)}function h(t){if(t.options.modal&&S>0&&(e.DocModalCount=S-=1,S<=0)){var n=document.querySelector(".noty_modal");n&&(k.removeClass(n,"noty_modal_open"),k.addClass(n,"noty_modal_close"),k.addListener(n,k.animationEndEvents,function(){k.remove(n)}))}}function p(){var t=document.querySelector("body"),e=document.createElement("div");k.addClass(e,"noty_modal"),t.insertBefore(e,t.firstChild),k.addClass(e,"noty_modal_open"),k.addListener(e,k.animationEndEvents,function(){k.removeClass(e,"noty_modal_open")})}function m(t){if(t.options.container)return void(t.layoutDom=document.querySelector(t.options.container));var e="noty_layout__"+t.options.layout;t.layoutDom=document.querySelector("div#"+e),t.layoutDom||(t.layoutDom=document.createElement("div"),t.layoutDom.setAttribute("id",e),k.addClass(t.layoutDom,"noty_layout"),document.querySelector("body").appendChild(t.layoutDom))}function v(t){t.options.timeout&&(t.options.progressBar&&t.progressDom&&k.css(t.progressDom,{transition:"width "+t.options.timeout+"ms linear",width:"0%"}),clearTimeout(t.closeTimer),t.closeTimer=setTimeout(function(){t.close()},t.options.timeout))}function y(t){t.options.timeout&&t.closeTimer&&(clearTimeout(t.closeTimer),t.closeTimer=-1,t.options.progressBar&&t.progressDom&&k.css(t.progressDom,{transition:"width 0ms linear",width:"100%"}))}function b(t,e){t.listeners.hasOwnProperty(e)&&t.listeners[e].forEach(function(e){"function"==typeof e&&e.apply(t)})}function w(t){b(t,"afterShow"),v(t),k.addListener(t.barDom,"mouseenter",function(){y(t)}),k.addListener(t.barDom,"mouseleave",function(){v(t)})}function g(t){delete P[t.id],t.closing=!1,b(t,"afterClose"),k.remove(t.barDom),0!==t.layoutDom.querySelectorAll(".noty_bar").length||t.options.container||k.remove(t.layoutDom),(k.inArray("docVisible",t.options.titleCount.conditions)||k.inArray("docHidden",t.options.titleCount.conditions))&&D.decrement(),s(t.options.queue)}Object.defineProperty(e,"__esModule",{value:!0}),e.Defaults=e.Store=e.Queues=e.DefaultMaxVisible=e.docTitle=e.DocModalCount=e.PageHidden=void 0,e.getQueueCounts=o,e.addToQueue=i,e.removeFromQueue=r,e.queueRender=s,e.queueRenderAll=u,e.ghostFix=a,e.build=c,e.hasButtons=l,e.handleModal=f,e.handleModalClose=h,e.queueClose=v,e.dequeueClose=y,e.fire=b,e.openFlow=w,e.closeFlow=g;var _=n(0),k=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(_),S=(e.PageHidden=!1,e.DocModalCount=0),C={originalTitle:null,count:0,changed:!1,timer:-1},D=e.docTitle={increment:function(){C.count++,D._update()},decrement:function(){if(--C.count<=0)return void D._clear();D._update()},_update:function(){var t=document.title;C.changed?document.title="("+C.count+") "+C.originalTitle:(C.originalTitle=t,document.title="("+C.count+") "+t,C.changed=!0)},_clear:function(){C.changed&&(C.count=0,document.title=C.originalTitle,C.changed=!1)}},x=e.DefaultMaxVisible=5,E=e.Queues={global:{maxVisible:x,queue:[]}},P=e.Store={};e.Defaults={type:"alert",layout:"topRight",theme:"mint",text:"",timeout:!1,progressBar:!0,closeWith:["click"],animation:{open:"noty_effects_open",close:"noty_effects_close"},id:!1,force:!1,killer:!1,queue:"global",container:!1,buttons:[],callbacks:{beforeShow:null,onShow:null,afterShow:null,onClose:null,afterClose:null,onHover:null,onTemplate:null},sounds:{sources:[],volume:1,conditions:[]},titleCount:{conditions:[]},modal:!1,visibilityControl:!0}},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.NotyButton=void 0;var i=n(0),r=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(i);e.NotyButton=function t(e,n,i){var s=this,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return o(this,t),this.dom=document.createElement("button"),this.dom.innerHTML=e,this.id=u.id=u.id||r.generateID("button"),this.cb=i,Object.keys(u).forEach(function(t){s.dom.setAttribute(t,u[t])}),r.addClass(this.dom,n||"noty_btn"),this}},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"/service-worker.js";return o(this,t),this.subData={},this.workerPath=e,this.listeners={onPermissionGranted:[],onPermissionDenied:[],onSubscriptionSuccess:[],onSubscriptionCancel:[],onWorkerError:[],onWorkerSuccess:[],onWorkerNotSupported:[]},this}return i(t,[{key:"on",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return"function"==typeof e&&this.listeners.hasOwnProperty(t)&&this.listeners[t].push(e),this}},{key:"fire",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.listeners.hasOwnProperty(t)&&this.listeners[t].forEach(function(t){"function"==typeof t&&t.apply(e,n)})}},{key:"create",value:function(){console.log("NOT IMPLEMENTED YET")}},{key:"isSupported",value:function(){var t=!1;try{t=window.Notification||window.webkitNotifications||navigator.mozNotification||window.external&&void 0!==window.external.msIsSiteMode()}catch(t){}return t}},{key:"getPermissionStatus",value:function(){var t="default";if(window.Notification&&window.Notification.permissionLevel)t=window.Notification.permissionLevel;else if(window.webkitNotifications&&window.webkitNotifications.checkPermission)switch(window.webkitNotifications.checkPermission()){case 1:t="default";break;case 0:t="granted";break;default:t="denied"}else window.Notification&&window.Notification.permission?t=window.Notification.permission:navigator.mozNotification?t="granted":window.external&&void 0!==window.external.msIsSiteMode()&&(t=window.external.msIsSiteMode()?"granted":"default");return t.toString().toLowerCase()}},{key:"getEndpoint",value:function(t){var e=t.endpoint,n=t.subscriptionId;return n&&-1===e.indexOf(n)&&(e+="/"+n),e}},{key:"isSWRegistered",value:function(){try{return"activated"===navigator.serviceWorker.controller.state}catch(t){return!1}}},{key:"unregisterWorker",value:function(){var t=this;"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(function(e){var n=!0,o=!1,i=void 0;try{for(var r,s=e[Symbol.iterator]();!(n=(r=s.next()).done);n=!0){r.value.unregister(),t.fire("onSubscriptionCancel")}}catch(t){o=!0,i=t}finally{try{!n&&s.return&&s.return()}finally{if(o)throw i}}})}},{key:"requestSubscription",value:function(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=this,o=this.getPermissionStatus(),i=function(o){"granted"===o?(t.fire("onPermissionGranted"),"serviceWorker"in navigator?navigator.serviceWorker.register(t.workerPath).then(function(){navigator.serviceWorker.ready.then(function(t){n.fire("onWorkerSuccess"),t.pushManager.subscribe({userVisibleOnly:e}).then(function(t){var e=t.getKey("p256dh"),o=t.getKey("auth");n.subData={endpoint:n.getEndpoint(t),p256dh:e?window.btoa(String.fromCharCode.apply(null,new Uint8Array(e))):null,auth:o?window.btoa(String.fromCharCode.apply(null,new Uint8Array(o))):null},n.fire("onSubscriptionSuccess",[n.subData])}).catch(function(t){n.fire("onWorkerError",[t])})})}):n.fire("onWorkerNotSupported")):"denied"===o&&(t.fire("onPermissionDenied"),t.unregisterWorker())};"default"===o?window.Notification&&window.Notification.requestPermission?window.Notification.requestPermission(i):window.webkitNotifications&&window.webkitNotifications.checkPermission&&window.webkitNotifications.requestPermission(i):i(o)}}]),t}()},function(t,e,n){(function(e,o){/*! - * @overview es6-promise - a tiny implementation of Promises/A+. - * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE - * @version 4.1.0 - */ -!function(e,n){t.exports=n()}(0,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function r(t){z=t}function s(t){U=t}function u(){return void 0!==R?function(){R(c)}:a()}function a(){var t=setTimeout;return function(){return t(c,1)}}function c(){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{};return i(this,t),this.options=c.deepExtend({},d.Defaults,e),this.id=this.options.id||c.generateID("bar"),this.closeTimer=-1,this.barDom=null,this.layoutDom=null,this.progressDom=null,this.showing=!1,this.shown=!1,this.closed=!1,this.closing=!1,this.killable=this.options.timeout||this.options.closeWith.length>0,this.hasSound=this.options.sounds.sources.length>0,this.soundPlayed=!1,this.listeners={beforeShow:[],onShow:[],afterShow:[],onClose:[],afterClose:[],onHover:[],onTemplate:[]},this.promises={show:null,close:null},this.on("beforeShow",this.options.callbacks.beforeShow),this.on("onShow",this.options.callbacks.onShow),this.on("afterShow",this.options.callbacks.afterShow),this.on("onClose",this.options.callbacks.onClose),this.on("afterClose",this.options.callbacks.afterClose),this.on("onHover",this.options.callbacks.onHover),this.on("onTemplate",this.options.callbacks.onTemplate),this}return r(t,[{key:"on",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return"function"==typeof e&&this.listeners.hasOwnProperty(t)&&this.listeners[t].push(e),this}},{key:"show",value:function(){var e=this;if(!0!==this.options.killer||d.PageHidden)if("string"!=typeof this.options.killer||d.PageHidden){var n=d.getQueueCounts(this.options.queue);if(n.current>=n.maxVisible||d.PageHidden)return d.addToQueue(this),d.PageHidden&&this.hasSound&&c.inArray("docHidden",this.options.sounds.conditions)&&c.createAudioElements(this),d.PageHidden&&c.inArray("docHidden",this.options.titleCount.conditions)&&d.docTitle.increment(),this}else t.closeAll(this.options.killer);else t.closeAll();if(d.Store[this.id]=this,d.fire(this,"beforeShow"),this.showing=!0,this.closing)return this.showing=!1,this;if(d.build(this),d.handleModal(this),this.options.force?this.layoutDom.insertBefore(this.barDom,this.layoutDom.firstChild):this.layoutDom.appendChild(this.barDom),this.hasSound&&!this.soundPlayed&&c.inArray("docVisible",this.options.sounds.conditions)&&c.createAudioElements(this),c.inArray("docVisible",this.options.titleCount.conditions)&&d.docTitle.increment(),this.shown=!0,this.closed=!1,d.hasButtons(this)&&Object.keys(this.options.buttons).forEach(function(t){var n=e.barDom.querySelector("#"+e.options.buttons[t].id);c.addListener(n,"click",function(n){c.stopPropagation(n),e.options.buttons[t].cb()})}),this.progressDom=this.barDom.querySelector(".noty_progressbar"),c.inArray("click",this.options.closeWith)&&(c.addClass(this.barDom,"noty_close_with_click"),c.addListener(this.barDom,"click",function(t){c.stopPropagation(t),e.close()},!1)),c.addListener(this.barDom,"mouseenter",function(){d.fire(e,"onHover")},!1),this.options.timeout&&c.addClass(this.barDom,"noty_has_timeout"),c.inArray("button",this.options.closeWith)){c.addClass(this.barDom,"noty_close_with_button");var o=document.createElement("div");c.addClass(o,"noty_close_button"),o.innerHTML="×",this.barDom.appendChild(o),c.addListener(o,"click",function(t){c.stopPropagation(t),e.close()},!1)}return d.fire(this,"onShow"),null===this.options.animation.open?this.promises.show=new u.default(function(t){t()}):"function"==typeof this.options.animation.open?this.promises.show=new u.default(this.options.animation.open.bind(this)):(c.addClass(this.barDom,this.options.animation.open),this.promises.show=new u.default(function(t){c.addListener(e.barDom,c.animationEndEvents,function(){c.removeClass(e.barDom,e.options.animation.open),t()})})),this.promises.show.then(function(){var t=e;setTimeout(function(){d.openFlow(t)},100)}),this}},{key:"stop",value:function(){return d.dequeueClose(this),this}},{key:"resume",value:function(){return d.queueClose(this),this}},{key:"setTimeout",value:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(function(t){if(this.stop(),this.options.timeout=t,this.barDom){this.options.timeout?c.addClass(this.barDom,"noty_has_timeout"):c.removeClass(this.barDom,"noty_has_timeout");var e=this;setTimeout(function(){e.resume()},100)}return this})},{key:"setText",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.barDom&&(this.barDom.querySelector(".noty_body").innerHTML=t),e&&(this.options.text=t),this}},{key:"setType",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.barDom){c.classList(this.barDom).split(" ").forEach(function(t){"noty_type__"===t.substring(0,11)&&c.removeClass(e.barDom,t)}),c.addClass(this.barDom,"noty_type__"+t)}return n&&(this.options.type=t),this}},{key:"setTheme",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.barDom){c.classList(this.barDom).split(" ").forEach(function(t){"noty_theme__"===t.substring(0,12)&&c.removeClass(e.barDom,t)}),c.addClass(this.barDom,"noty_theme__"+t)}return n&&(this.options.theme=t),this}},{key:"close",value:function(){var t=this;return this.closed?this:this.shown?(d.fire(this,"onClose"),this.closing=!0,null===this.options.animation.close?this.promises.close=new u.default(function(t){t()}):"function"==typeof this.options.animation.close?this.promises.close=new u.default(this.options.animation.close.bind(this)):(c.addClass(this.barDom,this.options.animation.close),this.promises.close=new u.default(function(e){c.addListener(t.barDom,c.animationEndEvents,function(){t.options.force?c.remove(t.barDom):d.ghostFix(t),e()})})),this.promises.close.then(function(){d.closeFlow(t),d.handleModalClose(t)}),this.closed=!0,this):(d.removeFromQueue(this),this)}}],[{key:"closeAll",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Object.keys(d.Store).forEach(function(e){t?d.Store[e].options.queue===t&&d.Store[e].killable&&d.Store[e].close():d.Store[e].killable&&d.Store[e].close()}),this}},{key:"overrideDefaults",value:function(t){return d.Defaults=c.deepExtend({},d.Defaults,t),this}},{key:"setMaxVisible",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.DefaultMaxVisible,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"global";return d.Queues.hasOwnProperty(e)||(d.Queues[e]={maxVisible:t,queue:[]}),d.Queues[e].maxVisible=t,this}},{key:"button",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new f.NotyButton(t,e,n,o)}},{key:"version",value:function(){return"3.1.0"}},{key:"Push",value:function(t){return new h.Push(t)}}]),t}();e.default=p,c.visibilityChangeFlow(),t.exports=e.default},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(l===setTimeout)return setTimeout(t,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function r(t){if(d===clearTimeout)return clearTimeout(t);if((d===o||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(t);try{return d(t)}catch(e){try{return d.call(null,t)}catch(e){return d.call(this,t)}}}function s(){m&&h&&(m=!1,h.length?p=h.concat(p):v=-1,p.length&&u())}function u(){if(!m){var t=i(s);m=!0;for(var e=p.length;e;){for(h=p,p=[];++v1)for(var n=1;n 'success', - 'msg' => 'Cookie refreshed' - )); - } - else { - return; - } - break; default: echo '{}'; break; @@ -376,10 +364,10 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u case "delete": switch ($category) { case "alias": - if (isset($_POST['address'])) { - $address = json_decode($_POST['address'], true); - if (is_array($address)) { - if (mailbox_delete_alias(array('address' => $address)) === false) { + if (isset($_POST['items'])) { + $items = (array)json_decode($_POST['items'], true); + if (is_array($items)) { + if (mailbox_delete_alias(array('address' => $items)) === false) { if (isset($_SESSION['return'])) { echo json_encode($_SESSION['return']); } @@ -389,59 +377,79 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u 'msg' => 'Deletion of items/s failed' )); } - exit(); - } - if (isset($_SESSION['return'])) { - echo json_encode($_SESSION['return']); } else { - echo json_encode(array( - 'type' => 'success', - 'msg' => 'Item/s deleted: ' . $domains - )); + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } } } - } - break; - case "fwdhost": - if (isset($_POST['forwardinghost'])) { - $forwardinghost = (array)json_decode($_POST['forwardinghost'], true); - if (is_array($forwardinghost)) { - if (delete_forwarding_host(array('forwardinghost' => $forwardinghost)) === false) { - if (isset($_SESSION['return'])) { - echo json_encode($_SESSION['return']); - } - else { - echo json_encode(array( - 'type' => 'error', - 'msg' => 'Deletion of items/s failed' - )); - } - exit(); - } - if (isset($_SESSION['return'])) { - echo json_encode($_SESSION['return']); - } - else { - echo json_encode(array( - 'type' => 'success', - 'msg' => 'Item/s deleted: ' . $domains - )); - } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find address array in post data' + )); } } else { echo json_encode(array( 'type' => 'error', - 'msg' => 'Cannot find forwardinghost array in post data' + 'msg' => 'Cannot find items in post data' + )); + } + break; + case "fwdhost": + if (isset($_POST['items'])) { + $items = (array)json_decode($_POST['items'], true); + if (is_array($items)) { + if (delete_forwarding_host(array('forwardinghost' => $items)) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Deletion of items/s failed' + )); + } + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find forwardinghost array in post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find items in post data' )); } break; case "dkim": - if (isset($_POST['domains'])) { - $domains = (array)json_decode($_POST['domains'], true); - if (is_array($domains)) { - if (dkim_delete_key(array('domains' => $domains)) === false) { + if (isset($_POST['items'])) { + $items = (array)json_decode($_POST['items'], true); + if (is_array($items)) { + if (dkim_delete_key(array('domains' => $items)) === false) { if (isset($_SESSION['return'])) { echo json_encode($_SESSION['return']); } @@ -451,23 +459,194 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u 'msg' => 'Deletion of items/s failed' )); } - exit(); - } - if (isset($_SESSION['return'])) { - echo json_encode($_SESSION['return']); } else { - echo json_encode(array( - 'type' => 'success', - 'msg' => 'Item/s deleted: ' . $domains - )); + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } } } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find domains array in post data' + )); + } } else { echo json_encode(array( 'type' => 'error', - 'msg' => 'Cannot find domains array in post data' + 'msg' => 'Cannot find items in post data' + )); + } + break; + case "domain": + if (isset($_POST['items'])) { + $items = (array)json_decode($_POST['items'], true); + if (is_array($items)) { + if (mailbox_delete_domain(array('domain' => $items)) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Task failed' + )); + } + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find domain array in post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find items in post data' + )); + } + break; + case "alias-domain": + if (isset($_POST['items'])) { + $items = (array)json_decode($_POST['items'], true); + if (is_array($items)) { + if (mailbox_delete_alias_domain(array('alias_domain' => $items)) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Task failed' + )); + } + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find alias_domain array in post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find items in post data' + )); + } + break; + case "mailbox": + if (isset($_POST['items'])) { + $items = (array)json_decode($_POST['items'], true); + if (is_array($items)) { + if (mailbox_delete_mailbox(array('username' => $items)) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Task failed' + )); + } + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find username array in post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find items in post data' + )); + } + break; + case "resource": + if (isset($_POST['items'])) { + $items = (array)json_decode($_POST['items'], true); + if (is_array($items)) { + if (mailbox_delete_resource(array('name' => $items)) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Task failed' + )); + } + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find name array in post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Cannot find items in post data' )); } break; @@ -476,26 +655,222 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u case "edit": switch ($category) { case "alias": - if (isset($_POST['address']) && isset($_POST['active'])) { - $address = (array)json_decode($_POST['address'], true); - if (is_array($address)) { - if (mailbox_edit_alias(array('address' => $address, 'active' => ($_POST['active'] == "1") ? $active = 1 : null)) === false) { - echo json_encode(array( - 'type' => 'error', - 'msg' => 'Edit item failed' - )); + if (isset($_POST['items']) && isset($_POST['attr'])) { + $items = (array)json_decode($_POST['items'], true); + $attr = (array)json_decode($_POST['attr'], true); + $postarray = array_merge(array('address' => $items), $attr); + if (is_array($postarray['address'])) { + if (mailbox_edit_alias($postarray) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Edit failed' + )); + } exit(); } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { echo json_encode(array( - 'type' => 'success', - 'msg' => 'Task completed' + 'type' => 'error', + 'msg' => 'Incomplete post data' )); } } else { echo json_encode(array( 'type' => 'error', - 'msg' => 'Cannot find address array in post data' + 'msg' => 'Incomplete post data' + )); + } + break; + case "mailbox": + if (isset($_POST['items']) && isset($_POST['attr'])) { + $items = (array)json_decode($_POST['items'], true); + $attr = (array)json_decode($_POST['attr'], true); + $postarray = array_merge(array('username' => $items), $attr); + if (is_array($postarray['username'])) { + if (mailbox_edit_mailbox($postarray) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Edit failed' + )); + } + exit(); + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' + )); + } + break; + case "resource": + if (isset($_POST['items']) && isset($_POST['attr'])) { + $items = (array)json_decode($_POST['items'], true); + $attr = (array)json_decode($_POST['attr'], true); + $postarray = array_merge(array('name' => $items), $attr); + if (is_array($postarray['name'])) { + if (mailbox_edit_resource($postarray) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Edit failed' + )); + } + exit(); + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' + )); + } + break; + case "domain": + if (isset($_POST['items']) && isset($_POST['attr'])) { + $items = (array)json_decode($_POST['items'], true); + $attr = (array)json_decode($_POST['attr'], true); + $postarray = array_merge(array('domain' => $items), $attr); + if (is_array($postarray['domain'])) { + if (mailbox_edit_domain($postarray) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Edit failed' + )); + } + exit(); + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' + )); + } + break; + case "alias-domain": + if (isset($_POST['items']) && isset($_POST['attr'])) { + $items = (array)json_decode($_POST['items'], true); + $attr = (array)json_decode($_POST['attr'], true); + $postarray = array_merge(array('alias_domain' => $items), $attr); + if (is_array($postarray['alias_domain'])) { + if (mailbox_edit_alias_domain($postarray) === false) { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Edit failed' + )); + } + exit(); + } + else { + if (isset($_SESSION['return'])) { + echo json_encode($_SESSION['return']); + } + else { + echo json_encode(array( + 'type' => 'success', + 'msg' => 'Task completed' + )); + } + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' + )); + } + } + else { + echo json_encode(array( + 'type' => 'error', + 'msg' => 'Incomplete post data' )); } break; diff --git a/data/web/lang/lang.de.php b/data/web/lang/lang.de.php index bc254ccb..d1a8300d 100644 --- a/data/web/lang/lang.de.php +++ b/data/web/lang/lang.de.php @@ -70,12 +70,12 @@ $lang['danger']['login_failed'] = 'Anmeldung fehlgeschlagen'; $lang['danger']['mailbox_invalid'] = 'Mailboxname ist ungültig'; $lang['danger']['resource_invalid'] = 'Ressourcenname ist ungültig'; $lang['danger']['description_invalid'] = 'Ressourcenbeschreibung ist ungültig'; -$lang['danger']['mailbox_invalid_suggest'] = 'Mailboxname ist ungültig, meinten Sie vielleicht "%s"?'; +$lang['danger']['mailbox_invalid_suggest'] = 'Mailboxname ist ungültig, meinten Sie vielleicht %s?'; $lang['danger']['is_alias'] = '%s lautet bereits eine Alias-Adresse'; $lang['danger']['is_alias_or_mailbox'] = "Eine Mailbox oder ein Alias mit der Adresse %s ist bereits vorhanden"; $lang['danger']['is_spam_alias'] = '%s lautet bereits eine Spam-Alias-Adresse'; $lang['danger']['quota_not_0_not_numeric'] = 'Speicherplatz muss numerisch und >= 0 sein'; -$lang['danger']['domain_not_found'] = 'Domain "%s" nicht gefunden.'; +$lang['danger']['domain_not_found'] = 'Domain %s nicht gefunden'; $lang['danger']['max_mailbox_exceeded'] = 'Anzahl an Mailboxen überschritten (%d von %d)'; $lang['danger']['max_alias_exceeded'] = 'Anzahl an Alias-Adressen überschritten'; $lang['danger']['mailbox_quota_exceeded'] = 'Speicherplatz überschreitet das Limit (max. %d MiB)'; diff --git a/data/web/lang/lang.en.php b/data/web/lang/lang.en.php index af500355..f562d498 100644 --- a/data/web/lang/lang.en.php +++ b/data/web/lang/lang.en.php @@ -77,7 +77,7 @@ $lang['danger']['is_alias'] = "%s is already known as an alias address"; $lang['danger']['is_alias_or_mailbox'] = "%s is already known as an alias or a mailbox"; $lang['danger']['is_spam_alias'] = "%s is already known as a spam alias address"; $lang['danger']['quota_not_0_not_numeric'] = "Quota must be numeric and >= 0"; -$lang['danger']['domain_not_found'] = "Domain not found."; +$lang['danger']['domain_not_found'] = 'Domain "%s" not found'; $lang['danger']['max_mailbox_exceeded'] = "Max. mailboxes exceeded (%d of %d)"; $lang['danger']['max_alias_exceeded'] = 'Max. aliases exceeded'; $lang['danger']['mailbox_quota_exceeded'] = "Quota exceeds the domain limit (max. %d MiB)"; diff --git a/data/web/mailbox.php b/data/web/mailbox.php index 864ea676..e35a3601 100644 --- a/data/web/mailbox.php +++ b/data/web/mailbox.php @@ -31,16 +31,28 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI']; - +
    -

    +
    +
    +
    + + + +
    +
    @@ -56,6 +68,18 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
    +
    +
    + + + +
    +
    @@ -71,6 +95,18 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
    +
    +
    + + + +
    +
    @@ -86,6 +122,18 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
    +
    +
    + + + +
    +
    @@ -99,18 +147,19 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
    -
    -

    - ↪ -

    -
    -
    diff --git a/data/web/user.php b/data/web/user.php index ec25dc94..d5c75abc 100644 --- a/data/web/user.php +++ b/data/web/user.php @@ -382,18 +382,20 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
    + +

    - data-on-text="" data-off-text=""> + data-on-text="" data-off-text="">

    - data-on-text="" data-off-text=""> + data-on-text="" data-off-text="">