Marius Cramer
2014-04-02 44c2ddee5f0069e821350b6a26bee1dd9330195a
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
8 files modified
70 ■■■■ changed files
install/tpl/sasl_smtpd.conf.master 2 ●●● patch | view | raw | blame | history
install/tpl/sasl_smtpd2.conf.master 2 ●●● patch | view | raw | blame | history
interface/web/client/client_edit.php 42 ●●●● patch | view | raw | blame | history
interface/web/mail/form/mail_user.tform.php 6 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/de_mail_user.lng 3 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_user.lng 5 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_user_edit.php 4 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_user_mailbox_edit.htm 6 ●●●●● patch | view | raw | blame | history
install/tpl/sasl_smtpd.conf.master
@@ -6,4 +6,4 @@
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'
install/tpl/sasl_smtpd2.conf.master
@@ -7,4 +7,4 @@
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'
interface/web/client/client_edit.php
@@ -431,6 +431,8 @@
            $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 @@
                $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 @@
                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']);
interface/web/mail/form/mail_user.tform.php
@@ -222,6 +222,12 @@
            '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',
interface/web/mail/lib/lang/de_mail_user.lng
@@ -16,12 +16,13 @@
$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';
interface/web/mail/lib/lang/en_mail_user.lng
@@ -21,12 +21,13 @@
$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.';
interface/web/mail/mail_user_edit.php
@@ -257,7 +257,7 @@
            $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 @@
            $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);
interface/web/mail/templates/mail_user_mailbox_edit.htm
@@ -57,6 +57,12 @@
                </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">
                    {tmpl_var name='disableimap'}