|
@@ -109,6 +109,11 @@ function init_db_schema() {
|
|
|
if ($num_results == 0) {
|
|
|
$pdo->query("ALTER TABLE `mailbox` ADD `multiple_bookings` tinyint(1) NOT NULL DEFAULT '0'");
|
|
|
}
|
|
|
+ $stmt = $pdo->query("SHOW COLUMNS FROM `imapsync` LIKE 'delete1'");
|
|
|
+ $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
|
|
+ if ($num_results == 0) {
|
|
|
+ $pdo->query("ALTER TABLE `imapsync` ADD `delete1` tinyint(1) NOT NULL DEFAULT '0'");
|
|
|
+ }
|
|
|
$stmt = $pdo->query("SHOW COLUMNS FROM `mailbox` LIKE 'wants_tagged_subject'");
|
|
|
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
|
|
if ($num_results == 0) {
|
|
@@ -1075,6 +1080,7 @@ function add_syncjob($postarray) {
|
|
|
}
|
|
|
isset($postarray['active']) ? $active = '1' : $active = '0';
|
|
|
isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0';
|
|
|
+ isset($postarray['delete1']) ? $delete1 = '1' : $delete1 = '0';
|
|
|
$port1 = $postarray['port1'];
|
|
|
$host1 = $postarray['host1'];
|
|
|
$password1 = $postarray['password1'];
|
|
@@ -1147,12 +1153,13 @@ function add_syncjob($postarray) {
|
|
|
return false;
|
|
|
}
|
|
|
try {
|
|
|
- $stmt = $pdo->prepare("INSERT INTO `imapsync` (`user2`, `exclude`, `maxage`, `subfolder2`, `host1`, `authmech1`, `user1`, `password1`, `mins_interval`, `port1`, `enc1`, `delete2duplicates`, `active`)
|
|
|
- VALUES (:user2, :exclude, :maxage, :subfolder2, :host1, :authmech1, :user1, :password1, :mins_interval, :port1, :enc1, :delete2duplicates, :active)");
|
|
|
+ $stmt = $pdo->prepare("INSERT INTO `imapsync` (`user2`, `exclude`, `delete1`, `maxage`, `subfolder2`, `host1`, `authmech1`, `user1`, `password1`, `mins_interval`, `port1`, `enc1`, `delete2duplicates`, `active`)
|
|
|
+ VALUES (:user2, :exclude, :maxage, :delete1, :subfolder2, :host1, :authmech1, :user1, :password1, :mins_interval, :port1, :enc1, :delete2duplicates, :active)");
|
|
|
$stmt->execute(array(
|
|
|
':user2' => $username,
|
|
|
':exclude' => $exclude,
|
|
|
':maxage' => $maxage,
|
|
|
+ ':delete1' => $delete1,
|
|
|
':subfolder2' => $subfolder2,
|
|
|
':host1' => $host1,
|
|
|
':authmech1' => 'PLAIN',
|
|
@@ -1200,6 +1207,7 @@ function edit_syncjob($postarray) {
|
|
|
}
|
|
|
isset($postarray['active']) ? $active = '1' : $active = '0';
|
|
|
isset($postarray['delete2duplicates']) ? $delete2duplicates = '1' : $delete2duplicates = '0';
|
|
|
+ isset($postarray['delete1']) ? $delete1 = '1' : $delete1 = '0';
|
|
|
$id = $postarray['id'];
|
|
|
$port1 = $postarray['port1'];
|
|
|
$host1 = $postarray['host1'];
|
|
@@ -1273,10 +1281,11 @@ function edit_syncjob($postarray) {
|
|
|
return false;
|
|
|
}
|
|
|
try {
|
|
|
- $stmt = $pdo->prepare("UPDATE `imapsync` set `maxage` = :maxage, `subfolder2` = :subfolder2, `exclude` = :exclude, `host1` = :host1, `user1` = :user1, `password1` = :password1, `mins_interval` = :mins_interval, `port1` = :port1, `enc1` = :enc1, `delete2duplicates` = :delete2duplicates, `active` = :active
|
|
|
+ $stmt = $pdo->prepare("UPDATE `imapsync` set `delete1` = :delete1, `maxage` = :maxage, `subfolder2` = :subfolder2, `exclude` = :exclude, `host1` = :host1, `user1` = :user1, `password1` = :password1, `mins_interval` = :mins_interval, `port1` = :port1, `enc1` = :enc1, `delete2duplicates` = :delete2duplicates, `active` = :active
|
|
|
WHERE `user2` = :user2 AND `id` = :id");
|
|
|
$stmt->execute(array(
|
|
|
':user2' => $username,
|
|
|
+ ':delete1' => $delete1,
|
|
|
':id' => $id,
|
|
|
':exclude' => $exclude,
|
|
|
':maxage' => $maxage,
|
|
@@ -1757,6 +1766,7 @@ function get_domain_admin_details($domain_admin) {
|
|
|
try {
|
|
|
$stmt = $pdo->prepare("SELECT
|
|
|
`tfa`.`active` AS `tfa_active_int`,
|
|
|
+ CASE `tfa`.`active` WHEN 1 THEN '".$lang['mailbox']['yes']."' ELSE '".$lang['mailbox']['no']."' END AS `tfa_active`,
|
|
|
`domain_admins`.`username`,
|
|
|
`domain_admins`.`created`,
|
|
|
`domain_admins`.`active` AS `active_int`,
|
|
@@ -1768,11 +1778,15 @@ function get_domain_admin_details($domain_admin) {
|
|
|
':domain_admin' => $domain_admin
|
|
|
));
|
|
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
+ if (empty($row)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
$domainadmindata['username'] = $row['username'];
|
|
|
+ $domainadmindata['tfa_active'] = $row['tfa_active'];
|
|
|
$domainadmindata['active'] = $row['active'];
|
|
|
- $domainadmindata['active_int'] = $row['active_int'];
|
|
|
$domainadmindata['tfa_active_int'] = $row['tfa_active_int'];
|
|
|
- $domainadmindata['created'] = $row['created'];
|
|
|
+ $domainadmindata['active_int'] = $row['active_int'];
|
|
|
+ $domainadmindata['modified'] = $row['created'];
|
|
|
// GET SELECTED
|
|
|
$stmt = $pdo->prepare("SELECT `domain` FROM `domain`
|
|
|
WHERE `domain` IN (
|
|
@@ -1793,6 +1807,9 @@ function get_domain_admin_details($domain_admin) {
|
|
|
while($row = array_shift($rows)) {
|
|
|
$domainadmindata['unselected_domains'][] = $row['domain'];
|
|
|
}
|
|
|
+ if (!isset($domainadmindata['unselected_domains'])) {
|
|
|
+ $domainadmindata['unselected_domains'] = "";
|
|
|
+ }
|
|
|
}
|
|
|
catch(PDOException $e) {
|
|
|
$_SESSION['return'] = array(
|
|
@@ -2134,6 +2151,14 @@ function edit_domain_admin($postarray) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (empty($postarray['domain'])) {
|
|
|
+ $_SESSION['return'] = array(
|
|
|
+ 'type' => 'danger',
|
|
|
+ 'msg' => sprintf($lang['danger']['domain_invalid'])
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
if (!ctype_alnum(str_replace(array('_', '.', '-'), '', $username))) {
|
|
|
$_SESSION['return'] = array(
|
|
|
'type' => 'danger',
|
|
@@ -2164,7 +2189,7 @@ function edit_domain_admin($postarray) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if(isset($postarray['domain'])) {
|
|
|
+ if (isset($postarray['domain'])) {
|
|
|
foreach ($postarray['domain'] as $domain) {
|
|
|
try {
|
|
|
$stmt = $pdo->prepare("INSERT INTO `domain_admins` (`username`, `domain`, `created`, `active`)
|
|
@@ -2519,6 +2544,14 @@ function mailbox_add_domain($postarray) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if ($maxquota == "0" || empty($maxquota)) {
|
|
|
+ $_SESSION['return'] = array(
|
|
|
+ 'type' => 'danger',
|
|
|
+ 'msg' => sprintf($lang['danger']['maxquota_empty'])
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
isset($postarray['active']) ? $active = '1' : $active = '0';
|
|
|
isset($postarray['relay_all_recipients']) ? $relay_all_recipients = '1' : $relay_all_recipients = '0';
|
|
|
isset($postarray['backupmx']) ? $backupmx = '1' : $backupmx = '0';
|
|
@@ -2623,6 +2656,18 @@ function mailbox_add_alias($postarray) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ $stmt = $pdo->prepare("SELECT `address` FROM `alias`
|
|
|
+ WHERE `address`= :address");
|
|
|
+ $stmt->execute(array(':address' => $address));
|
|
|
+ $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
|
|
+ if ($num_results != 0) {
|
|
|
+ $_SESSION['return'] = array(
|
|
|
+ 'type' => 'danger',
|
|
|
+ 'msg' => sprintf($lang['danger']['is_alias_or_mailbox'], htmlspecialchars($address))
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
foreach ($addresses as $address) {
|
|
|
if (empty($address)) {
|
|
|
continue;
|
|
@@ -2632,6 +2677,15 @@ function mailbox_add_alias($postarray) {
|
|
|
$local_part = strstr($address, '@', true);
|
|
|
$address = $local_part.'@'.$domain;
|
|
|
|
|
|
+ $domaindata = mailbox_get_domain_details($domain);
|
|
|
+ if ($domaindata['aliases_left'] == 0) {
|
|
|
+ $_SESSION['return'] = array(
|
|
|
+ 'type' => 'danger',
|
|
|
+ 'msg' => sprintf($lang['danger']['max_alias_exceeded'])
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
$stmt = $pdo->prepare("SELECT `domain` FROM `domain`
|
|
|
WHERE `domain`= :domain1 OR `domain` = (SELECT `target_domain` FROM `alias_domain` WHERE `alias_domain` = :domain2)");
|
|
@@ -3432,7 +3486,7 @@ function mailbox_edit_domain($postarray) {
|
|
|
// aliases float
|
|
|
// mailboxes float
|
|
|
// maxquota float
|
|
|
- // quota float (Byte)
|
|
|
+ // quota float (Byte)
|
|
|
// active int
|
|
|
|
|
|
global $lang;
|
|
@@ -3519,6 +3573,14 @@ function mailbox_edit_domain($postarray) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if ($maxquota == "0" || empty($maxquota)) {
|
|
|
+ $_SESSION['return'] = array(
|
|
|
+ 'type' => 'danger',
|
|
|
+ 'msg' => sprintf($lang['danger']['maxquota_empty'])
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
if ($MailboxData['maxquota'] > $maxquota) {
|
|
|
$_SESSION['return'] = array(
|
|
|
'type' => 'danger',
|
|
@@ -4271,6 +4333,10 @@ function mailbox_get_domain_details($domain) {
|
|
|
':domain' => $domain,
|
|
|
));
|
|
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
+ if (empty($row)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
$stmt = $pdo->prepare("SELECT COUNT(*) AS `count`, COALESCE(SUM(`quota`), 0) as `in_use` FROM `mailbox` WHERE `kind` NOT REGEXP 'location|thing|group' AND `domain` = :domain");
|
|
|
$stmt->execute(array(':domain' => $row['domain']));
|
|
|
$MailboxDataDomain = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
@@ -4303,8 +4369,9 @@ function mailbox_get_domain_details($domain) {
|
|
|
$stmt->execute(array(
|
|
|
':domain' => $domain,
|
|
|
));
|
|
|
- $AliasData = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
- (isset($AliasData['alias_count'])) ? $domaindata['aliases_in_domain'] = $AliasData['alias_count'] : $domaindata['aliases_in_domain'] = "0";
|
|
|
+ $AliasDataDomain = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
+ (isset($AliasDataDomain['alias_count'])) ? $domaindata['aliases_in_domain'] = $AliasDataDomain['alias_count'] : $domaindata['aliases_in_domain'] = "0";
|
|
|
+ $domaindata['aliases_left'] = $row['aliases'] - $AliasDataDomain['alias_count'];
|
|
|
}
|
|
|
catch (PDOException $e) {
|
|
|
$_SESSION['return'] = array(
|