Commit 44c2ddee authored by Marius Cramer's avatar Marius Cramer

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
parent 5c93f084
......@@ -6,4 +6,4 @@ sql_hostnames: {mysql_server_ip}
sql_user: {mysql_server_ispconfig_user}
sql_passwd: {mysql_server_ispconfig_password}
sql_database: {mysql_server_database}
sql_select: select password from mail_user where login = '%u'
sql_select: select password from mail_user where (login = '%u' or email = '%u@%r') and postfix = 'y' and disablesmtp = 'n'
\ No newline at end of file
......@@ -7,4 +7,4 @@ sql_hostnames: {mysql_server_ip}
sql_user: {mysql_server_ispconfig_user}
sql_passwd: {mysql_server_ispconfig_password}
sql_database: {mysql_server_database}
sql_select: select password from mail_user where (login = '%u' or login = '%u@%r') and postfix = 'y'
sql_select: select password from mail_user where (login = '%u' or email = '%u@%r') and postfix = 'y' and disablesmtp = 'n'
......@@ -431,6 +431,8 @@ class page_action extends tform_actions {
$to_disable = array('cron' => 'id',
'ftp_user' => 'ftp_user_id',
'mail_domain' => 'domain_id',
'mail_user' => 'mailuser_id',
'mail_user_smtp' => 'mailuser_id',
'mail_forwarding' => 'forwarding_id',
'mail_get' => 'mailget_id',
'openvz_vm' => 'vm_id',
......@@ -452,17 +454,28 @@ class page_action extends tform_actions {
$prev_active = array();
$prev_sysuser = array();
foreach($to_disable as $current => $keycolumn) {
$prev_active[$current] = array();
$prev_sysuser[$current] = array();
$active_col = 'active';
$reverse = false;
if($current == 'mail_user') {
$active_col = 'postfix';
} elseif($current == 'mail_user_smtp') {
$current = 'mail_user';
$active_col = 'disablesmtp';
$reverse = true;
}
if(!isset($prev_active[$current])) $prev_active[$current] = array();
if(!isset($prev_sysuser[$current])) $prev_sysuser[$current] = array();
$entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id`, `sys_userid`, `active` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid);
$entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id`, `sys_userid`, `' . $active_col . '` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid);
foreach($entries as $item) {
if($item['active'] != 'y') $prev_active[$current][$item['id']]['active'] = 'n';
if($item['sys_userid'] != $sys_userid) $prev_sysuser[$current][$item['id']]['active'] = $item['sys_userid'];
if($item[$active_col] != 'y' && $reverse == false) $prev_active[$current][$item['id']][$active_col] = 'n';
elseif($item[$active_col] == 'y' && $reverse == true) $prev_active[$current][$item['id']][$active_col] = 'y';
if($item['sys_userid'] != $sys_userid) $prev_sysuser[$current][$item['id']] = $item['sys_userid'];
// we don't have to store these if y, as everything without previous state gets enabled later
$app->db->datalogUpdate($current, array('active' => 'n', 'sys_userid' => $_SESSION["s"]["user"]["userid"]), $keycolumn, $item['id']);
$app->db->datalogUpdate($current, array($active_col => ($reverse == true ? 'y' : 'n'), 'sys_userid' => $_SESSION["s"]["user"]["userid"]), $keycolumn, $item['id']);
}
}
......@@ -473,20 +486,31 @@ class page_action extends tform_actions {
unset($prev_sysuser);
} elseif($this->dataRecord['locked'] == 'n') {
foreach($to_disable as $current => $keycolumn) {
$active_col = 'active';
$reverse = false;
if($current == 'mail_user') {
$active_col = 'postfix';
} elseif($current == 'mail_user_smtp') {
$current = 'mail_user';
$active_col = 'disablesmtp';
$reverse = true;
}
$entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid);
foreach($entries as $item) {
$set_active = 'y';
$set_active = ($reverse == true ? 'n' : 'y');
$set_inactive = ($reverse == true ? 'y' : 'n');
$set_sysuser = $sys_userid;
if(array_key_exists('prev_active', $tmp_data) == true
&& array_key_exists($current, $tmp_data['prev_active']) == true
&& array_key_exists($item['id'], $tmp_data['prev_active'][$current]) == true
&& $tmp_data['prev_active'][$current][$item['id']] == 'n') $set_active = 'n';
&& $tmp_data['prev_active'][$current][$item['id']][$active_col] == $set_inactive) $set_active = $set_inactive;
if(array_key_exists('prev_sysuser', $tmp_data) == true
&& array_key_exists($current, $tmp_data['prev_sysuser']) == true
&& array_key_exists($item['id'], $tmp_data['prev_sysuser'][$current]) == true
&& $tmp_data['prev_sysuser'][$current][$item['id']] != $sys_userid) $set_sysuser = $tmp_data['prev_sysuser'][$current][$item['id']];
$app->db->datalogUpdate($current, array('active' => $set_active, 'sys_userid' => $set_sysuser), $keycolumn, $item['id']);
$app->db->datalogUpdate($current, array($active_col => $set_active, 'sys_userid' => $set_sysuser), $keycolumn, $item['id']);
}
}
if(array_key_exists('prev_active', $tmp_data)) unset($tmp_data['prev_active']);
......
......@@ -222,6 +222,12 @@ $form["tabs"]['mailuser'] = array(
'value' => array(1 => 'y',0 => 'n')
),
*/
'disablesmtp' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'value' => array(1 => 'y', 0 => 'n')
),
'disableimap' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
......
......@@ -16,12 +16,13 @@ $wb['quota_txt'] = 'Beschränkung';
$wb['server_id_txt'] = 'Server ID';
$wb['password_txt'] = 'Passwort';
$wb['maildir_txt'] = 'E-Mail Verzeichnis';
$wb['postfix_txt'] = 'Aktiviere SMTP (in/out)';
$wb['postfix_txt'] = 'Aktiviere Empfang';
$wb['access_txt'] = 'Aktiviere Zugriff';
$wb['policy_txt'] = 'Spamfilter';
$wb['no_policy'] = '- nicht aktiviert -';
$wb['limit_mailbox_txt'] = 'Die maximale Anzahl an E-Mailkonten für Ihr Konto wurde erreicht.';
$wb['limit_mailquota_txt'] = 'Der maximale Speicherplatz für Ihr E-Mail Konto wurde erreicht. Der maximal verfügbare Speicher in MB ist';
$wb["disablesmtp_txt"] = 'SMTP (Mailversand) deaktivieren';
$wb['disableimap_txt'] = 'IMAP deaktivieren';
$wb['disablepop3_txt'] = 'POP3 deaktivieren';
$wb['password_strength_txt'] = 'Passwortkomplexität';
......
......@@ -21,12 +21,13 @@ $wb["quota_txt"] = 'Quota (0 for unlimited)';
$wb["server_id_txt"] = 'Aerver_id';
$wb["password_txt"] = 'Password';
$wb["maildir_txt"] = 'Maildir';
$wb["postfix_txt"] = 'Enable SMTP (in/out)';
$wb["access_txt"] = 'Enable Access';
$wb["postfix_txt"] = 'Enable receiving';
$wb["access_txt"] = 'Enable access';
$wb["policy_txt"] = 'Spamfilter';
$wb["no_policy"] = '- not enabled -';
$wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.';
$wb["limit_mailquota_txt"] = 'The max space for mailboxes is reached. The max. available space in MB is';
$wb["disablesmtp_txt"] = 'Disable SMTP (sending)';
$wb["disableimap_txt"] = 'Disable IMAP';
$wb["disablepop3_txt"] = 'Disable POP3';
$wb["duplicate_alias_or_forward_txt"] = 'There is already an alias or forward with this email address.';
......
......@@ -257,7 +257,7 @@ class page_action extends tform_actions {
$disableimap = ($this->dataRecord["disableimap"])?'y':'n';
$disablepop3 = ($this->dataRecord["disablepop3"])?'y':'n';
$disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$disablesmtp = ($this->dataRecord["disablesmtp"])?'y':'n';
$sql = "UPDATE mail_user SET disableimap = '$disableimap', disablesieve = '$disableimap', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver', disablelda = '$disabledeliver', disabledoveadm = '$disableimap' WHERE mailuser_id = ".$this->id;
$app->db->query($sql);
......@@ -298,7 +298,7 @@ class page_action extends tform_actions {
$disableimap = (isset($this->dataRecord["disableimap"]) && $this->dataRecord["disableimap"])?'y':'n';
$disablepop3 = (isset($this->dataRecord["disablepop3"]) && $this->dataRecord["disablepop3"])?'y':'n';
$disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$disablesmtp = (isset($this->dataRecord["disablesmtp"]) && $this->dataRecord["disablesmtp"])?'y':'n';
$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;
$app->db->query($sql);
......
......@@ -56,6 +56,12 @@
{tmpl_var name='postfix'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='disablesmtp_txt'}</p>
<div class="multiField">
{tmpl_var name='disablesmtp'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='disableimap_txt'}</p>
<div class="multiField">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment