Various CSS fixes, remove sorttable, better API format

master
andryyy 2017-03-28 11:51:17 +02:00
parent 0b54d32401
commit 297674d256
13 changed files with 293 additions and 541 deletions

View File

@ -1,19 +1,19 @@
.panel-heading div { table.footable>tbody>tr.footable-empty>td {
margin-top: -18px; font-size:15px !important;
font-size: 15px; font-style:italic;
} }
.panel-heading div span { .pagination a {
margin-left:5px; text-decoration: none !important;
} }
.panel-body { .panel panel-default {
display: none; overflow: visible !important;
} }
.clickable { .table-responsive {
cursor: pointer; overflow: visible !important;
} }
.progress { .footer-add-item {
margin-bottom: 0px; text-align:center;
} font-style: italic;
.table>thead>tr>th { display:block;
vertical-align: top !important; padding: 10px;
} }

View File

@ -1,79 +0,0 @@
ul[id*="sortable"] { word-wrap: break-word; list-style-type: none; float: left; padding: 0 15px 0 0; width: 48%; cursor:move}
ul[id$="sortable-active"] li {cursor:move; }
ul[id$="sortable-inactive"] li {cursor:move }
.list-heading { cursor:default !important}
.ui-state-disabled { cursor:no-drop; color:#ccc; }
.ui-state-highlight {background: #F5F5F5 !important; height: 41px !important; cursor:move }
table[data-sortable] {
border-collapse: collapse;
border-spacing: 0;
}
table[data-sortable] th {
vertical-align: bottom;
font-weight: bold;
}
table[data-sortable] th, table[data-sortable] td {
text-align: left;
padding: 10px;
}
table[data-sortable] th:not([data-sortable="false"]) {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-touch-callout: none;
cursor: pointer;
}
table[data-sortable] th:after {
content: "";
visibility: hidden;
display: inline-block;
vertical-align: inherit;
height: 0;
width: 0;
border-width: 5px;
border-style: solid;
border-color: transparent;
margin-right: 1px;
margin-left: 10px;
float: right;
}
table[data-sortable] th[data-sortable="false"]:after {
display: none;
}
table[data-sortable] th[data-sorted="true"]:after {
visibility: visible;
}
table[data-sortable] th[data-sorted-direction="descending"]:after {
border-top-color: inherit;
margin-top: 8px;
}
table[data-sortable] th[data-sorted-direction="ascending"]:after {
border-bottom-color: inherit;
margin-top: 3px;
}
table[data-sortable].sortable-theme-bootstrap thead th {
border-bottom: 2px solid #e0e0e0;
}
table[data-sortable].sortable-theme-bootstrap th[data-sorted="true"] {
color: #3a87ad;
background: #d9edf7;
border-bottom-color: #bce8f1;
}
table[data-sortable].sortable-theme-bootstrap th[data-sorted="true"][data-sorted-direction="descending"]:after {
border-top-color: #3a87ad;
}
table[data-sortable].sortable-theme-bootstrap th[data-sorted="true"][data-sorted-direction="ascending"]:after {
border-bottom-color: #3a87ad;
}
table[data-sortable].sortable-theme-bootstrap.sortable-theme-bootstrap-striped tbody > tr:nth-child(odd) > td {
background-color: #f9f9f9;
}
#data td, #no-data td {
vertical-align: middle;
}
.sort-table:hover {
border-bottom-color: #00B7DC !important;
}

View File

@ -50,11 +50,7 @@ $(document).ready(function() {
type: "GET", type: "GET",
cache: false, cache: false,
dataType: 'script', dataType: 'script',
url: "json_api.php", url: "/api/v1/u2f-authentication/<?=(isset($_SESSION['pending_mailcow_cc_username'])) ? $_SESSION['pending_mailcow_cc_username'] : null;?>",
data: {
'action':'get_u2f_auth_challenge',
'object':'<?=(isset($_SESSION['pending_mailcow_cc_username'])) ? $_SESSION['pending_mailcow_cc_username'] : null;?>',
},
success: function(data){ success: function(data){
data; data;
} }
@ -87,11 +83,7 @@ $(document).ready(function() {
type: "GET", type: "GET",
cache: false, cache: false,
dataType: 'script', dataType: 'script',
url: "json_api.php", url: "/api/v1/u2f-registration/<?=(isset($_SESSION['mailcow_cc_username'])) ? $_SESSION['mailcow_cc_username'] : null;?>",
data: {
'action':'get_u2f_reg_challenge',
'object':'<?=(isset($_SESSION['mailcow_cc_username'])) ? $_SESSION['mailcow_cc_username'] : null;?>',
},
success: function(data){ success: function(data){
data; data;
} }

View File

@ -16,10 +16,8 @@
<link rel="stylesheet" href="/css/bootstrap-slider.min.css"> <link rel="stylesheet" href="/css/bootstrap-slider.min.css">
<link rel="stylesheet" href="/css/bootstrap-switch.min.css"> <link rel="stylesheet" href="/css/bootstrap-switch.min.css">
<link rel="stylesheet" href="/css/footable.bootstrap.min.css"> <link rel="stylesheet" href="/css/footable.bootstrap.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700&subset=latin,latin-ext">
<link rel="stylesheet" href="/inc/languages.min.css"> <link rel="stylesheet" href="/inc/languages.min.css">
<link rel="stylesheet" href="/css/mailcow.css"> <link rel="stylesheet" href="/css/mailcow.css">
<link rel="stylesheet" href="/css/tables.css">
<?=(preg_match("/mailbox.php/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/mailbox.css">' : null;?> <?=(preg_match("/mailbox.php/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/mailbox.css">' : null;?>
<link rel="shortcut icon" href="/favicon.png" type="image/png"> <link rel="shortcut icon" href="/favicon.png" type="image/png">
<link rel="icon" href="/favicon.png" type="image/png"> <link rel="icon" href="/favicon.png" type="image/png">

View File

@ -2,7 +2,7 @@ $(document).ready(function() {
// add.php // add.php
// Get max. possible quota for a domain when domain field changes // Get max. possible quota for a domain when domain field changes
$('#addSelectDomain').on('change', function() { $('#addSelectDomain').on('change', function() {
$.get("json_api.php", { action:"get_domain_details", object:this.value }, function(data){ $.get("/api/v1/domain/" + this.value, function(data){
var result = jQuery.parseJSON( data ); var result = jQuery.parseJSON( data );
max_new_mailbox_quota = ( result.max_new_mailbox_quota / 1048576); max_new_mailbox_quota = ( result.max_new_mailbox_quota / 1048576);
if (max_new_mailbox_quota != '0') { if (max_new_mailbox_quota != '0') {

View File

@ -1,31 +1,42 @@
$(document).ready(function() { $(document).ready(function() {
// Postfix restrictions, drag and drop functions $.ajax({
$( "[id*=srr-sortable]" ).sortable({ dataType: 'json',
items: "li:not(.list-heading)", url: '/api/v1/domain-admin/all',
cancel: ".ui-state-disabled", jsonp: false,
connectWith: "[id*=srr-sortable]", error: function () {
dropOnEmpty: true, alert('Cannot draw domain administrator table');
placeholder: "ui-state-highlight" },
success: function (data) {
$.each(data, function (i, item) {
item.action = '<div class="btn-group">' +
'<a href="/edit.php?domainadmin=' + encodeURI(item.username) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
'<a href="/delete.php?domainadmin=' + encodeURI(item.username) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
'</div>';
}); });
$( "[id*=ssr-sortable]" ).sortable({ $('#domainadminstable').footable({
items: "li:not(.list-heading)", "columns": [
cancel: ".ui-state-disabled", {"sorted": true,"name":"username","title":lang.username,"style":{"width":"250px"}},
connectWith: "[id*=ssr-sortable]", {"name":"selected_domains","title":lang.admin_domains,"breakpoints":"xs sm"},
dropOnEmpty: true, {"name":"tfa_active","title":"TFA", "filterable": false,"style":{"maxWidth":"80px","width":"80px"}},
placeholder: "ui-state-highlight" {"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
}
}); });
$('#srr_form').submit(function(){ }
var srr_joined_vals = $("[id^=srr-sortable-active] li").map(function() {
return $(this).data("value");
}).get().join(', ');
var input = $("<input>").attr("type", "hidden").attr("name", "srr_value").val(srr_joined_vals);
$('#srr_form').append($(input));
});
$('#ssr_form').submit(function(){
var ssr_joined_vals = $("[id^=ssr-sortable-active] li").map(function() {
return $(this).data("value");
}).get().join(', ');
var input = $("<input>").attr("type", "hidden").attr("name", "ssr_value").val(ssr_joined_vals);
$('#ssr_form').append($(input));
}); });
}); });

View File

@ -15,7 +15,7 @@ $(document).ready(function() {
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
url: '/json_api.php?action=domain_table_data', url: '/api/v1/domain/all',
jsonp: false, jsonp: false,
error: function () { error: function () {
alert('Cannot draw domain table'); alert('Cannot draw domain table');
@ -70,7 +70,7 @@ $(document).ready(function() {
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
url: '/json_api.php?action=mailbox_table_data', url: '/api/v1/mailbox/all',
jsonp: false, jsonp: false,
error: function () { error: function () {
alert('Cannot draw mailbox table'); alert('Cannot draw mailbox table');
@ -102,12 +102,12 @@ $(document).ready(function() {
{"sorted": true,"name":"username","title":lang.username,"style":{"width":"250px"}}, {"sorted": true,"name":"username","title":lang.username,"style":{"width":"250px"}},
{"name":"name","title":lang.fname,"breakpoints":"xs sm"}, {"name":"name","title":lang.fname,"breakpoints":"xs sm"},
{"name":"domain","title":lang.domain,"breakpoints":"xs sm"}, {"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
{"name":"quota","title":lang.domain_quota}, {"name":"quota","style":{"whiteSpace":"nowrap"},"title":lang.domain_quota},
{"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"xs sm"}, {"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":"in_use","filterable": false,"style":{"whiteSpace":"nowrap"},"type":"html","title":lang.in_use},
{"name":"messages","filterable": false,"style":{"width":"90px"},"title":lang.msg_num,"breakpoints":"xs sm"}, {"name":"messages","filterable": false,"style":{"whiteSpace":"nowrap"},"title":lang.msg_num,"breakpoints":"xs sm md"},
{"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, {"name":"active","filterable": false,"style":{"whiteSpace":"nowrap"},"title":lang.active},
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","width":"290px"},"type":"html","title":lang.action,"breakpoints":"xs sm"} {"name":"action","filterable": false,"sortable": false,"style":{"whiteSpace":"nowrap","text-align":"right","width":"290px"},"type":"html","title":lang.action,"breakpoints":"xs sm md"}
], ],
"empty": lang.empty, "empty": lang.empty,
"rows": data, "rows": data,
@ -130,7 +130,7 @@ $(document).ready(function() {
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
url: '/json_api.php?action=resource_table_data', url: '/api/v1/resource/all',
jsonp: false, jsonp: false,
error: function () { error: function () {
alert('Cannot draw resource table'); alert('Cannot draw resource table');
@ -172,7 +172,7 @@ $(document).ready(function() {
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
url: '/json_api.php?action=domain_alias_table_data', url: '/api/v1/alias-domain/all',
jsonp: false, jsonp: false,
error: function () { error: function () {
alert('Cannot draw alias domain table'); alert('Cannot draw alias domain table');
@ -212,7 +212,7 @@ $(document).ready(function() {
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
url: '/json_api.php?action=alias_table_data', url: '/api/v1/alias/all',
jsonp: false, jsonp: false,
error: function () { error: function () {
alert('Cannot draw alias table'); alert('Cannot draw alias table');

View File

@ -1,236 +0,0 @@
(function() {
var SELECTOR, addEventListener, clickEvents, numberRegExp, sortable, touchDevice, trimRegExp;
SELECTOR = 'table[data-sortable]';
numberRegExp = /^-?[£$¤]?[\d,.]+%?$/;
trimRegExp = /^\s+|\s+$/g;
clickEvents = ['click'];
touchDevice = 'ontouchstart' in document.documentElement;
if (touchDevice) {
clickEvents.push('touchstart');
}
addEventListener = function(el, event, handler) {
if (el.addEventListener != null) {
return el.addEventListener(event, handler, false);
} else {
return el.attachEvent("on" + event, handler);
}
};
sortable = {
init: function(options) {
var table, tables, _i, _len, _results;
if (options == null) {
options = {};
}
if (options.selector == null) {
options.selector = SELECTOR;
}
tables = document.querySelectorAll(options.selector);
_results = [];
for (_i = 0, _len = tables.length; _i < _len; _i++) {
table = tables[_i];
_results.push(sortable.initTable(table));
}
return _results;
},
initTable: function(table) {
var i, th, ths, _i, _len, _ref;
if (((_ref = table.tHead) != null ? _ref.rows.length : void 0) !== 1) {
return;
}
if (table.getAttribute('data-sortable-initialized') === 'true') {
return;
}
table.setAttribute('data-sortable-initialized', 'true');
ths = table.querySelectorAll('th');
for (i = _i = 0, _len = ths.length; _i < _len; i = ++_i) {
th = ths[i];
if (th.getAttribute('data-sortable') !== 'false') {
sortable.setupClickableTH(table, th, i);
}
}
return table;
},
setupClickableTH: function(table, th, i) {
var eventName, onClick, type, _i, _len, _results;
type = sortable.getColumnType(table, i);
onClick = function(e) {
var compare, item, newSortedDirection, position, row, rowArray, sorted, sortedDirection, tBody, ths, value, _compare, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1;
if (e.handled !== true) {
e.handled = true;
} else {
return false;
}
sorted = this.getAttribute('data-sorted') === 'true';
sortedDirection = this.getAttribute('data-sorted-direction');
if (sorted) {
newSortedDirection = sortedDirection === 'ascending' ? 'descending' : 'ascending';
} else {
newSortedDirection = type.defaultSortDirection;
}
ths = this.parentNode.querySelectorAll('th');
for (_i = 0, _len = ths.length; _i < _len; _i++) {
th = ths[_i];
th.setAttribute('data-sorted', 'false');
th.removeAttribute('data-sorted-direction');
}
this.setAttribute('data-sorted', 'true');
this.setAttribute('data-sorted-direction', newSortedDirection);
tBody = table.tBodies[0];
rowArray = [];
if (!sorted) {
if (type.compare != null) {
_compare = type.compare;
} else {
_compare = function(a, b) {
return b - a;
};
}
compare = function(a, b) {
if (a[0] === b[0]) {
return a[2] - b[2];
}
if (type.reverse) {
return _compare(b[0], a[0]);
} else {
return _compare(a[0], b[0]);
}
};
_ref = tBody.rows;
for (position = _j = 0, _len1 = _ref.length; _j < _len1; position = ++_j) {
row = _ref[position];
value = sortable.getNodeValue(row.cells[i]);
if (type.comparator != null) {
value = type.comparator(value);
}
rowArray.push([value, row, position]);
}
rowArray.sort(compare);
for (_k = 0, _len2 = rowArray.length; _k < _len2; _k++) {
row = rowArray[_k];
tBody.appendChild(row[1]);
}
} else {
_ref1 = tBody.rows;
for (_l = 0, _len3 = _ref1.length; _l < _len3; _l++) {
item = _ref1[_l];
rowArray.push(item);
}
rowArray.reverse();
for (_m = 0, _len4 = rowArray.length; _m < _len4; _m++) {
row = rowArray[_m];
tBody.appendChild(row);
}
}
if (typeof window['CustomEvent'] === 'function') {
return typeof table.dispatchEvent === "function" ? table.dispatchEvent(new CustomEvent('Sortable.sorted', {
bubbles: true
})) : void 0;
}
};
_results = [];
for (_i = 0, _len = clickEvents.length; _i < _len; _i++) {
eventName = clickEvents[_i];
_results.push(addEventListener(th, eventName, onClick));
}
return _results;
},
getColumnType: function(table, i) {
var row, specified, text, type, _i, _j, _len, _len1, _ref, _ref1, _ref2;
specified = (_ref = table.querySelectorAll('th')[i]) != null ? _ref.getAttribute('data-sortable-type') : void 0;
if (specified != null) {
return sortable.typesObject[specified];
}
_ref1 = table.tBodies[0].rows;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
row = _ref1[_i];
text = sortable.getNodeValue(row.cells[i]);
_ref2 = sortable.types;
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
type = _ref2[_j];
if (type.match(text)) {
return type;
}
}
}
return sortable.typesObject.alpha;
},
getNodeValue: function(node) {
var dataValue;
if (!node) {
return '';
}
dataValue = node.getAttribute('data-value');
if (dataValue !== null) {
return dataValue;
}
if (typeof node.innerText !== 'undefined') {
return node.innerText.replace(trimRegExp, '');
}
return node.textContent.replace(trimRegExp, '');
},
setupTypes: function(types) {
var type, _i, _len, _results;
sortable.types = types;
sortable.typesObject = {};
_results = [];
for (_i = 0, _len = types.length; _i < _len; _i++) {
type = types[_i];
_results.push(sortable.typesObject[type.name] = type);
}
return _results;
}
};
sortable.setupTypes([
{
name: 'numeric',
defaultSortDirection: 'descending',
match: function(a) {
return a.match(numberRegExp);
},
comparator: function(a) {
return parseFloat(a.replace(/[^0-9.-]/g, ''), 10) || 0;
}
}, {
name: 'date',
defaultSortDirection: 'ascending',
reverse: true,
match: function(a) {
return !isNaN(Date.parse(a));
},
comparator: function(a) {
return Date.parse(a) || 0;
}
}, {
name: 'alpha',
defaultSortDirection: 'ascending',
match: function() {
return true;
},
compare: function(a, b) {
return a.localeCompare(b);
}
}
]);
setTimeout(sortable.init, 0);
if (typeof define === 'function' && define.amd) {
define(function() {
return sortable;
});
} else if (typeof exports !== 'undefined') {
module.exports = sortable;
} else {
window.Sortable = sortable;
}
}).call(this);

View File

@ -2,10 +2,13 @@
require_once 'inc/prerequisites.inc.php'; require_once 'inc/prerequisites.inc.php';
error_reporting(E_ALL); error_reporting(E_ALL);
if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_username'])) { if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_username'])) {
if (isset($_GET['action'])) { if (isset($_GET['action']) && isset($_GET['object'])) {
$action = $_GET['action']; $action = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
$object = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
switch ($action) { switch ($action) {
case "domain_table_data": case "domain":
switch ($object) {
case "all":
$domains = mailbox_get_domains(); $domains = mailbox_get_domains();
if (!empty($domains)) { if (!empty($domains)) {
foreach ($domains as $domain) { foreach ($domains as $domain) {
@ -22,7 +25,21 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "mailbox_table_data":
default:
$data = mailbox_get_domain_details($object);
if (!isset($data) || empty($data)) {
echo '{}';
}
else {
echo json_encode(mailbox_get_domain_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
break;
}
break;
case "mailbox":
switch ($object) {
case "all":
$domains = mailbox_get_domains(); $domains = mailbox_get_domains();
if (!empty($domains)) { if (!empty($domains)) {
foreach ($domains as $domain) { foreach ($domains as $domain) {
@ -44,7 +61,22 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "resource_table_data":
default:
$data = mailbox_get_mailbox_details($object);
if (!isset($data) || empty($data)) {
echo '{}';
}
else {
echo json_encode(mailbox_get_mailbox_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
break;
}
break;
case "resource":
switch ($object) {
case "all":
$domains = mailbox_get_domains(); $domains = mailbox_get_domains();
if (!empty($domains)) { if (!empty($domains)) {
foreach ($domains as $domain) { foreach ($domains as $domain) {
@ -66,7 +98,22 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "domain_alias_table_data":
default:
$data = mailbox_get_resource_details($object);
if (!isset($data) || empty($data)) {
echo '{}';
}
else {
echo json_encode(mailbox_get_resource_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
break;
}
break;
case "alias-domain":
switch ($object) {
case "all":
$domains = mailbox_get_domains(); $domains = mailbox_get_domains();
if (!empty($domains)) { if (!empty($domains)) {
foreach ($domains as $domain) { foreach ($domains as $domain) {
@ -88,7 +135,21 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "alias_table_data":
default:
$data = mailbox_get_alias_domains($object);
if (!isset($data) || empty($data)) {
echo '{}';
}
else {
echo json_encode(mailbox_get_alias_domains($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
break;
}
break;
case "alias":
switch ($object) {
case "all":
$domains = array_merge(mailbox_get_domains(), mailbox_get_alias_domains()); $domains = array_merge(mailbox_get_domains(), mailbox_get_alias_domains());
if (!empty($domains)) { if (!empty($domains)) {
foreach ($domains as $domain) { foreach ($domains as $domain) {
@ -110,55 +171,68 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
echo '{}'; echo '{}';
} }
break; break;
case "get_mailbox_details":
if (!isset($_GET['object'])) { return false; } default:
$object = $_GET['object']; $data = mailbox_get_alias_details($object);
$data = mailbox_get_mailbox_details($object);
if (!isset($data) || empty($data)) { if (!isset($data) || empty($data)) {
echo '{}'; echo '{}';
} }
else { else {
echo json_encode(mailbox_get_mailbox_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); echo json_encode(mailbox_get_alias_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
} }
break; break;
case "get_domain_details": }
if (!isset($_GET['object'])) { return false; } break;
$object = $_GET['object']; case "domain-admin":
$data = mailbox_get_domain_details($object); switch ($object) {
case "all":
$domain_admins = get_domain_admins();
if (!empty($domain_admins)) {
foreach ($domain_admins as $domain_admin) {
$data[] = get_domain_admin_details($domain_admin);
}
if (!isset($data) || empty($data)) { if (!isset($data) || empty($data)) {
echo '{}'; echo '{}';
} }
else { else {
echo json_encode(mailbox_get_domain_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
}
else {
echo '{}';
} }
break; break;
case "get_u2f_reg_challenge":
if (!isset($_GET['object'])) { return false; } default:
$object = $_GET['object']; $data = get_domain_admin_details($object);
if ( if (!isset($data) || empty($data)) {
($_SESSION["mailcow_cc_role"] == "admin" || $_SESSION["mailcow_cc_role"] == "domainadmin") echo '{}';
&& }
($_SESSION["mailcow_cc_username"] == $object) else {
) { echo json_encode(get_domain_admin_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
break;
}
break;
case "u2f-registration":
if (($_SESSION["mailcow_cc_role"] == "admin" || $_SESSION["mailcow_cc_role"] == "domainadmin") && $_SESSION["mailcow_cc_username"] == $object) {
$data = $u2f->getRegisterData(get_u2f_registrations($object)); $data = $u2f->getRegisterData(get_u2f_registrations($object));
list($req, $sigs) = $data; list($req, $sigs) = $data;
$_SESSION['regReq'] = json_encode($req); $_SESSION['regReq'] = json_encode($req);
echo 'var req = ' . json_encode($req) . '; var sigs = ' . json_encode($sigs) . ';'; echo 'var req = ' . json_encode($req) . '; var sigs = ' . json_encode($sigs) . ';';
} }
else { else {
echo '{}'; return;
} }
break; break;
case "get_u2f_auth_challenge": case "u2f-authentication":
if (!isset($_GET['object'])) { return false; }
$object = $_GET['object'];
if (isset($_SESSION['pending_mailcow_cc_username']) && $_SESSION['pending_mailcow_cc_username'] == $object) { if (isset($_SESSION['pending_mailcow_cc_username']) && $_SESSION['pending_mailcow_cc_username'] == $object) {
$reqs = json_encode($u2f->getAuthenticateData(get_u2f_registrations($object))); $reqs = json_encode($u2f->getAuthenticateData(get_u2f_registrations($object)));
$_SESSION['authReq'] = $reqs; $_SESSION['authReq'] = $reqs;
echo 'var req = ' . $reqs . ';'; echo 'var req = ' . $reqs . ';';
} }
else { else {
echo '{}'; return;
} }
break; break;
default: default:

View File

@ -36,6 +36,7 @@ $lang['danger']['object_exists'] = 'Objekt %s existiert bereits';
$lang['danger']['domain_exists'] = 'Domain %s existiert bereits'; $lang['danger']['domain_exists'] = 'Domain %s existiert bereits';
$lang['danger']['alias_goto_identical'] = 'Alias- und Ziel-Adresse dürfen nicht identisch sein'; $lang['danger']['alias_goto_identical'] = 'Alias- und Ziel-Adresse dürfen nicht identisch sein';
$lang['danger']['aliasd_targetd_identical'] = 'Alias-Domain darf nicht gleich Ziel-Domain sein'; $lang['danger']['aliasd_targetd_identical'] = 'Alias-Domain darf nicht gleich Ziel-Domain sein';
$lang['danger']['maxquota_empty'] = 'Max. Speicherplatz pro Mailbox darf nicht 0 sein.';
$lang['success']['alias_added'] = 'Alias-Adresse(n) wurden angelegt'; $lang['success']['alias_added'] = 'Alias-Adresse(n) wurden angelegt';
$lang['success']['alias_modified'] = 'Änderungen an Alias %s wurden gespeichert'; $lang['success']['alias_modified'] = 'Änderungen an Alias %s wurden gespeichert';
$lang['success']['aliasd_modified'] = 'Änderungen an Alias-Domain %s wurden gespeichert'; $lang['success']['aliasd_modified'] = 'Änderungen an Alias-Domain %s wurden gespeichert';
@ -70,6 +71,7 @@ $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']['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_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)'; $lang['danger']['mailbox_quota_exceeded'] = 'Speicherplatz überschreitet das Limit (max. %d MiB)';
$lang['danger']['mailbox_quota_left_exceeded'] = 'Nicht genügend Speicherplatz vorhanden (Speicherplatz anwendbar: %d MiB)'; $lang['danger']['mailbox_quota_left_exceeded'] = 'Nicht genügend Speicherplatz vorhanden (Speicherplatz anwendbar: %d MiB)';
$lang['success']['mailbox_added'] = 'Mailbox %s wurde angelegt'; $lang['success']['mailbox_added'] = 'Mailbox %s wurde angelegt';
@ -246,6 +248,7 @@ $lang['mailbox']['add_domain_alias'] = 'Domain-Alias hinzufügen';
$lang['mailbox']['add_mailbox'] = 'Mailbox hinzufügen'; $lang['mailbox']['add_mailbox'] = 'Mailbox hinzufügen';
$lang['mailbox']['add_resource'] = 'Ressource hinzufügen'; $lang['mailbox']['add_resource'] = 'Ressource hinzufügen';
$lang['mailbox']['add_alias'] = 'Alias hinzufügen'; $lang['mailbox']['add_alias'] = 'Alias hinzufügen';
$lang['mailbox']['empty'] = 'Keine Einträge vorhanden';
$lang['info']['no_action'] = 'Keine Aktion anwendbar'; $lang['info']['no_action'] = 'Keine Aktion anwendbar';
@ -448,4 +451,6 @@ $lang['admin']['site_not_found'] = 'Kann mailcow Site-Konfiguration nicht finden
$lang['admin']['public_folder_empty'] = 'Public folder name must not be empty'; // NEEDS TRANSLATION $lang['admin']['public_folder_empty'] = 'Public folder name must not be empty'; // NEEDS TRANSLATION
$lang['admin']['set_rr_failed'] = 'Kann Postfix Restriktionen nicht setzen'; $lang['admin']['set_rr_failed'] = 'Kann Postfix Restriktionen nicht setzen';
$lang['admin']['no_record'] = 'Kein Eintrag'; $lang['admin']['no_record'] = 'Kein Eintrag';
$lang['admin']['filter_table'] = 'Tabelle Filtern';
$lang['admin']['empty'] = 'Keine Einträge vorhanden';
?> ?>

View File

@ -38,6 +38,7 @@ $lang['danger']['object_exists'] = "Object %s already exists";
$lang['danger']['domain_exists'] = "Domain %s already exists"; $lang['danger']['domain_exists'] = "Domain %s already exists";
$lang['danger']['alias_goto_identical'] = "Alias and goto address must not be identical"; $lang['danger']['alias_goto_identical'] = "Alias and goto address must not be identical";
$lang['danger']['aliasd_targetd_identical'] = "Alias domain must not be equal to target domain"; $lang['danger']['aliasd_targetd_identical'] = "Alias domain must not be equal to target domain";
$lang['danger']['maxquota_empty'] = 'Max. quota per mailbox must not be 0.';
$lang['success']['alias_added'] = "Alias address/es has/have been added"; $lang['success']['alias_added'] = "Alias address/es has/have been added";
$lang['success']['alias_modified'] = "Changes to alias have been saved"; $lang['success']['alias_modified'] = "Changes to alias have been saved";
$lang['success']['aliasd_modified'] = "Changes to alias domain have been saved"; $lang['success']['aliasd_modified'] = "Changes to alias domain have been saved";
@ -72,6 +73,7 @@ $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']['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 not found.";
$lang['danger']['max_mailbox_exceeded'] = "Max. mailboxes exceeded (%d of %d)"; $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)"; $lang['danger']['mailbox_quota_exceeded'] = "Quota exceeds the domain limit (max. %d MiB)";
$lang['danger']['mailbox_quota_left_exceeded'] = "Not enough space left (space left: %d MiB)"; $lang['danger']['mailbox_quota_left_exceeded'] = "Not enough space left (space left: %d MiB)";
$lang['success']['mailbox_added'] = "Mailbox %s has been added"; $lang['success']['mailbox_added'] = "Mailbox %s has been added";
@ -249,6 +251,7 @@ $lang['mailbox']['add_mailbox'] = 'Add mailbox';
$lang['mailbox']['add_resource'] = 'Add resource'; $lang['mailbox']['add_resource'] = 'Add resource';
$lang['mailbox']['add_alias'] = 'Add alias'; $lang['mailbox']['add_alias'] = 'Add alias';
$lang['mailbox']['add_domain_record_first'] = 'Please add a domain first'; $lang['mailbox']['add_domain_record_first'] = 'Please add a domain first';
$lang['mailbox']['empty'] = 'No results';
$lang['info']['no_action'] = 'No action applicable'; $lang['info']['no_action'] = 'No action applicable';
@ -459,4 +462,6 @@ $lang['admin']['site_not_found'] = 'Cannot locate mailcow site configuration';
$lang['admin']['public_folder_empty'] = 'Public folder name must not be empty'; $lang['admin']['public_folder_empty'] = 'Public folder name must not be empty';
$lang['admin']['set_rr_failed'] = 'Cannot set Postfix restrictions'; $lang['admin']['set_rr_failed'] = 'Cannot set Postfix restrictions';
$lang['admin']['no_record'] = 'No record'; $lang['admin']['no_record'] = 'No record';
$lang['admin']['filter_table'] = 'Filter table';
$lang['admin']['empty'] = 'No results';
?> ?>

View File

@ -5,33 +5,11 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
require_once "inc/header.inc.php"; require_once "inc/header.inc.php";
$_SESSION['return_to'] = $_SERVER['REQUEST_URI']; $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
?> ?>
<style>
table.footable>tbody>tr.footable-empty>td {
font-size:15px !important;
font-style:italic;
}
.pagination a {
text-decoration: none !important;
}
.panel panel-default {
overflow: visible !important;
}
.table-responsive {
overflow: visible !important;
}
.footer-add-item {
text-align:center;
font-style: italic;
display:block;
padding: 10px;
}
</style>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"><?=$lang['mailbox']['domains'];?></h3>
<div class="pull-right"> <div class="pull-right">
<?php <?php
if ($_SESSION['mailcow_cc_role'] == "admin"): if ($_SESSION['mailcow_cc_role'] == "admin"):
@ -41,6 +19,7 @@ table.footable>tbody>tr.footable-empty>td {
endif; endif;
?> ?>
</div> </div>
<h3 class="panel-title"><?=$lang['mailbox']['domains'];?></h3>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table id="domain_table" class="table table-striped"></table> <table id="domain_table" class="table table-striped"></table>
@ -49,14 +28,15 @@ table.footable>tbody>tr.footable-empty>td {
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"><?=$lang['mailbox']['mailboxes'];?></h3>
<div class="pull-right"> <div class="pull-right">
<a href="/add.php?mailbox"><span class="glyphicon glyphicon-plus"></span></a> <a href="/add.php?mailbox"><span class="glyphicon glyphicon-plus"></span></a>
</div> </div>
<h3 class="panel-title"><?=$lang['mailbox']['mailboxes'];?></h3>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table id="mailbox_table" class="table table-striped"></table> <table id="mailbox_table" class="table table-striped"></table>
@ -65,14 +45,15 @@ table.footable>tbody>tr.footable-empty>td {
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"><?=$lang['mailbox']['resources'];?></h3>
<div class="pull-right"> <div class="pull-right">
<a href="/add.php?resource"><span class="glyphicon glyphicon-plus"></span></a> <a href="/add.php?resource"><span class="glyphicon glyphicon-plus"></span></a>
</div> </div>
<h3 class="panel-title"><?=$lang['mailbox']['resources'];?></h3>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table id="resources_table" class="table table-striped"></table> <table id="resources_table" class="table table-striped"></table>
@ -80,14 +61,15 @@ table.footable>tbody>tr.footable-empty>td {
<span class="footer-add-item"><a href="/add.php?resource"><?=$lang['mailbox']['add_resource'];?></a></span> </div> <span class="footer-add-item"><a href="/add.php?resource"><?=$lang['mailbox']['add_resource'];?></a></span> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"><?=$lang['mailbox']['domain_aliases'];?></h3>
<div class="pull-right"> <div class="pull-right">
<a href="/add.php?aliasdomain"><span class="glyphicon glyphicon-plus"></span></a> <a href="/add.php?aliasdomain"><span class="glyphicon glyphicon-plus"></span></a>
</div> </div>
<h3 class="panel-title"><?=$lang['mailbox']['domain_aliases'];?></h3>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table id="aliasdomain_table" class="table table-striped"></table> <table id="aliasdomain_table" class="table table-striped"></table>
@ -100,10 +82,10 @@ table.footable>tbody>tr.footable-empty>td {
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"><?=$lang['mailbox']['aliases'];?></h3>
<div class="pull-right"> <div class="pull-right">
<a href="/add.php?alias"><span class="glyphicon glyphicon-plus"></span></a> <a href="/add.php?alias"><span class="glyphicon glyphicon-plus"></span></a>
</div> </div>
<h3 class="panel-title"><?=$lang['mailbox']['aliases'];?></h3>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table id="alias_table" class="table table-striped"></table> <table id="alias_table" class="table table-striped"></table>

View File

@ -405,7 +405,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
</div> </div>
<div role="tabpanel" class="tab-pane" id="Syncjobs"> <div role="tabpanel" class="tab-pane" id="Syncjobs">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped sortable-theme-bootstrap" data-sortable id="timelimitedaliases"> <table class="table table-striped" id="timelimitedaliases">
<thead> <thead>
<tr> <tr>
<th class="sort-table" style="min-width: 96px;">Server:Port</th> <th class="sort-table" style="min-width: 96px;">Server:Port</th>
@ -416,7 +416,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
<th class="sort-table" style="min-width: 35px;"><?=$lang['user']['last_run'];?></th> <th class="sort-table" style="min-width: 35px;"><?=$lang['user']['last_run'];?></th>
<th class="sort-table" style="min-width: 35px;">Log</th> <th class="sort-table" style="min-width: 35px;">Log</th>
<th class="sort-table" style="max-width: 95px;"><?=$lang['user']['active'];?></th> <th class="sort-table" style="max-width: 95px;"><?=$lang['user']['active'];?></th>
<th style="text-align: right; min-width: 200px;" data-sortable="false"><?=$lang['user']['action'];?></th> <th style="text-align: right; min-width: 200px;"><?=$lang['user']['action'];?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>