Merge pull request #2594 from FELDSAM-INC/domain-default-mailbox-quota
Default quota for mailbox
This commit is contained in:
@@ -326,9 +326,18 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
$description = $_data['description'];
|
||||
$aliases = $_data['aliases'];
|
||||
$mailboxes = $_data['mailboxes'];
|
||||
$defquota = $_data['defquota'];
|
||||
$maxquota = $_data['maxquota'];
|
||||
$restart_sogo = $_data['restart_sogo'];
|
||||
$quota = $_data['quota'];
|
||||
if ($defquota > $maxquota) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
||||
'msg' => 'mailbox_defquota_exceeds_mailbox_maxquota'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ($maxquota > $quota) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
@@ -337,6 +346,14 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ($defquota == "0" || empty($defquota)) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
||||
'msg' => 'defquota_empty'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ($maxquota == "0" || empty($maxquota)) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
@@ -392,13 +409,14 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$stmt = $pdo->prepare("INSERT INTO `domain` (`domain`, `description`, `aliases`, `mailboxes`, `maxquota`, `quota`, `backupmx`, `gal`, `active`, `relay_all_recipients`)
|
||||
VALUES (:domain, :description, :aliases, :mailboxes, :maxquota, :quota, :backupmx, :gal, :active, :relay_all_recipients)");
|
||||
$stmt = $pdo->prepare("INSERT INTO `domain` (`domain`, `description`, `aliases`, `mailboxes`, `defquota`, `maxquota`, `quota`, `backupmx`, `gal`, `active`, `relay_all_recipients`)
|
||||
VALUES (:domain, :description, :aliases, :mailboxes, :defquota, :maxquota, :quota, :backupmx, :gal, :active, :relay_all_recipients)");
|
||||
$stmt->execute(array(
|
||||
':domain' => $domain,
|
||||
':description' => $description,
|
||||
':aliases' => $aliases,
|
||||
':mailboxes' => $mailboxes,
|
||||
':defquota' => $defquota,
|
||||
':maxquota' => $maxquota,
|
||||
':quota' => $quota,
|
||||
':backupmx' => $backupmx,
|
||||
@@ -1869,6 +1887,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
$relayhost = (isset($_data['relayhost'])) ? intval($_data['relayhost']) : $is_now['relayhost'];
|
||||
$aliases = (!empty($_data['aliases'])) ? $_data['aliases'] : $is_now['max_num_aliases_for_domain'];
|
||||
$mailboxes = (isset($_data['mailboxes']) && $_data['mailboxes'] != '') ? intval($_data['mailboxes']) : $is_now['max_num_mboxes_for_domain'];
|
||||
$defquota = (!empty($_data['defquota'])) ? $_data['defquota'] : ($is_now['def_quota_for_mbox'] / 1048576);
|
||||
$maxquota = (!empty($_data['maxquota'])) ? $_data['maxquota'] : ($is_now['max_quota_for_mbox'] / 1048576);
|
||||
$quota = (!empty($_data['quota'])) ? $_data['quota'] : ($is_now['max_quota_for_domain'] / 1048576);
|
||||
$description = (!empty($_data['description'])) ? $_data['description'] : $is_now['description'];
|
||||
@@ -1900,6 +1919,22 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
)");
|
||||
$stmt->execute(array(':domain' => $domain));
|
||||
$AliasData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if ($defquota > $maxquota) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
||||
'msg' => 'mailbox_defquota_exceeds_mailbox_maxquota'
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if ($defquota == "0" || empty($defquota)) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
||||
'msg' => 'defquota_empty'
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if ($maxquota > $quota) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
@@ -1954,6 +1989,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
`gal` = :gal,
|
||||
`active` = :active,
|
||||
`quota` = :quota,
|
||||
`defquota` = :defquota,
|
||||
`maxquota` = :maxquota,
|
||||
`relayhost` = :relayhost,
|
||||
`mailboxes` = :mailboxes,
|
||||
@@ -1966,6 +2002,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
':gal' => $gal,
|
||||
':active' => $active,
|
||||
':quota' => $quota,
|
||||
':defquota' => $defquota,
|
||||
':maxquota' => $maxquota,
|
||||
':relayhost' => $relayhost,
|
||||
':mailboxes' => $mailboxes,
|
||||
@@ -2924,6 +2961,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
`description`,
|
||||
`aliases`,
|
||||
`mailboxes`,
|
||||
`defquota`,
|
||||
`maxquota`,
|
||||
`quota`,
|
||||
`relayhost`,
|
||||
@@ -2955,6 +2993,10 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
if ($domaindata['max_new_mailbox_quota'] > ($row['maxquota'] * 1048576)) {
|
||||
$domaindata['max_new_mailbox_quota'] = ($row['maxquota'] * 1048576);
|
||||
}
|
||||
$domaindata['def_new_mailbox_quota'] = $domaindata['max_new_mailbox_quota'];
|
||||
if ($domaindata['def_new_mailbox_quota'] > ($row['defquota'] * 1048576)) {
|
||||
$domaindata['def_new_mailbox_quota'] = ($row['defquota'] * 1048576);
|
||||
}
|
||||
$domaindata['quota_used_in_domain'] = $MailboxDataDomain['in_use'];
|
||||
$domaindata['mboxes_in_domain'] = $MailboxDataDomain['count'];
|
||||
$domaindata['mboxes_left'] = $row['mailboxes'] - $MailboxDataDomain['count'];
|
||||
@@ -2962,6 +3004,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
||||
$domaindata['description'] = $row['description'];
|
||||
$domaindata['max_num_aliases_for_domain'] = $row['aliases'];
|
||||
$domaindata['max_num_mboxes_for_domain'] = $row['mailboxes'];
|
||||
$domaindata['def_quota_for_mbox'] = $row['defquota'] * 1048576;
|
||||
$domaindata['max_quota_for_mbox'] = $row['maxquota'] * 1048576;
|
||||
$domaindata['max_quota_for_domain'] = $row['quota'] * 1048576;
|
||||
$domaindata['relayhost'] = $row['relayhost'];
|
||||
|
@@ -189,7 +189,8 @@ function init_db_schema() {
|
||||
"description" => "VARCHAR(255)",
|
||||
"aliases" => "INT(10) NOT NULL DEFAULT '0'",
|
||||
"mailboxes" => "INT(10) NOT NULL DEFAULT '0'",
|
||||
"maxquota" => "BIGINT(20) NOT NULL DEFAULT '0'",
|
||||
"defquota" => "BIGINT(20) NOT NULL DEFAULT '3072'",
|
||||
"maxquota" => "BIGINT(20) NOT NULL DEFAULT '102400'",
|
||||
"quota" => "BIGINT(20) NOT NULL DEFAULT '102400'",
|
||||
"relayhost" => "VARCHAR(255) NOT NULL DEFAULT '0'",
|
||||
"backupmx" => "TINYINT(1) NOT NULL DEFAULT '0'",
|
||||
|
Reference in New Issue
Block a user