Skip to content

Commit 44c2dde

Browse files
author
Marius Cramer
committed
Fixed some things in mail user handling
- mail accounts not locked when client locked - mail account sending and receiving lock separated - fixed error in query - fixed wording to match separeted locks
1 parent 5c93f08 commit 44c2dde

File tree

8 files changed

+54
-16
lines changed

8 files changed

+54
-16
lines changed

install/tpl/sasl_smtpd.conf.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ sql_hostnames: {mysql_server_ip}
66
sql_user: {mysql_server_ispconfig_user}
77
sql_passwd: {mysql_server_ispconfig_password}
88
sql_database: {mysql_server_database}
9-
sql_select: select password from mail_user where login = '%u'
9+
sql_select: select password from mail_user where (login = '%u' or email = '%u@%r') and postfix = 'y' and disablesmtp = 'n'

install/tpl/sasl_smtpd2.conf.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ sql_hostnames: {mysql_server_ip}
77
sql_user: {mysql_server_ispconfig_user}
88
sql_passwd: {mysql_server_ispconfig_password}
99
sql_database: {mysql_server_database}
10-
sql_select: select password from mail_user where (login = '%u' or login = '%u@%r') and postfix = 'y'
10+
sql_select: select password from mail_user where (login = '%u' or email = '%u@%r') and postfix = 'y' and disablesmtp = 'n'

