Skip to content

Commit d5380a3

Browse files
author
Till Brehm
committed
Merge branch '5918-custom-imap-prefix-by-mailbox' into 'develop'
Support configurable IMAP prefix per mailbox Closes #5918 See merge request ispconfig/ispconfig3!1605
2 parents e16edeb + bfd8893 commit d5380a3

34 files changed

+106
-17
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
21
ALTER TABLE `mail_user` CHANGE `quota` `quota` BIGINT(20) NOT NULL DEFAULT '0';
2+
-- 5918 add imap_prefix column to mail_user table
3+
ALTER TABLE `mail_user` ADD COLUMN `imap_prefix` varchar(255) NULL default NULL AFTER `backup_copies`;
4+

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ CREATE TABLE `mail_user` (
11011101
`last_quota_notification` date NULL default NULL,
11021102
`backup_interval` VARCHAR( 255 ) NOT NULL default 'none',
11031103
`backup_copies` INT NOT NULL DEFAULT '1',
1104+
`imap_prefix` varchar(255) NULL default NULL,
11041105
PRIMARY KEY (`mailuser_id`),
11051106
KEY `server_id` (`server_id`,`email`),
11061107
KEY `email_access` (`email`,`access`)

install/tpl/debian6_dovecot-sql.conf.master

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
55
default_pass_scheme = CRYPT
66

77
# password-query with prefetch
8-
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
8+
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve, NULLIF(imap_prefix, '') as "userdb_namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
99

10-
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
10+
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve, NULLIF(imap_prefix, '') as "namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
1111

1212
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
1313
# Do not enable it on Dovecot 1.x servers

install/tpl/debian_dovecot-sql.conf.master

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
55
default_pass_scheme = CRYPT
66

77
# password-query with prefetch
8-
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
8+
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve, NULLIF(imap_prefix, '') as "userdb_namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
99

10-
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
10+
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve, NULLIF(imap_prefix, '') as "namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
1111

1212
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
1313
# Do not enable it on Dovecot 1.x servers

install/tpl/fedora_dovecot-sql.conf.master

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
55
default_pass_scheme = CRYPT
66

77
# password-query with prefetch
8-
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
8+
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve, NULLIF(imap_prefix, '') as "userdb_namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
99

10-
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
10+
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve, NULLIF(imap_prefix, '') as "namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
1111

1212
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
1313
# Do not enable it on Dovecot 1.x servers

install/tpl/opensuse_dovecot-sql.conf.master

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
55
default_pass_scheme = CRYPT
66

77
# password-query with prefetch
8-
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
8+
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve, NULLIF(imap_prefix, '') as "userdb_namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' AND NOT EXISTS (SELECT domain_id FROM mail_domain WHERE domain = '%d' AND active = 'n' AND server_id = {server_id})
99

10-
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
10+
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve, NULLIF(imap_prefix, '') as "namespace/inbox/prefix" FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
1111

1212
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
1313
# Do not enable it on Dovecot 1.x servers

interface/web/mail/form/mail_user.tform.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,29 @@
216216
'maxlength' => '255',
217217
'searchable' => 2
218218
),
219+
)
220+
);
221+
222+
if($app->auth->is_admin()) {
223+
$form["tabs"]['mailuser']['fields'] += array(
224+
'imap_prefix' => array (
225+
'datatype' => 'VARCHAR',
226+
'formtype' => 'TEXT',
227+
'filters' => array(
228+
0 => array( 'event' => 'SAVE',
229+
'type' => 'STRIPTAGS'),
230+
1 => array( 'event' => 'SAVE',
231+
'type' => 'STRIPNL')
232+
),
233+
'default' => '',
234+
'value' => '',
235+
'width' => '30',
236+
'maxlength' => '255',
237+
),
238+
);
239+
}
240+
241+
$form["tabs"]['mailuser']['fields'] += array(
219242
'maildir' => array (
220243
'datatype' => 'VARCHAR',
221244
'formtype' => 'TEXT',
@@ -321,7 +344,6 @@
321344
//#################################
322345
// END Datatable fields
323346
//#################################
324-
)
325347
);
326348

327349
if($global_config['mail']['mail_password_onlyascii'] == 'y') {

interface/web/mail/lib/lang/ar_mail_user.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,6 @@ $wb['purge_trash_days_txt'] = 'Purge Trash automatically after X days';
7575
$wb['tooltip_purge_trash_days_txt'] = '0 = disabled';
7676
$wb['purge_junk_days_txt'] = 'Purge Junk automatically after X days';
7777
$wb['tooltip_purge_junk_days_txt'] = '0 = disabled';
78+
$wb['imap_prefix_txt'] = 'IMAP prefix';
79+
$wb['tooltip_imap_prefix_txt'] = 'In most cases this should be left empty. To allow seamless per-mailbox migration of legacy systems you can specify a prefix followed by the hierarchy separator. e.g.: \'INBOX.\'';
7880
?>

interface/web/mail/lib/lang/bg_mail_user.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,6 @@ $wb['purge_trash_days_txt'] = 'Purge Trash automatically after X days';
7575
$wb['tooltip_purge_trash_days_txt'] = '0 = disabled';
7676
$wb['purge_junk_days_txt'] = 'Purge Junk automatically after X days';
7777
$wb['tooltip_purge_junk_days_txt'] = '0 = disabled';
78+
$wb['imap_prefix_txt'] = 'IMAP prefix';
79+
$wb['tooltip_imap_prefix_txt'] = 'In most cases this should be left empty. To allow seamless per-mailbox migration of legacy systems you can specify a prefix followed by the hierarchy separator. e.g.: \'INBOX.\'';
7880
?>

interface/web/mail/lib/lang/ca_mail_user.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,6 @@ $wb['purge_trash_days_txt'] = 'Purge Trash automatically after X days';
7474
$wb['tooltip_purge_trash_days_txt'] = '0 = disabled';
7575
$wb['purge_junk_days_txt'] = 'Purge Junk automatically after X days';
7676
$wb['tooltip_purge_junk_days_txt'] = '0 = disabled';
77+
$wb['imap_prefix_txt'] = 'IMAP prefix';
78+
$wb['tooltip_imap_prefix_txt'] = 'In most cases this should be left empty. To allow seamless per-mailbox migration of legacy systems you can specify a prefix followed by the hierarchy separator. e.g.: \'INBOX.\'';
7779
?>

0 commit comments

Comments
 (0)