From 08c8976a9543c357251aba2edb09e39ab9e053e4 Mon Sep 17 00:00:00 2001 From: "andre.peters" Date: Sun, 21 Jan 2018 14:58:16 +0100 Subject: [PATCH] [SOGo] Show shared aliases and "allow to send as" addresses as FROM fields in SOGo --- data/Dockerfiles/sogo/bootstrap-sogo.sh | 11 +++++++---- data/web/inc/init_db.inc.php | 9 +++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/data/Dockerfiles/sogo/bootstrap-sogo.sh b/data/Dockerfiles/sogo/bootstrap-sogo.sh index 4bd9d570..59877927 100755 --- a/data/Dockerfiles/sogo/bootstrap-sogo.sh +++ b/data/Dockerfiles/sogo/bootstrap-sogo.sh @@ -18,11 +18,13 @@ done mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "DROP VIEW IF EXISTS sogo_view" mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} << EOF -CREATE VIEW sogo_view (c_uid, domain, c_name, c_password, c_cn, mail, aliases, ad_aliases, home, kind, multiple_bookings) AS -SELECT mailbox.username, mailbox.domain, mailbox.username, mailbox.password, mailbox.name, mailbox.username, IFNULL(ga.aliases, ''), IFNULL(gda.ad_alias, ''), CONCAT('/var/vmail/', maildir), mailbox.kind, mailbox.multiple_bookings FROM mailbox -LEFT OUTER JOIN grouped_mail_aliases ga ON ga.username = mailbox.username +CREATE VIEW sogo_view (c_uid, domain, c_name, c_password, c_cn, mail, aliases, sa_aliases, ad_aliases, home, kind, multiple_bookings) AS +SELECT mailbox.username, mailbox.domain, mailbox.username, mailbox.password, mailbox.name, mailbox.username, IFNULL(GROUP_CONCAT(ga.aliases SEPARATOR ' '), ''), IFNULL(gsa.send_as_acl, ''), IFNULL(gda.ad_alias, ''), CONCAT('/var/vmail/', maildir), mailbox.kind, mailbox.multiple_bookings FROM mailbox +LEFT OUTER JOIN grouped_mail_aliases ga ON ga.username REGEXP CONCAT('(^|,)', mailbox.username, '($|,)') +LEFT OUTER JOIN grouped_sender_acl gsa ON gsa.username = mailbox.username LEFT OUTER JOIN grouped_domain_alias_address gda ON gda.username = mailbox.username -WHERE mailbox.active = '1'; +WHERE mailbox.active = '1' +GROUP BY mailbox.username; EOF @@ -67,6 +69,7 @@ while read line MailFieldNames aliases + sa_aliases ad_aliases KindFieldName diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php index 6c0ef937..4f93a9d0 100644 --- a/data/web/inc/init_db.inc.php +++ b/data/web/inc/init_db.inc.php @@ -3,7 +3,7 @@ function init_db_schema() { try { global $pdo; - $db_version = "02012018_1515"; + $db_version = "21012018_1317"; $stmt = $pdo->query("SHOW TABLES LIKE 'versions'"); $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); @@ -21,13 +21,14 @@ function init_db_schema() { AND active = '1' AND address NOT LIKE '@%' GROUP BY goto;", - "grouped_sender_acl" => "CREATE VIEW grouped_sender_acl (username, send_as) AS - SELECT logged_in_as, IFNULL(GROUP_CONCAT(send_as SEPARATOR ' '), '') AS send_as FROM sender_acl + "grouped_sender_acl" => "CREATE VIEW grouped_sender_acl (username, send_as_acl) AS + SELECT logged_in_as, IFNULL(GROUP_CONCAT(send_as SEPARATOR ' '), '') AS send_as_acl FROM sender_acl WHERE send_as NOT LIKE '@%' GROUP BY logged_in_as;", "grouped_domain_alias_address" => "CREATE VIEW grouped_domain_alias_address (username, ad_alias) AS SELECT username, IFNULL(GROUP_CONCAT(local_part, '@', alias_domain SEPARATOR ' '), '') AS ad_alias FROM mailbox - LEFT OUTER JOIN alias_domain on target_domain=domain GROUP BY username;", + LEFT OUTER JOIN alias_domain ON target_domain=domain + GROUP BY username;", "sieve_before" => "CREATE VIEW sieve_before (id, username, script_name, script_data) AS SELECT md5(script_data), username, script_name, script_data FROM sieve_filters WHERE filter_type = 'prefilter';",