interface/web/client/client_edit.php

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ function onAfterUpdate() {
431431
$to_disable = array('cron' => 'id',
432432
'ftp_user' => 'ftp_user_id',
433433
'mail_domain' => 'domain_id',
434+
'mail_user' => 'mailuser_id',
435+
'mail_user_smtp' => 'mailuser_id',
434436
'mail_forwarding' => 'forwarding_id',
435437
'mail_get' => 'mailget_id',
436438
'openvz_vm' => 'vm_id',
@@ -452,17 +454,28 @@ function onAfterUpdate() {
452454
$prev_active = array();
453455
$prev_sysuser = array();
454456
foreach($to_disable as $current => $keycolumn) {
455-
$prev_active[$current] = array();
456-
$prev_sysuser[$current] = array();
457+
$active_col = 'active';
458+
$reverse = false;
459+
if($current == 'mail_user') {
460+
$active_col = 'postfix';
461+
} elseif($current == 'mail_user_smtp') {
462+
$current = 'mail_user';
463+
$active_col = 'disablesmtp';
464+
$reverse = true;
465+
}
466+
467+
if(!isset($prev_active[$current])) $prev_active[$current] = array();
468+
if(!isset($prev_sysuser[$current])) $prev_sysuser[$current] = array();
457469

458-
$entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id`, `sys_userid`, `active` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid);
470+
$entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id`, `sys_userid`, `' . $active_col . '` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid);
459471
foreach($entries as $item) {
460472

461-
if($item['active'] != 'y') $prev_active[$current][$item['id']]['active'] = 'n';
462-
if($item['sys_userid'] != $sys_userid) $prev_sysuser[$current][$item['id']]['active'] = $item['sys_userid'];
473+
if($item[$active_col] != 'y' && $reverse == false) $prev_active[$current][$item['id']][$active_col] = 'n';
474+
elseif($item[$active_col] == 'y' && $reverse == true) $prev_active[$current][$item['id']][$active_col] = 'y';
475+
if($item['sys_userid'] != $sys_userid) $prev_sysuser[$current][$item['id']] = $item['sys_userid'];
463476
// we don't have to store these if y, as everything without previous state gets enabled later
464477

465-
$app->db->datalogUpdate($current, array('active' => 'n', 'sys_userid' => $_SESSION["s"]["user"]["userid"]), $keycolumn, $item['id']);
478+
$app->db->datalogUpdate($current, array($active_col => ($reverse == true ? 'y' : 'n'), 'sys_userid' => $_SESSION["s"]["user"]["userid"]), $keycolumn, $item['id']);
466479
}
467480
}
468481

@@ -473,20 +486,31 @@ function onAfterUpdate() {
473486
unset($prev_sysuser);
474487
} elseif($this->dataRecord['locked'] == 'n') {
475488
foreach($to_disable as $current => $keycolumn) {
489+
$active_col = 'active';
490+
$reverse = false;
491+
if($current == 'mail_user') {
492+
$active_col = 'postfix';
493+
} elseif($current == 'mail_user_smtp') {
494+
$current = 'mail_user';
495+
$active_col = 'disablesmtp';
496+
$reverse = true;
497+
}
498+
476499
$entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid);
477500
foreach($entries as $item) {
478-
$set_active = 'y';
501+
$set_active = ($reverse == true ? 'n' : 'y');
502+
$set_inactive = ($reverse == true ? 'y' : 'n');
479503
$set_sysuser = $sys_userid;
480504
if(array_key_exists('prev_active', $tmp_data) == true
481505
&& array_key_exists($current, $tmp_data['prev_active']) == true
482506
&& array_key_exists($item['id'], $tmp_data['prev_active'][$current]) == true
483-
&& $tmp_data['prev_active'][$current][$item['id']] == 'n') $set_active = 'n';
507+
&& $tmp_data['prev_active'][$current][$item['id']][$active_col] == $set_inactive) $set_active = $set_inactive;
484508
if(array_key_exists('prev_sysuser', $tmp_data) == true
485509
&& array_key_exists($current, $tmp_data['prev_sysuser']) == true
486510
&& array_key_exists($item['id'], $tmp_data['prev_sysuser'][$current]) == true
487511
&& $tmp_data['prev_sysuser'][$current][$item['id']] != $sys_userid) $set_sysuser = $tmp_data['prev_sysuser'][$current][$item['id']];
488512

489-
$app->db->datalogUpdate($current, array('active' => $set_active, 'sys_userid' => $set_sysuser), $keycolumn, $item['id']);
513+
$app->db->datalogUpdate($current, array($active_col => $set_active, 'sys_userid' => $set_sysuser), $keycolumn, $item['id']);
490514
}
491515
}
492516
if(array_key_exists('prev_active', $tmp_data)) unset($tmp_data['prev_active']);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@
222222
'value' => array(1 => 'y',0 => 'n')
223223
),
224224
*/
225+
'disablesmtp' => array (
226+
'datatype' => 'VARCHAR',
227+
'formtype' => 'CHECKBOX',
228+
'default' => 'n',
229+
'value' => array(1 => 'y', 0 => 'n')
230+
),
225231
'disableimap' => array (
226232
'datatype' => 'VARCHAR',
227233
'formtype' => 'CHECKBOX',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ $wb['quota_txt'] = 'Beschränkung';
1616
$wb['server_id_txt'] = 'Server ID';
1717
$wb['password_txt'] = 'Passwort';
1818
$wb['maildir_txt'] = 'E-Mail Verzeichnis';
19-
$wb['postfix_txt'] = 'Aktiviere SMTP (in/out)';
19+
$wb['postfix_txt'] = 'Aktiviere Empfang';
2020
$wb['access_txt'] = 'Aktiviere Zugriff';
2121
$wb['policy_txt'] = 'Spamfilter';
2222
$wb['no_policy'] = '- nicht aktiviert -';
2323
$wb['limit_mailbox_txt'] = 'Die maximale Anzahl an E-Mailkonten für Ihr Konto wurde erreicht.';
2424
$wb['limit_mailquota_txt'] = 'Der maximale Speicherplatz für Ihr E-Mail Konto wurde erreicht. Der maximal verfügbare Speicher in MB ist';
25+
$wb["disablesmtp_txt"] = 'SMTP (Mailversand) deaktivieren';
2526
$wb['disableimap_txt'] = 'IMAP deaktivieren';
2627
$wb['disablepop3_txt'] = 'POP3 deaktivieren';
2728
$wb['password_strength_txt'] = 'Passwortkomplexität';

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ $wb["quota_txt"] = 'Quota (0 for unlimited)';
2121
$wb["server_id_txt"] = 'Aerver_id';
2222
$wb["password_txt"] = 'Password';
2323
$wb["maildir_txt"] = 'Maildir';
24-
$wb["postfix_txt"] = 'Enable SMTP (in/out)';
25-
$wb["access_txt"] = 'Enable Access';
24+
$wb["postfix_txt"] = 'Enable receiving';
25+
$wb["access_txt"] = 'Enable access';
2626
$wb["policy_txt"] = 'Spamfilter';
2727
$wb["no_policy"] = '- not enabled -';
2828
$wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.';
2929
$wb["limit_mailquota_txt"] = 'The max space for mailboxes is reached. The max. available space in MB is';
30+
$wb["disablesmtp_txt"] = 'Disable SMTP (sending)';
3031
$wb["disableimap_txt"] = 'Disable IMAP';
3132
$wb["disablepop3_txt"] = 'Disable POP3';
3233
$wb["duplicate_alias_or_forward_txt"] = 'There is already an alias or forward with this email address.';

interface/web/mail/mail_user_edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function onAfterInsert() {
257257
$disableimap = ($this->dataRecord["disableimap"])?'y':'n';
258258
$disablepop3 = ($this->dataRecord["disablepop3"])?'y':'n';
259259
$disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y';
260-
$disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y';
260+
$disablesmtp = ($this->dataRecord["disablesmtp"])?'y':'n';
261261

262262
$sql = "UPDATE mail_user SET disableimap = '$disableimap', disablesieve = '$disableimap', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver', disablelda = '$disabledeliver', disabledoveadm = '$disableimap' WHERE mailuser_id = ".$this->id;
263263
$app->db->query($sql);
@@ -298,7 +298,7 @@ function onAfterUpdate() {
298298
$disableimap = (isset($this->dataRecord["disableimap"]) && $this->dataRecord["disableimap"])?'y':'n';
299299
$disablepop3 = (isset($this->dataRecord["disablepop3"]) && $this->dataRecord["disablepop3"])?'y':'n';
300300
$disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y';
301-
$disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y';
301+
$disablesmtp = (isset($this->dataRecord["disablesmtp"]) && $this->dataRecord["disablesmtp"])?'y':'n';
302302

303303
$sql = "UPDATE mail_user SET disableimap = '$disableimap', disablesieve = '$disableimap', `disablesieve-filter` = '$disableimap', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver', disablelda = '$disabledeliver', disabledoveadm = '$disableimap' WHERE mailuser_id = ".$this->id;
304304
$app->db->query($sql);

interface/web/mail/templates/mail_user_mailbox_edit.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
5656
{tmpl_var name='postfix'}
5757
</div>
5858
</div>
59+
<div class="ctrlHolder">
60+
<p class="label">{tmpl_var name='disablesmtp_txt'}</p>
61+
<div class="multiField">
62+
{tmpl_var name='disablesmtp'}
63+
</div>
64+
</div>
5965
<div class="ctrlHolder">
6066
<p class="label">{tmpl_var name='disableimap_txt'}</p>
6167
<div class="multiField">

0 commit comments

Comments
 (0)