andryyy 2019-11-11 09:55:24 +01:00
commit 64b64f1dcb
16 changed files with 947 additions and 924 deletions

File diff suppressed because one or more lines are too long

View File

@ -46,7 +46,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$stmt = $pdo->prepare("SELECT `domain` FROM `mailbox` WHERE `username` = :username"); $stmt = $pdo->prepare("SELECT `domain` FROM `mailbox` WHERE `username` = :username");
$stmt->execute(array(':username' => $_SESSION['mailcow_cc_username'])); $stmt->execute(array(':username' => $_SESSION['mailcow_cc_username']));
$domain = $stmt->fetch(PDO::FETCH_ASSOC)['domain']; $domain = $stmt->fetch(PDO::FETCH_ASSOC)['domain'];
$validity = strtotime("+".$_data["validity"]." hour"); $validity = strtotime("+".$_data["validity"]." hour");
$letters = 'abcefghijklmnopqrstuvwxyz1234567890'; $letters = 'abcefghijklmnopqrstuvwxyz1234567890';
$random_name = substr(str_shuffle($letters), 0, 24); $random_name = substr(str_shuffle($letters), 0, 24);
$stmt = $pdo->prepare("INSERT INTO `spamalias` (`address`, `goto`, `validity`) VALUES $stmt = $pdo->prepare("INSERT INTO `spamalias` (`address`, `goto`, `validity`) VALUES
@ -485,7 +485,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
'msg' => 'comment_too_long' 'msg' => 'comment_too_long'
); );
return false; return false;
} }
if (empty($addresses[0])) { if (empty($addresses[0])) {
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
'type' => 'danger', 'type' => 'danger',
@ -841,7 +841,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
WHERE `domain` = :domain"); WHERE `domain` = :domain");
$stmt->execute(array(':domain' => $domain)); $stmt->execute(array(':domain' => $domain));
$DomainData = $stmt->fetch(PDO::FETCH_ASSOC); $DomainData = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt = $pdo->prepare("SELECT $stmt = $pdo->prepare("SELECT
COUNT(*) as count, COUNT(*) as count,
COALESCE(ROUND(SUM(`quota`)/1048576), 0) as `quota` COALESCE(ROUND(SUM(`quota`)/1048576), 0) as `quota`
FROM `mailbox` FROM `mailbox`
@ -945,7 +945,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
); );
return false; return false;
} }
$stmt = $pdo->prepare("INSERT INTO `mailbox` (`username`, `password`, `name`, `quota`, `local_part`, `domain`, `attributes`, `active`) $stmt = $pdo->prepare("INSERT INTO `mailbox` (`username`, `password`, `name`, `quota`, `local_part`, `domain`, `attributes`, `active`)
VALUES (:username, :password_hashed, :name, :quota_b, :local_part, :domain, :mailbox_attrs, :active)"); VALUES (:username, :password_hashed, :name, :quota_b, :local_part, :domain, :mailbox_attrs, :active)");
$stmt->execute(array( $stmt->execute(array(
':username' => $username, ':username' => $username,
@ -1073,7 +1073,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
); );
return false; return false;
} }
$stmt = $pdo->prepare("INSERT INTO `mailbox` (`username`, `password`, `name`, `quota`, `local_part`, `domain`, `active`, `multiple_bookings`, `kind`) $stmt = $pdo->prepare("INSERT INTO `mailbox` (`username`, `password`, `name`, `quota`, `local_part`, `domain`, `active`, `multiple_bookings`, `kind`)
VALUES (:name, 'RESOURCE', :description, 0, :local_part, :domain, :active, :multiple_bookings, :kind)"); VALUES (:name, 'RESOURCE', :description, 0, :local_part, :domain, :active, :multiple_bookings, :kind)");
$stmt->execute(array( $stmt->execute(array(
':name' => $name, ':name' => $name,
@ -1249,7 +1249,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
'msg' => 'access_denied' 'msg' => 'access_denied'
); );
continue; continue;
} }
$stmt = $pdo->prepare("UPDATE `mailbox` $stmt = $pdo->prepare("UPDATE `mailbox`
SET `attributes` = JSON_SET(`attributes`, '$.quarantine_notification', :quarantine_notification) SET `attributes` = JSON_SET(`attributes`, '$.quarantine_notification', :quarantine_notification)
WHERE `username` = :username"); WHERE `username` = :username");
@ -1360,7 +1360,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
continue; continue;
} }
$validity = round((int)time() + ($_data['validity'] * 3600)); $validity = round((int)time() + ($_data['validity'] * 3600));
$stmt = $pdo->prepare("UPDATE `spamalias` SET `validity` = :validity WHERE $stmt = $pdo->prepare("UPDATE `spamalias` SET `validity` = :validity WHERE
`address` = :address"); `address` = :address");
$stmt->execute(array( $stmt->execute(array(
':address' => $address, ':address' => $address,
@ -1888,7 +1888,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
); );
continue; continue;
} }
$stmt = $pdo->prepare("UPDATE `domain` SET $stmt = $pdo->prepare("UPDATE `domain` SET
`description` = :description, `description` = :description,
`gal` = :gal `gal` = :gal
WHERE `domain` = :domain"); WHERE `domain` = :domain");
@ -1928,7 +1928,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
continue; continue;
} }
// todo: should be using api here // todo: should be using api here
$stmt = $pdo->prepare("SELECT $stmt = $pdo->prepare("SELECT
COUNT(*) AS count, COUNT(*) AS count,
MAX(COALESCE(ROUND(`quota`/1048576), 0)) AS `biggest_mailbox`, MAX(COALESCE(ROUND(`quota`/1048576), 0)) AS `biggest_mailbox`,
COALESCE(ROUND(SUM(`quota`)/1048576), 0) AS `quota_all` COALESCE(ROUND(SUM(`quota`)/1048576), 0) AS `quota_all`
@ -2009,7 +2009,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
); );
continue; continue;
} }
$stmt = $pdo->prepare("UPDATE `domain` SET $stmt = $pdo->prepare("UPDATE `domain` SET
`relay_all_recipients` = :relay_all_recipients, `relay_all_recipients` = :relay_all_recipients,
`backupmx` = :backupmx, `backupmx` = :backupmx,
`gal` = :gal, `gal` = :gal,
@ -2071,7 +2071,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$domain = $is_now['domain']; $domain = $is_now['domain'];
$quota_b = $quota_m * 1048576; $quota_b = $quota_m * 1048576;
$password = (!empty($_data['password'])) ? $_data['password'] : null; $password = (!empty($_data['password'])) ? $_data['password'] : null;
$password2 = (!empty($_data['password2'])) ? $_data['password2'] : null; $password2 = (!empty($_data['password2'])) ? $_data['password2'] : null;
} }
else { else {
$_SESSION['return'][] = array( $_SESSION['return'][] = array(
@ -2517,14 +2517,14 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
} }
$stmt = $pdo->prepare("SELECT `domain` FROM `domain` $stmt = $pdo->prepare("SELECT `domain` FROM `domain`
WHERE `domain` NOT IN ( WHERE `domain` NOT IN (
SELECT REPLACE(`send_as`, '@', '') FROM `sender_acl` SELECT REPLACE(`send_as`, '@', '') FROM `sender_acl`
WHERE `logged_in_as` = :logged_in_as1 WHERE `logged_in_as` = :logged_in_as1
AND `external` = '0' AND `external` = '0'
AND `send_as` LIKE '@%') AND `send_as` LIKE '@%')
UNION UNION
SELECT '*' FROM `domain` SELECT '*' FROM `domain`
WHERE '*' NOT IN ( WHERE '*' NOT IN (
SELECT `send_as` FROM `sender_acl` SELECT `send_as` FROM `sender_acl`
WHERE `logged_in_as` = :logged_in_as2 WHERE `logged_in_as` = :logged_in_as2
AND `external` = '0' AND `external` = '0'
)"); )");
@ -2546,7 +2546,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$stmt = $pdo->prepare("SELECT `address` FROM `alias` $stmt = $pdo->prepare("SELECT `address` FROM `alias`
WHERE `goto` != :goto WHERE `goto` != :goto
AND `address` NOT IN ( AND `address` NOT IN (
SELECT `send_as` FROM `sender_acl` SELECT `send_as` FROM `sender_acl`
WHERE `logged_in_as` = :logged_in_as WHERE `logged_in_as` = :logged_in_as
AND `external` = '0' AND `external` = '0'
AND `send_as` NOT LIKE '@%')"); AND `send_as` NOT LIKE '@%')");
@ -3074,11 +3074,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
if (!empty($row)) { if (!empty($row)) {
$_data = $row['target_domain']; $_data = $row['target_domain'];
} }
$stmt = $pdo->prepare("SELECT $stmt = $pdo->prepare("SELECT
`domain`, `domain`,
`description`, `description`,
`aliases`, `aliases`,
`mailboxes`, `mailboxes`,
`defquota`, `defquota`,
`maxquota`, `maxquota`,
`quota`, `quota`,
@ -3096,7 +3096,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
':domain' => $_data ':domain' => $_data
)); ));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
if (empty($row)) { if (empty($row)) {
return false; return false;
} }
$stmt = $pdo->prepare("SELECT COUNT(*) AS `count`, $stmt = $pdo->prepare("SELECT COUNT(*) AS `count`,
@ -3147,6 +3147,15 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$AliasDataDomain = $stmt->fetch(PDO::FETCH_ASSOC); $AliasDataDomain = $stmt->fetch(PDO::FETCH_ASSOC);
(isset($AliasDataDomain['alias_count'])) ? $domaindata['aliases_in_domain'] = $AliasDataDomain['alias_count'] : $domaindata['aliases_in_domain'] = "0"; (isset($AliasDataDomain['alias_count'])) ? $domaindata['aliases_in_domain'] = $AliasDataDomain['alias_count'] : $domaindata['aliases_in_domain'] = "0";
$domaindata['aliases_left'] = $row['aliases'] - $AliasDataDomain['alias_count']; $domaindata['aliases_left'] = $row['aliases'] - $AliasDataDomain['alias_count'];
if ($_SESSION['mailcow_cc_role'] == "admin")
{
$stmt = $pdo->prepare("SELECT GROUP_CONCAT(`username` SEPARATOR ', ') AS domain_admins FROM `domain_admins` WHERE `domain` = :domain");
$stmt->execute(array(
':domain' => $_data
));
$domain_admins = $stmt->fetch(PDO::FETCH_ASSOC);
(isset($domain_admins['domain_admins'])) ? $domaindata['domain_admins'] = $domain_admins['domain_admins'] : $domaindata['domain_admins'] = "-";
}
return $domaindata; return $domaindata;
break; break;
case 'mailbox_details': case 'mailbox_details':
@ -3726,7 +3735,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
curl_setopt($curl, CURLOPT_HTTPHEADER,array('Content-Type: text/xml')); curl_setopt($curl, CURLOPT_HTTPHEADER,array('Content-Type: text/xml'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, '<delete><query>user:' . $username . '</query></delete>'); curl_setopt($curl, CURLOPT_POSTFIELDS, '<delete><query>user:' . $username . '</query></delete>');
curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_TIMEOUT, 30);
$response = curl_exec($curl); $response = curl_exec($curl);
if ($response === false) { if ($response === false) {

View File

@ -10,11 +10,11 @@ $(document).ready(function() {
this._super(); this._super();
var self = this; var self = this;
var domains = []; var domains = [];
$.each(self.ft.rows.all, function(i, row){ $.each(self.ft.rows.all, function(i, row){
if((row.val().domain != null) && ($.inArray(row.val().domain, domains) === -1)) domains.push(row.val().domain); if((row.val().domain != null) && ($.inArray(row.val().domain, domains) === -1)) domains.push(row.val().domain);
}); });
$form_grp = $('<div/>', {'class': 'form-group'}) $form_grp = $('<div/>', {'class': 'form-group'})
.append($('<label/>', {'class': 'sr-only', text: 'Domain'})) .append($('<label/>', {'class': 'sr-only', text: 'Domain'}))
.prependTo(self.$form); .prependTo(self.$form);
@ -233,6 +233,7 @@ jQuery(function($){
{"name":"max_quota_for_mbox","title":lang.mailbox_quota,"breakpoints":"xs sm","style":{"width":"125px"}}, {"name":"max_quota_for_mbox","title":lang.mailbox_quota,"breakpoints":"xs sm","style":{"width":"125px"}},
{"name":"rl","title":"RL","breakpoints":"xs sm md lg","style":{"maxWidth":"100px","width":"100px"}}, {"name":"rl","title":"RL","breakpoints":"xs sm md lg","style":{"maxWidth":"100px","width":"100px"}},
{"name":"backupmx","filterable": false,"style":{"maxWidth":"120px","width":"120px"},"title":lang.backup_mx,"breakpoints":"xs sm md lg"}, {"name":"backupmx","filterable": false,"style":{"maxWidth":"120px","width":"120px"},"title":lang.backup_mx,"breakpoints":"xs sm md lg"},
{"name":"domain_admins","title":lang.domain_admins,"style":{"word-break":"break-all","min-width":"200px"},"breakpoints":"xs sm md lg","filterable":(role == "admin"),"visible":(role == "admin")},
{"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active}, {"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active},
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"240px","width":"240px"},"type":"html","title":lang.action,"breakpoints":"xs sm md"} {"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"240px","width":"240px"},"type":"html","title":lang.action,"breakpoints":"xs sm md"}
], ],

View File

@ -298,6 +298,7 @@
"active": "Actiu", "active": "Actiu",
"action": "Acció", "action": "Acció",
"backup_mx": "Backup MX", "backup_mx": "Backup MX",
"domain_admins": "Administradores de dominio",
"domain_aliases": "Àlies de domini", "domain_aliases": "Àlies de domini",
"target_domain": "Domini destí", "target_domain": "Domini destí",
"target_address": "Direcció Goto", "target_address": "Direcció Goto",

View File

@ -563,6 +563,7 @@
"active": "Aktivní", "active": "Aktivní",
"action": "Akce", "action": "Akce",
"backup_mx": "Záložní MX", "backup_mx": "Záložní MX",
"domain_admins": "Správci domén",
"domain_aliases": "Doménové aliasy", "domain_aliases": "Doménové aliasy",
"target_domain": "Cílová doména", "target_domain": "Cílová doména",
"target_address": "Cílová adresa", "target_address": "Cílová adresa",

View File

@ -569,6 +569,7 @@
"active": "Aktiv", "active": "Aktiv",
"action": "Aktion", "action": "Aktion",
"backup_mx": "Backup MX", "backup_mx": "Backup MX",
"domain_admins": "Domain-Administratoren",
"domain_aliases": "Domain-Aliasse", "domain_aliases": "Domain-Aliasse",
"target_domain": "Ziel-Domain", "target_domain": "Ziel-Domain",
"target_address": "Ziel-Adresse", "target_address": "Ziel-Adresse",

View File

@ -568,6 +568,7 @@
"active": "Active", "active": "Active",
"action": "Action", "action": "Action",
"backup_mx": "Backup MX", "backup_mx": "Backup MX",
"domain_admins": "Domain administrators",
"domain_aliases": "Domain aliases", "domain_aliases": "Domain aliases",
"target_domain": "Target domain", "target_domain": "Target domain",
"target_address": "Goto address", "target_address": "Goto address",

View File

@ -262,6 +262,7 @@
"active": "Activo", "active": "Activo",
"action": "Acción", "action": "Acción",
"backup_mx": "MX de respaldo", "backup_mx": "MX de respaldo",
"domain_admins": "Administradores por dominio",
"domain_aliases": "Alias de dominio", "domain_aliases": "Alias de dominio",
"target_domain": "Dominio destino", "target_domain": "Dominio destino",
"target_address": "Dirección destino", "target_address": "Dirección destino",

View File

@ -563,6 +563,7 @@
"active": "Aktiivinen", "active": "Aktiivinen",
"action": "Toiminnot", "action": "Toiminnot",
"backup_mx": "Varmuuskopiointi MX", "backup_mx": "Varmuuskopiointi MX",
"domain_admins": "Verkkotunnuksien järjestelmänvalvojat",
"domain_aliases": "Domain alueiden aliakset", "domain_aliases": "Domain alueiden aliakset",
"target_domain": "Kohde verkkotunnus alue", "target_domain": "Kohde verkkotunnus alue",
"target_address": "Siiretty osoitteseen", "target_address": "Siiretty osoitteseen",

View File

@ -259,6 +259,7 @@
"active": "Actif", "active": "Actif",
"action": "Action", "action": "Action",
"backup_mx": "MX de secours", "backup_mx": "MX de secours",
"domain_admins": "Administrateurs de domaines",
"domain_aliases": "Alias de domaine", "domain_aliases": "Alias de domaine",
"target_domain": "Domaine cible", "target_domain": "Domaine cible",
"target_address": "Adresse cible", "target_address": "Adresse cible",

View File

@ -182,6 +182,7 @@
"active": "Attiva", "active": "Attiva",
"action": "Azione", "action": "Azione",
"backup_mx": "Backup MX", "backup_mx": "Backup MX",
"domain_admins": "Amministratori di dominio",
"domain_aliases": "Alias di domini", "domain_aliases": "Alias di domini",
"target_domain": "Target domain", "target_domain": "Target domain",
"target_address": "Vai ad indirizzo", "target_address": "Vai ad indirizzo",

View File

@ -303,6 +303,7 @@
"active": "Aktīvs", "active": "Aktīvs",
"action": "Rīcība", "action": "Rīcība",
"backup_mx": "Rezerves kopija MX", "backup_mx": "Rezerves kopija MX",
"domain_admins": "Domēna administratori",
"domain_aliases": "Domēna aliases", "domain_aliases": "Domēna aliases",
"target_domain": "Mērķa domēns", "target_domain": "Mērķa domēns",
"target_address": "Doties uz adresi", "target_address": "Doties uz adresi",

View File

@ -565,6 +565,7 @@
"active": "Actief", "active": "Actief",
"action": "Handeling", "action": "Handeling",
"backup_mx": "Secundaire MX", "backup_mx": "Secundaire MX",
"domain_admins": "Domeinbeheerders",
"domain_aliases": "Domeinaliassen", "domain_aliases": "Domeinaliassen",
"target_domain": "Doeldomein", "target_domain": "Doeldomein",
"target_address": "Doeladres", "target_address": "Doeladres",

View File

@ -258,6 +258,7 @@
"active": "Aktywny", "active": "Aktywny",
"action": "Działanie", "action": "Działanie",
"backup_mx": "Backup MX", "backup_mx": "Backup MX",
"domain_admins": "Administratorzy domeny",
"domain_aliases": "Aliasy domeny", "domain_aliases": "Aliasy domeny",
"target_domain": "Domena docelowa", "target_domain": "Domena docelowa",
"target_address": "Adres Idź do", "target_address": "Adres Idź do",

View File

@ -148,6 +148,7 @@
"active": "Ativo", "active": "Ativo",
"action": "Ação", "action": "Ação",
"backup_mx": "Backup MX", "backup_mx": "Backup MX",
"domain_admins": "Administradores de domínio",
"domain_aliases": "Encaminhamento de Domínio", "domain_aliases": "Encaminhamento de Domínio",
"target_domain": "Domínio Destino", "target_domain": "Domínio Destino",
"target_address": "Encaminhar para", "target_address": "Encaminhar para",

View File

@ -259,6 +259,7 @@
"active": "Активный", "active": "Активный",
"action": "Действия", "action": "Действия",
"backup_mx": "Резервное копирование MX", "backup_mx": "Резервное копирование MX",
"domain_admins": "Администраторы домена",
"domain_aliases": "Псевдонимы доменов", "domain_aliases": "Псевдонимы доменов",
"target_domain": "Целевой домен", "target_domain": "Целевой домен",
"target_address": "Основной адрес", "target_address": "Основной адрес",