|
@@ -1045,7 +1045,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
$password2 = '';
|
|
|
$password_hashed = '';
|
|
|
}
|
|
|
- if (!$_extra['iam_create_login'] && ((!isset($_SESSION['acl']['unlimited_quota']) || $_SESSION['acl']['unlimited_quota'] != "1") && $quota_m === 0)) {
|
|
|
+ if (!$_extra['hasAccess'] && ((!isset($_SESSION['acl']['unlimited_quota']) || $_SESSION['acl']['unlimited_quota'] != "1") && $quota_m === 0)) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1101,7 +1101,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
- if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain) && !$_extra['iam_create_login']) {
|
|
|
+ if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain) && !$_extra['hasAccess']) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1364,6 +1364,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
$attribute_hash = sha1(json_encode($mbox_template_data["attributes"]));
|
|
|
$mbox_template_data = json_decode($mbox_template_data["attributes"], true);
|
|
|
$mbox_template_data['domain'] = $_data['domain'];
|
|
|
+ $mbox_template_data['name'] = $_data['name'];
|
|
|
$mbox_template_data['local_part'] = $_data['local_part'];
|
|
|
$mbox_template_data['authsource'] = $_data['authsource'];
|
|
|
$mbox_template_data['attribute_hash'] = $attribute_hash;
|
|
@@ -1381,7 +1382,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return mailbox('add', 'mailbox', $mailbox_attributes, array('iam_create_login' => true));
|
|
|
+ return mailbox('add', 'mailbox', $mailbox_attributes, array('hasAccess' => $_data['hasAccess']));
|
|
|
break;
|
|
|
case 'resource':
|
|
|
$domain = idn_to_ascii(strtolower(trim($_data['domain'])), 0, INTL_IDNA_VARIANT_UTS46);
|
|
@@ -1749,7 +1750,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
else {
|
|
|
$usernames = $_data['username'];
|
|
|
}
|
|
|
- if (!isset($_SESSION['acl']['tls_policy']) || $_SESSION['acl']['tls_policy'] != "1" ) {
|
|
|
+ if (!$_extra['hasAccess'] && (!isset($_SESSION['acl']['tls_policy']) || $_SESSION['acl']['tls_policy'] != "1")) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1758,7 +1759,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
return false;
|
|
|
}
|
|
|
foreach ($usernames as $username) {
|
|
|
- if (!filter_var($username, FILTER_VALIDATE_EMAIL) || !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username)) {
|
|
|
+ if (!$_extra['hasAccess'] && (!filter_var($username, FILTER_VALIDATE_EMAIL) || !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username))) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1766,7 +1767,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
);
|
|
|
continue;
|
|
|
}
|
|
|
- $is_now = mailbox('get', 'tls_policy', $username);
|
|
|
+ $is_now = mailbox('get', 'tls_policy', $username, $_extra);
|
|
|
if (!empty($is_now)) {
|
|
|
$tls_enforce_in = (isset($_data['tls_enforce_in'])) ? intval($_data['tls_enforce_in']) : $is_now['tls_enforce_in'];
|
|
|
$tls_enforce_out = (isset($_data['tls_enforce_out'])) ? intval($_data['tls_enforce_out']) : $is_now['tls_enforce_out'];
|
|
@@ -1803,7 +1804,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
else {
|
|
|
$usernames = $_data['username'];
|
|
|
}
|
|
|
- if (!isset($_SESSION['acl']['quarantine_notification']) || $_SESSION['acl']['quarantine_notification'] != "1" ) {
|
|
|
+ if (!$_extra['hasAccess'] && (!isset($_SESSION['acl']['quarantine_notification']) || $_SESSION['acl']['quarantine_notification'] != "1")) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1812,7 +1813,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
return false;
|
|
|
}
|
|
|
foreach ($usernames as $username) {
|
|
|
- if (!filter_var($username, FILTER_VALIDATE_EMAIL) || !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username)) {
|
|
|
+ if (!$_extra['hasAccess'] && (!filter_var($username, FILTER_VALIDATE_EMAIL) || !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username))) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1820,7 +1821,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
);
|
|
|
continue;
|
|
|
}
|
|
|
- $is_now = mailbox('get', 'quarantine_notification', $username);
|
|
|
+ $is_now = mailbox('get', 'quarantine_notification', $username, $_extra);
|
|
|
if (!empty($is_now)) {
|
|
|
$quarantine_notification = (isset($_data['quarantine_notification'])) ? $_data['quarantine_notification'] : $is_now['quarantine_notification'];
|
|
|
}
|
|
@@ -1862,7 +1863,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
else {
|
|
|
$usernames = $_data['username'];
|
|
|
}
|
|
|
- if (!isset($_SESSION['acl']['quarantine_category']) || $_SESSION['acl']['quarantine_category'] != "1" ) {
|
|
|
+ if (!$_extra['hasAccess'] && (!isset($_SESSION['acl']['quarantine_category']) || $_SESSION['acl']['quarantine_category'] != "1")) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1871,7 +1872,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
return false;
|
|
|
}
|
|
|
foreach ($usernames as $username) {
|
|
|
- if (!filter_var($username, FILTER_VALIDATE_EMAIL) || !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username)) {
|
|
|
+ if (!$_extra['hasAccess'] && (!filter_var($username, FILTER_VALIDATE_EMAIL) || !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $username))) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -1879,7 +1880,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
);
|
|
|
continue;
|
|
|
}
|
|
|
- $is_now = mailbox('get', 'quarantine_category', $username);
|
|
|
+ $is_now = mailbox('get', 'quarantine_category', $username, $_extra);
|
|
|
if (!empty($is_now)) {
|
|
|
$quarantine_category = (isset($_data['quarantine_category'])) ? $_data['quarantine_category'] : $is_now['quarantine_category'];
|
|
|
}
|
|
@@ -2923,7 +2924,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
);
|
|
|
continue;
|
|
|
}
|
|
|
- $is_now = mailbox('get', 'mailbox_details', $username);
|
|
|
+ $is_now = mailbox('get', 'mailbox_details', $username, $_extra);
|
|
|
if (isset($_data['protocol_access'])) {
|
|
|
$_data['protocol_access'] = (array)$_data['protocol_access'];
|
|
|
$_data['imap_access'] = (in_array('imap', $_data['protocol_access'])) ? 1 : 0;
|
|
@@ -2963,7 +2964,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
continue;
|
|
|
}
|
|
|
// if already 0 == ok
|
|
|
- if ((!isset($_SESSION['acl']['unlimited_quota']) || $_SESSION['acl']['unlimited_quota'] != "1") && ($quota_m == 0 && $is_now['quota'] != 0)) {
|
|
|
+ if (!$_extra['hasAccess'] && (!isset($_SESSION['acl']['unlimited_quota']) || $_SESSION['acl']['unlimited_quota'] != "1") && ($quota_m == 0 && $is_now['quota'] != 0)) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -2971,7 +2972,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
- if (!hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
|
|
|
+ if (!$_extra['hasAccess'] && !hasDomainAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $domain)) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -2998,7 +2999,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
}
|
|
|
$extra_acls = array();
|
|
|
if (isset($_data['extended_sender_acl'])) {
|
|
|
- if (!isset($_SESSION['acl']['extend_sender_acl']) || $_SESSION['acl']['extend_sender_acl'] != "1" ) {
|
|
|
+ if (!$_extra['hasAccess'] && (!isset($_SESSION['acl']['extend_sender_acl']) || $_SESSION['acl']['extend_sender_acl'] != "1")) {
|
|
|
$_SESSION['return'][] = array(
|
|
|
'type' => 'danger',
|
|
|
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
|
|
@@ -3493,7 +3494,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
}
|
|
|
|
|
|
$attribute_hash = sha1(json_encode($mbox_template_data["attributes"]));
|
|
|
- $is_now = mailbox('get', 'mailbox_details', $_data['username']);
|
|
|
+ $is_now = mailbox('get', 'mailbox_details', $_data['username'], array('hasAccess' => $_data['hasAccess']));
|
|
|
$name = ltrim(rtrim($_data['name'], '>'), '<');
|
|
|
if ($is_now['attributes']['attribute_hash'] == $attribute_hash && $is_now['name'] == $name)
|
|
|
return true;
|
|
@@ -3529,19 +3530,20 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
}
|
|
|
|
|
|
$mailbox_attributes['quota'] = intval($mailbox_attributes['quota'] / 1048576);
|
|
|
- $result = mailbox('edit', 'mailbox', $mailbox_attributes);
|
|
|
+ $result = mailbox('edit', 'mailbox', $mailbox_attributes, array('hasAccess' => $_data['hasAccess']));
|
|
|
if ($result === false) return $result;
|
|
|
- $result = mailbox('edit', 'tls_policy', $tls_attributes);
|
|
|
+ $result = mailbox('edit', 'tls_policy', $tls_attributes, array('hasAccess' => $_data['hasAccess']));
|
|
|
if ($result === false) return $result;
|
|
|
- $result = mailbox('edit', 'quarantine_notification', $quarantine_attributes);
|
|
|
+ $result = mailbox('edit', 'quarantine_notification', $quarantine_attributes, array('hasAccess' => $_data['hasAccess']));
|
|
|
if ($result === false) return $result;
|
|
|
- $result = mailbox('edit', 'quarantine_category', $quarantine_attributes);
|
|
|
+ $result = mailbox('edit', 'quarantine_category', $quarantine_attributes, array('hasAccess' => $_data['hasAccess']));
|
|
|
if ($result === false) return $result;
|
|
|
- $result = ratelimit('edit', 'mailbox', $ratelimit_attributes);
|
|
|
+ $result = ratelimit('edit', 'mailbox', $ratelimit_attributes, array('hasAccess' => $_data['hasAccess']));
|
|
|
if ($result === false) return $result;
|
|
|
- $result = acl('edit', 'user', $acl_attributes);
|
|
|
+ $result = acl('edit', 'user', $acl_attributes, array('hasAccess' => $_data['hasAccess']));
|
|
|
if ($result === false) return $result;
|
|
|
|
|
|
+ $_SESSION['return'] = array();
|
|
|
return true;
|
|
|
break;
|
|
|
case 'mailbox_templates':
|
|
@@ -4077,7 +4079,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
case 'tls_policy':
|
|
|
$attrs = array();
|
|
|
if (isset($_data) && filter_var($_data, FILTER_VALIDATE_EMAIL)) {
|
|
|
- if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
|
|
|
+ if (!$_extra['hasAccess'] && !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -4096,7 +4098,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
case 'quarantine_notification':
|
|
|
$attrs = array();
|
|
|
if (isset($_data) && filter_var($_data, FILTER_VALIDATE_EMAIL)) {
|
|
|
- if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
|
|
|
+ if (!$_extra['hasAccess'] && !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -4112,7 +4114,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
case 'quarantine_category':
|
|
|
$attrs = array();
|
|
|
if (isset($_data) && filter_var($_data, FILTER_VALIDATE_EMAIL)) {
|
|
|
- if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
|
|
|
+ if (!$_extra['hasAccess'] && (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data))) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -4793,7 +4795,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
}
|
|
|
break;
|
|
|
case 'mailbox_details':
|
|
|
- if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
|
|
|
+ if (!$_extra['hasAccess'] && !hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
|
|
|
return false;
|
|
|
}
|
|
|
$mailboxdata = array();
|
|
@@ -4891,7 +4893,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
else if ($SaslLogs['service'] == 'pop3') {
|
|
|
$last_pop3_login = strtotime($SaslLogs['datetime']);
|
|
|
}
|
|
|
- else if ($SaslLogs['service'] == 'SSO') {
|
|
|
+ else if ($SaslLogs['service'] == 'SSO') {
|
|
|
$last_sso_login = strtotime($SaslLogs['datetime']);
|
|
|
}
|
|
|
}
|
|
@@ -4904,7 +4906,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
if (!isset($last_pop3_login) || $GLOBALS['SHOW_LAST_LOGIN'] === false) {
|
|
|
$last_pop3_login = 0;
|
|
|
}
|
|
|
- if (!isset($last_sso_login) || $GLOBALS['SHOW_LAST_LOGIN'] === false) {
|
|
|
+ if (!isset($last_sso_login) || $GLOBALS['SHOW_LAST_LOGIN'] === false) {
|
|
|
$last_sso_login = 0;
|
|
|
}
|
|
|
$mailboxdata['last_imap_login'] = $last_imap_login;
|
|
@@ -4956,7 +4958,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|
|
return $mailboxdata;
|
|
|
break;
|
|
|
case 'mailbox_templates':
|
|
|
- if ($_SESSION['mailcow_cc_role'] != "admin" && $_SESSION['mailcow_cc_role'] != "domainadmin" && !$_extra['iam_create_login']) {
|
|
|
+ if ($_SESSION['mailcow_cc_role'] != "admin" && $_SESSION['mailcow_cc_role'] != "domainadmin" && !$_extra['hasAccess']) {
|
|
|
return false;
|
|
|
}
|
|
|
$_data = (isset($_data)) ? intval($_data) : null;
|