[Web] Allow to select aliases for BCC

master
andryyy 2021-06-03 08:00:59 +02:00
parent 1bad74101f
commit 735bcb2f55
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
3 changed files with 21 additions and 5 deletions

View File

@ -949,6 +949,9 @@ function user_get_alias_details($username) {
if (!filter_var($username, FILTER_VALIDATE_EMAIL)) {
return false;
}
if (!hasMailboxObjectAccess($username, $_SESSION['mailcow_cc_role'], $username)) {
return false;
}
$data['address'] = $username;
$stmt = $pdo->prepare("SELECT `address` AS `shared_aliases`, `public_comment` FROM `alias`
WHERE `goto` REGEXP :username_goto

View File

@ -565,13 +565,13 @@ jQuery(function($){
ft_bcc_table = FooTable.init('#bcc_table', {
"columns": [
{"name":"chkbox","title":"","style":{"min-width":"60px","width":"60px"},"filterable": false,"sortable": false,"type":"html"},
{"sorted": true,"name":"id","title":"ID","style":{"maxWidth":"60px","width":"60px","text-align":"center"}},
{"sorted": true,"name":"id","title":"ID","style":{"min-width":"60px","width":"60px","text-align":"center"}},
{"name":"type","title":lang.bcc_type},
{"name":"local_dest","title":lang.bcc_local_dest},
{"name":"bcc_dest","title":lang.bcc_destinations},
{"name":"domain","title":lang.domain,"breakpoints":"xs sm"},
{"name":"active","filterable": false,"style":{"maxWidth":"80px","width":"80px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
{"name":"active","filterable": false,"style":{"min-width":"80px","width":"80px"},"title":lang.active,"formatter": function(value){return 1==value?'<i class="bi bi-check-lg"></i>':0==value&&'<i class="bi bi-x-lg"></i>';}},
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","min-width":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
],
"empty": lang.empty,
"rows": $.ajax({

View File

@ -650,25 +650,38 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="local_dest"><?=$lang['mailbox']['bcc_local_dest'];?></label>
<div class="col-sm-10">
<select data-live-search="true" name="local_dest" required>
<select data-live-search="true" data-size="20" name="local_dest" required>
<?php
$domains = mailbox('get', 'domains');
$alias_domains = mailbox('get', 'alias_domains');
if (!empty($domains)) {
echo "<optgroup label=\"Domains\">";
foreach ($domains as $domain) {
echo "<option>".htmlspecialchars($domain)."</option>";
}
echo "</optgroup>";
}
if (!empty($alias_domains)) {
echo "<optgroup label=\"Alias Domains\">";
foreach ($alias_domains as $alias_domain) {
echo "<option>".htmlspecialchars($alias_domain)."</option>";
}
echo "</optgroup>";
}
if (!empty($domains)) {
foreach ($domains as $domain) {
$mailboxes = mailbox('get', 'mailboxes', $domain);
foreach ($mailboxes as $mailbox) {
echo "<optgroup label=\"" . htmlspecialchars($mailbox) . "\">";
echo "<option> " . htmlspecialchars($mailbox) . "</option>";
$user_alias_details = user_get_alias_details($mailbox);
foreach ($user_alias_details['direct_aliases'] as $k => $v) {
echo "<option>" . htmlspecialchars($k) . "</option>";
}
foreach ($user_alias_details['shared_aliases'] as $k => $v) {
echo "<option>" . htmlspecialchars($k) . "</option>";
}
echo "</optgroup>";
}
}
}