tbrehm
2012-12-04 2052e167f7dc04e37041443f640af4e8c18c3bc0
Fixed: FS#2524 - Add check in remote api that no email alias can be added that exists as mailbox
1 files modified
34 ■■■■ changed files
interface/lib/classes/remoting.inc.php 34 ●●●● patch | view | raw | blame | history
interface/lib/classes/remoting.inc.php
@@ -481,11 +481,21 @@
    //* aliasy email
    public function mail_alias_add($session_id, $client_id, $params)
    {
        global $app;
        if (!$this->checkPerm($session_id, 'mail_alias_add'))
        {
            $this->server->fault('permission_denied','You do not have the permissions to access this function.');
            return false;
        }
        //* Check if there is no active mailbox with this address
        $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'");
        if($tmp['number'] > 0) {
            $this->server->fault('duplicate','There is already a mailbox with this email address.');
        }
        unset($tmp);
        $affected_rows = $this->insertQuery('../mail/form/mail_alias.tform.php', $client_id, $params);
        return $affected_rows;
    }
@@ -493,13 +503,23 @@
    public function mail_alias_update($session_id, $client_id, $primary_id, $params)
    {
            if (!$this->checkPerm($session_id, 'mail_alias_update'))
            {
                    $this->server->fault('permission_denied','You do not have the permissions to access this function.');
                    return false;
            }
            $affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params);
            return $affected_rows;
        global $app;
        if (!$this->checkPerm($session_id, 'mail_alias_update'))
        {
            $this->server->fault('permission_denied','You do not have the permissions to access this function.');
            return false;
        }
            //* Check if there is no active mailbox with this address
        $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'");
        if($tmp['number'] > 0) {
            $this->server->fault('duplicate','There is already a mailbox with this email address.');
        }
        unset($tmp);
        $affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params);
        return $affected_rows;
    }
    public function mail_alias_delete($session_id, $primary_id)