| | |
| | | $email = $this->dataRecord["email"]; |
| | | $email_parts = explode("@",$email); |
| | | $app->tpl->setVar("email_local_part",$email_parts[0]); |
| | | |
| | | $email_parts[1] = $app->functions->idn_decode($email_parts[1]); |
| | | |
| | | // Getting Domains of the user |
| | | // $sql = "SELECT domain, server_id FROM mail_domain WHERE ".$app->tform->getAuthSQL('r').' ORDER BY domain'; |
| | | $sql = "SELECT domain, server_id FROM mail_domain WHERE domain NOT IN (SELECT SUBSTR(source,2) FROM mail_forwarding WHERE type = 'aliasdomain') AND ".$app->tform->getAuthSQL('r')." ORDER BY domain"; |
| | |
| | | $domain_select = ''; |
| | | if(is_array($domains)) { |
| | | foreach( $domains as $domain) { |
| | | $domain['domain'] = $app->functions->idn_decode($domain['domain']); |
| | | $selected = ($domain["domain"] == @$email_parts[1])?'SELECTED':''; |
| | | $domain_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n"; |
| | | } |
| | |
| | | |
| | | //* Check if Domain belongs to user |
| | | if(isset($_POST["email_domain"])) { |
| | | $domain = $app->db->queryOneRecord("SELECT server_id, domain FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r')); |
| | | if($domain["domain"] != $_POST["email_domain"]) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm"); |
| | | $domain = $app->db->queryOneRecord("SELECT server_id, domain FROM mail_domain WHERE domain = '".$app->db->quote($app->functions->idn_encode($_POST["email_domain"]))."' AND ".$app->tform->getAuthSQL('r')); |
| | | if($domain["domain"] != $app->functions->idn_encode($_POST["email_domain"])) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm"); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // Check the quota and adjust |
| | | if(isset($_POST["quota"]) && $client["limit_mailquota"] >= 0) { |
| | | $tmp = $app->db->queryOneRecord("SELECT sum(quota) as mailquota FROM mail_user WHERE mailuser_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u')); |
| | | $tmp = $app->db->queryOneRecord("SELECT sum(quota) as mailquota FROM mail_user WHERE mailuser_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u')); |
| | | $mailquota = $tmp["mailquota"] / 1024 / 1024; |
| | | $new_mailbox_quota = intval($this->dataRecord["quota"]); |
| | | $new_mailbox_quota = $app->functions->intval($this->dataRecord["quota"]); |
| | | if(($mailquota + $new_mailbox_quota > $client["limit_mailquota"]) || ($new_mailbox_quota == 0 && $client["limit_mailquota"] != -1)) { |
| | | $max_free_quota = $client["limit_mailquota"] - $mailquota; |
| | | $app->tform->errorMessage .= $app->tform->lng("limit_mailquota_txt").": ".$max_free_quota."<br>"; |
| | |
| | | |
| | | //* compose the email field |
| | | if(isset($_POST["email_local_part"]) && isset($_POST["email_domain"])) { |
| | | $this->dataRecord["email"] = strtolower($_POST["email_local_part"]."@".$_POST["email_domain"]); |
| | | $this->dataRecord["email"] = strtolower($_POST["email_local_part"]."@".$app->functions->idn_encode($_POST["email_domain"])); |
| | | |
| | | // Set the server id of the mailbox = server ID of mail domain. |
| | | $this->dataRecord["server_id"] = $domain["server_id"]; |
| | |
| | | |
| | | $sys_config = $app->getconf->get_global_config('mail'); |
| | | if($sys_config["enable_custom_login"] == "y") { |
| | | if(!isset($_POST["login"])) $this->dataRecord["login"] = $this->dataRecord["email"]; |
| | | if(!isset($_POST["login"]) || $_POST["login"] == '') $this->dataRecord["login"] = $this->dataRecord["email"]; |
| | | elseif(strpos($_POST["login"], '@') !== false && $_POST["login"] != $this->dataRecord["email"]) $app->tform->errorMessage .= $app->tform->lng("error_login_email_txt")."<br>"; |
| | | } else { |
| | | $this->dataRecord["login"] = isset($this->dataRecord["email"]) ? $this->dataRecord["email"] : ''; |
| | |
| | | global $app, $conf; |
| | | |
| | | // Set the domain owner as mailbox owner |
| | | $domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r')); |
| | | $domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($app->functions->idn_encode($_POST["email_domain"]))."' AND ".$app->tform->getAuthSQL('r')); |
| | | $app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id); |
| | | |
| | | // Spamfilter policy |
| | | $policy_id = intval($this->dataRecord["policy"]); |
| | | $policy_id = $app->functions->intval($this->dataRecord["policy"]); |
| | | if($policy_id > 0) { |
| | | $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".$app->db->quote($this->dataRecord["email"])."'"); |
| | | if($tmp_user["id"] > 0) { |
| | |
| | | $disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y'; |
| | | $disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y'; |
| | | |
| | | $sql = "UPDATE mail_user SET disableimap = '$disableimap', disablesieve = '$disableimap', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver', disablelda = '$disabledeliver' WHERE mailuser_id = ".$this->id; |
| | | $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); |
| | | } |
| | | } |
| | |
| | | |
| | | // Set the domain owner as mailbox owner |
| | | if(isset($_POST["email_domain"])) { |
| | | $domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r')); |
| | | $domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($app->functions->idn_encode($_POST["email_domain"]))."' AND ".$app->tform->getAuthSQL('r')); |
| | | $app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id); |
| | | |
| | | // Spamfilter policy |
| | | $policy_id = intval($this->dataRecord["policy"]); |
| | | $policy_id = $app->functions->intval($this->dataRecord["policy"]); |
| | | $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".$app->db->quote($this->dataRecord["email"])."'"); |
| | | if($policy_id > 0) { |
| | | if($tmp_user["id"] > 0) { |
| | |
| | | $disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y'; |
| | | $disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y'; |
| | | |
| | | $sql = "UPDATE mail_user SET disableimap = '$disableimap', disablesieve = '$disableimap', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver', disablelda = '$disabledeliver' WHERE mailuser_id = ".$this->id; |
| | | $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); |
| | | } |
| | | |