mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-12-04 10:24:42 +02:00
Initial push or quick actions in alias table
This commit is contained in:
parent
a03b36e0c3
commit
5586bd2bb5
@ -16,4 +16,17 @@ table.footable>tbody>tr.footable-empty>td {
|
||||
font-style: italic;
|
||||
display:block;
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
.mass-each-action {
|
||||
font-style: italic;
|
||||
padding: 0 3px 0 3px;
|
||||
user-select: none;
|
||||
}
|
||||
.mass-actions {
|
||||
user-select: none;
|
||||
padding:10px;
|
||||
}
|
||||
.mass-select-all {
|
||||
cursor:pointer;
|
||||
color:grey;
|
||||
}
|
||||
|
@ -50,3 +50,8 @@ pre{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-s
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
/* Fix modal moving content left */
|
||||
body.modal-open {
|
||||
overflow: inherit;
|
||||
padding-right: inherit !important;
|
||||
}
|
||||
|
@ -3308,82 +3308,95 @@ function mailbox_edit_alias_domain($postarray) {
|
||||
);
|
||||
}
|
||||
function mailbox_edit_alias($postarray) {
|
||||
// Array elements
|
||||
// address string
|
||||
// goto string (separated by " ", "," ";" "\n") - email address or domain
|
||||
// active int
|
||||
// We can edit multiple addresses at once, but only set one "goto" and/or "active" attribute for all
|
||||
// address string or array containing strings | email | required
|
||||
// goto string | separated by " ", "," ";" "\n", email or domain | optional
|
||||
// active set (active) or unset (inactive)
|
||||
global $lang;
|
||||
global $pdo;
|
||||
$address = $postarray['address'];
|
||||
$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',
|
||||
'msg' => sprintf($lang['danger']['access_denied'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (empty($postarray['goto'])) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['goto_empty'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $postarray['goto']));
|
||||
foreach ($gotos as &$goto) {
|
||||
if (empty($goto)) {
|
||||
continue;
|
||||
}
|
||||
if (!filter_var($goto, FILTER_VALIDATE_EMAIL)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' =>sprintf($lang['danger']['goto_invalid'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ($goto == $address) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['alias_goto_identical'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$gotos = array_filter($gotos);
|
||||
$goto = implode(",", $gotos);
|
||||
if (!is_array($postarray['address'])) {
|
||||
$address_array = array();
|
||||
$address_array[] = $postarray['address'];
|
||||
}
|
||||
else {
|
||||
$address_array = $postarray['address'];
|
||||
}
|
||||
if (isset($postarray['goto']) || !empty($postarray['goto'])) {
|
||||
$gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $postarray['goto']));
|
||||
foreach ($gotos as &$goto) {
|
||||
if (empty($goto)) {
|
||||
continue;
|
||||
}
|
||||
if (!filter_var($goto, FILTER_VALIDATE_EMAIL)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' =>sprintf($lang['danger']['goto_invalid'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ($goto == $address) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['alias_goto_identical'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$gotos = array_filter($gotos);
|
||||
$goto = implode(",", $gotos);
|
||||
}
|
||||
isset($postarray['active']) ? $active = '1' : $active = '0';
|
||||
if ((!filter_var($address, FILTER_VALIDATE_EMAIL) === true) && !empty($local_part)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['alias_invalid'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("UPDATE `alias` SET
|
||||
`goto` = :goto,
|
||||
`active`= :active
|
||||
WHERE `address` = :address");
|
||||
$stmt->execute(array(
|
||||
':goto' => $goto,
|
||||
':active' => $active,
|
||||
':address' => $address
|
||||
));
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'success',
|
||||
'msg' => sprintf($lang['success']['alias_modified'], htmlspecialchars($address))
|
||||
);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
foreach ($address_array as $address) {
|
||||
$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',
|
||||
'msg' => sprintf($lang['danger']['access_denied'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ((!filter_var($address, FILTER_VALIDATE_EMAIL) === true) && !empty($local_part)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['alias_invalid'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (isset($goto) && !empty($goto)) {
|
||||
$stmt = $pdo->prepare("UPDATE `alias` SET
|
||||
`goto` = :goto,
|
||||
`active`= :active
|
||||
WHERE `address` = :address");
|
||||
$stmt->execute(array(
|
||||
':goto' => $goto,
|
||||
':active' => $active,
|
||||
':address' => $address
|
||||
));
|
||||
}
|
||||
else {
|
||||
$stmt = $pdo->prepare("UPDATE `alias` SET
|
||||
`active`= :active
|
||||
WHERE `address` = :address");
|
||||
$stmt->execute(array(
|
||||
':active' => $active,
|
||||
':address' => $address
|
||||
));
|
||||
}
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'success',
|
||||
'msg' => sprintf($lang['success']['alias_modified'], htmlspecialchars(implode(', ', $address_array)))
|
||||
);
|
||||
}
|
||||
function mailbox_edit_domain($postarray) {
|
||||
// Array elements
|
||||
@ -4527,48 +4540,57 @@ function mailbox_delete_domain($postarray) {
|
||||
return true;
|
||||
}
|
||||
function mailbox_delete_alias($postarray) {
|
||||
// $postarray['address'] can be a single element or an array
|
||||
global $lang;
|
||||
global $pdo;
|
||||
$address = $postarray['address'];
|
||||
$local_part = strstr($address, '@', true);
|
||||
$domain = mailbox_get_alias_details($address)['domain'];
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT `goto` FROM `alias` WHERE `address` = :address");
|
||||
$stmt->execute(array(':address' => $address));
|
||||
$gotos = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$goto_array = explode(',', $gotos['goto']);
|
||||
if (!is_array($postarray['address'])) {
|
||||
$address_array = array();
|
||||
$address_array[] = $postarray['address'];
|
||||
}
|
||||
else {
|
||||
$address_array = $postarray['address'];
|
||||
}
|
||||
foreach ($address_array as $address) {
|
||||
$local_part = strstr($address, '@', true);
|
||||
$domain = mailbox_get_alias_details($address)['domain'];
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT `goto` FROM `alias` WHERE `address` = :address");
|
||||
$stmt->execute(array(':address' => $address));
|
||||
$gotos = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$goto_array = explode(',', $gotos['goto']);
|
||||
|
||||
if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['access_denied'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$stmt = $pdo->prepare("DELETE FROM `alias` WHERE `address` = :address AND `address` NOT IN (SELECT `username` FROM `mailbox`)");
|
||||
$stmt->execute(array(
|
||||
':address' => $address
|
||||
));
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => sprintf($lang['danger']['access_denied'])
|
||||
);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$stmt = $pdo->prepare("DELETE FROM `alias` WHERE `address` = :address AND `address` NOT IN (SELECT `username` FROM `mailbox`)");
|
||||
$stmt->execute(array(
|
||||
':address' => $address
|
||||
));
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'danger',
|
||||
'msg' => 'MySQL: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$_SESSION['return'] = array(
|
||||
'type' => 'success',
|
||||
'msg' => sprintf($lang['success']['alias_removed'], htmlspecialchars($address))
|
||||
'msg' => sprintf($lang['success']['alias_removed'], htmlspecialchars(implode(', ', $address_array)))
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ $(document).ready(function() {
|
||||
} while(Math.abs(bytes) >= 1024 && u < units.length - 1);
|
||||
return bytes.toFixed(1)+' '+units[u];
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/domain/all',
|
||||
url: '/api/v1/get/domain/all',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
alert('Cannot draw domain table');
|
||||
@ -78,7 +78,7 @@ $(document).ready(function() {
|
||||
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/mailbox/all',
|
||||
url: '/api/v1/get/mailbox/all',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
alert('Cannot draw mailbox table');
|
||||
@ -146,7 +146,7 @@ $(document).ready(function() {
|
||||
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/resource/all',
|
||||
url: '/api/v1/get/resource/all',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
alert('Cannot draw resource table');
|
||||
@ -188,7 +188,7 @@ $(document).ready(function() {
|
||||
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/alias-domain/all',
|
||||
url: '/api/v1/get/alias-domain/all',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
alert('Cannot draw alias domain table');
|
||||
@ -228,7 +228,7 @@ $(document).ready(function() {
|
||||
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/api/v1/alias/all',
|
||||
url: '/api/v1/get/alias/all',
|
||||
jsonp: false,
|
||||
error: function () {
|
||||
alert('Cannot draw alias table');
|
||||
@ -239,6 +239,7 @@ $(document).ready(function() {
|
||||
'<a href="/edit.php?alias=' + encodeURI(item.address) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
||||
'<a href="/delete.php?alias=' + encodeURI(item.address) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||
'</div>';
|
||||
item.chkbox = '<input type="checkbox" class="alias_item" name="sel_aliases" value="' + item.address + '" />';
|
||||
if (item.is_catch_all == 1) {
|
||||
item.address = '<div class="label label-default">Catch-All</div> ' + item.address;
|
||||
}
|
||||
@ -246,8 +247,9 @@ $(document).ready(function() {
|
||||
item.domain = "↳ " + item.domain + " (" + item.in_primary_domain + ")";
|
||||
}
|
||||
});
|
||||
$('#alias_table').footable({
|
||||
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"},
|
||||
@ -269,6 +271,68 @@ $(document).ready(function() {
|
||||
"sorting": {
|
||||
"enabled": true
|
||||
}
|
||||
}, function aliases_table_hook() {
|
||||
var selected_aliases = {};
|
||||
$('input[name=sel_aliases]').change(function() {
|
||||
selected_aliases = {};
|
||||
$('input[name=sel_aliases]:checked').each(function(i) {
|
||||
selected_aliases[i] = ($(this).val());
|
||||
});
|
||||
});
|
||||
$("#select_all_aliases").click(function(e) {
|
||||
e.preventDefault();
|
||||
var alias_chkbxs = $("input[name=sel_aliases]");
|
||||
alias_chkbxs.prop("checked", !alias_chkbxs.prop("checked")).change();
|
||||
});
|
||||
$("#activate_selected_alias").click(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/post',
|
||||
jsonp: false,
|
||||
complete: function (data) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#deactivate_selected_alias").click(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/post',
|
||||
jsonp: false,
|
||||
complete: function (data) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$("#delete_selected_alias").click(function(e) {
|
||||
e.preventDefault();
|
||||
if (Object.keys(selected_aliases).length !== 0) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { "address": JSON.stringify(selected_aliases) },
|
||||
url: '/api/v1/delete/alias/post',
|
||||
jsonp: false,
|
||||
complete: function (data) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$("tr").on('click',function(event) {
|
||||
var checkbox = $(this).find(':checkbox');
|
||||
checkbox.trigger('click');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -2,242 +2,307 @@
|
||||
require_once 'inc/prerequisites.inc.php';
|
||||
error_reporting(E_ALL);
|
||||
if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_username'])) {
|
||||
if (isset($_GET['action']) && isset($_GET['object'])) {
|
||||
if (isset($_GET['action']) && isset($_GET['cat'])) {
|
||||
$category = filter_input(INPUT_GET, 'cat', FILTER_SANITIZE_STRING);
|
||||
$action = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
|
||||
$object = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
|
||||
|
||||
if (isset($_GET['object'])) {
|
||||
$object = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case "domain":
|
||||
switch ($object) {
|
||||
case "all":
|
||||
$domains = mailbox_get_domains();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$data[] = mailbox_get_domain_details($domain);
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
|
||||
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();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$mailboxes = mailbox_get_mailboxes($domain);
|
||||
if (!empty($mailboxes)) {
|
||||
foreach ($mailboxes as $mailbox) {
|
||||
$data[] = mailbox_get_mailbox_details($mailbox);
|
||||
case "get":
|
||||
switch ($category) {
|
||||
case "domain":
|
||||
switch ($object) {
|
||||
case "all":
|
||||
$domains = mailbox_get_domains();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$data[] = mailbox_get_domain_details($domain);
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$resources = mailbox_get_resources($domain);
|
||||
if (!empty($resources)) {
|
||||
foreach ($resources as $resource) {
|
||||
$data[] = mailbox_get_resource_details($resource);
|
||||
case "mailbox":
|
||||
switch ($object) {
|
||||
case "all":
|
||||
$domains = mailbox_get_domains();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$mailboxes = mailbox_get_mailboxes($domain);
|
||||
if (!empty($mailboxes)) {
|
||||
foreach ($mailboxes as $mailbox) {
|
||||
$data[] = mailbox_get_mailbox_details($mailbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$alias_domains = mailbox_get_alias_domains($domain);
|
||||
if (!empty($alias_domains)) {
|
||||
foreach ($alias_domains as $alias_domain) {
|
||||
$data[] = mailbox_get_alias_domain_details($alias_domain);
|
||||
case "resource":
|
||||
switch ($object) {
|
||||
case "all":
|
||||
$domains = mailbox_get_domains();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$resources = mailbox_get_resources($domain);
|
||||
if (!empty($resources)) {
|
||||
foreach ($resources as $resource) {
|
||||
$data[] = mailbox_get_resource_details($resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
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());
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$aliases = mailbox_get_aliases($domain);
|
||||
if (!empty($aliases)) {
|
||||
foreach ($aliases as $alias) {
|
||||
$data[] = mailbox_get_alias_details($alias);
|
||||
case "alias-domain":
|
||||
switch ($object) {
|
||||
case "all":
|
||||
$domains = mailbox_get_domains();
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$alias_domains = mailbox_get_alias_domains($domain);
|
||||
if (!empty($alias_domains)) {
|
||||
foreach ($alias_domains as $alias_domain) {
|
||||
$data[] = mailbox_get_alias_domain_details($alias_domain);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$data = mailbox_get_alias_details($object);
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode(mailbox_get_alias_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "domain-admin":
|
||||
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)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
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());
|
||||
if (!empty($domains)) {
|
||||
foreach ($domains as $domain) {
|
||||
$aliases = mailbox_get_aliases($domain);
|
||||
if (!empty($aliases)) {
|
||||
foreach ($aliases as $alias) {
|
||||
$data[] = mailbox_get_alias_details($alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$data = get_domain_admin_details($object);
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
default:
|
||||
$data = mailbox_get_alias_details($object);
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode(mailbox_get_alias_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "domain-admin":
|
||||
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)) {
|
||||
echo '{}';
|
||||
}
|
||||
else {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{}';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$data = get_domain_admin_details($object);
|
||||
if (!isset($data) || empty($data)) {
|
||||
echo '{}';
|
||||
}
|
||||
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));
|
||||
list($req, $sigs) = $data;
|
||||
$_SESSION['regReq'] = json_encode($req);
|
||||
echo 'var req = ' . json_encode($req) . '; var sigs = ' . json_encode($sigs) . ';';
|
||||
}
|
||||
else {
|
||||
echo json_encode(get_domain_admin_details($object), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "u2f-authentication":
|
||||
if (isset($_SESSION['pending_mailcow_cc_username']) && $_SESSION['pending_mailcow_cc_username'] == $object) {
|
||||
$reqs = json_encode($u2f->getAuthenticateData(get_u2f_registrations($object)));
|
||||
$_SESSION['authReq'] = $reqs;
|
||||
echo 'var req = ' . $reqs . ';';
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
echo '{}';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
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) {
|
||||
echo json_encode(array(
|
||||
'type' => 'error',
|
||||
'message' => 'Deletion of item failed'
|
||||
));
|
||||
exit();
|
||||
}
|
||||
echo json_encode(array(
|
||||
'type' => 'success',
|
||||
'message' => 'Task completed'
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo json_encode(array(
|
||||
'type' => 'error',
|
||||
'message' => 'Cannot find address array in post data'
|
||||
));
|
||||
}
|
||||
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));
|
||||
list($req, $sigs) = $data;
|
||||
$_SESSION['regReq'] = json_encode($req);
|
||||
echo 'var req = ' . json_encode($req) . '; var sigs = ' . json_encode($sigs) . ';';
|
||||
case "edit":
|
||||
switch ($category) {
|
||||
case "alias":
|
||||
if (isset($_POST['address']) && isset($_POST['active'])) {
|
||||
$address = 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',
|
||||
'message' => 'Edit item failed'
|
||||
));
|
||||
exit();
|
||||
}
|
||||
echo json_encode(array(
|
||||
'type' => 'success',
|
||||
'message' => 'Task completed'
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo json_encode(array(
|
||||
'type' => 'error',
|
||||
'message' => 'Cannot find address array in post data'
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "u2f-authentication":
|
||||
if (isset($_SESSION['pending_mailcow_cc_username']) && $_SESSION['pending_mailcow_cc_username'] == $object) {
|
||||
$reqs = json_encode($u2f->getAuthenticateData(get_u2f_registrations($object)));
|
||||
$_SESSION['authReq'] = $reqs;
|
||||
echo 'var req = ' . $reqs . ';';
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
echo '{}';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ $lang['danger']['alias_goto_identical'] = "Alias and goto address must not be id
|
||||
$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_modified'] = "Changes to alias have been saved";
|
||||
$lang['success']['alias_modified'] = "Changes to alias/es %s have been saved";
|
||||
$lang['success']['aliasd_modified'] = "Changes to alias domain have been saved";
|
||||
$lang['success']['mailbox_modified'] = "Changes to mailbox %s have been saved";
|
||||
$lang['success']['resource_modified'] = "Changes to mailbox %s have been saved";
|
||||
@ -79,7 +79,7 @@ $lang['danger']['mailbox_quota_left_exceeded'] = "Not enough space left (space l
|
||||
$lang['success']['mailbox_added'] = "Mailbox %s has been added";
|
||||
$lang['success']['resource_added'] = "Resource %s has been added";
|
||||
$lang['success']['domain_removed'] = "Domain %s has been removed";
|
||||
$lang['success']['alias_removed'] = "Alias-Adresse %s has been removed";
|
||||
$lang['success']['alias_removed'] = "Alias %s has been removed";
|
||||
$lang['success']['alias_domain_removed'] = "Alias domain %s has been removed";
|
||||
$lang['success']['domain_admin_removed'] = "Domain administrator %s has been removed";
|
||||
$lang['success']['mailbox_removed'] = "Mailbox %s has been removed";
|
||||
|
@ -89,6 +89,14 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="alias_table" class="table table-striped"></table>
|
||||
<div class="mass-actions">
|
||||
<span id="select_all_aliases" class="mass-select-all">Toggle all</span>
|
||||
<br /><span>(
|
||||
<a id="delete_selected_alias" href="#" class="mass-each-action">delete</a> |
|
||||
<a id="activate_selected_alias" href="#" class="mass-each-action">activate</a> |
|
||||
<a id="deactivate_selected_alias" href="#" class="mass-each-action">deactivate</a>)
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="footer-add-item"><a href="/add.php?alias"><?=$lang['mailbox']['add_alias'];?></a></span> </div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user