| | |
| | | |
| | | // Get the spamfilter policys for the user |
| | | $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '".$app->db->quote($this->dataRecord["email"])."'"); |
| | | $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r'); |
| | | $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r') . " ORDER BY policy_name"; |
| | | $policys = $app->db->queryAllRecords($sql); |
| | | $policy_select = "<option value='0'>".$app->tform->lng("no_policy")."</option>"; |
| | | if(is_array($policys)) { |
| | |
| | | if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin |
| | | // Get the limits of the client |
| | | $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
| | | $client = $app->db->queryOneRecord("SELECT limit_mailbox, limit_mailquota FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
| | | $client = $app->db->queryOneRecord("SELECT limit_mailbox, limit_mailquota, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
| | | |
| | | |
| | | // Check if the user may add another mailbox. |
| | |
| | | } |
| | | |
| | | // Check the quota and adjust |
| | | if(isset($_POST["quota"]) && $client["limit_mailquota"] >= 0 && $app->functions->intval($this->dataRecord["quota"]) * 1024 * 1024 != $this->oldDataRecord['quota']) { |
| | | if(isset($_POST["quota"]) && $client["limit_mailquota"] >= 0 && (($app->functions->intval($this->dataRecord["quota"]) * 1024 * 1024 != $this->oldDataRecord['quota']) || ($_POST["quota"] <= 0))) { |
| | | $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 = $app->functions->intval($this->dataRecord["quota"]); |
| | |
| | | } |
| | | unset($tmp); |
| | | unset($tmp_quota); |
| | | } |
| | | |
| | | if($client['parent_client_id'] > 0) { |
| | | // Get the limits of the reseller |
| | | $reseller = $app->db->queryOneRecord("SELECT limit_mailquota, limit_maildomain FROM client WHERE client_id = ".$client['parent_client_id']); |
| | | |
| | | //* Check the website quota of the client |
| | | if(isset($_POST["quota"]) && $reseller["limit_mailquota"] >= 0 && $app->functions->intval($this->dataRecord["quota"]) * 1024 * 1024 != $this->oldDataRecord['quota']) { |
| | | $tmp = $app->db->queryOneRecord("SELECT sum(quota) as mailquota FROM mail_user, sys_group, client WHERE mail_user.sys_groupid=sys_group.groupid AND sys_group.client_id=client.client_id AND ".$client['parent_client_id']." IN (client.parent_client_id, client.client_id) AND mailuser_id != ".$app->functions->intval($this->id)); |
| | | |
| | | $mailquota = $tmp["mailquota"] / 1024 / 1024; |
| | | $new_mailbox_quota = $app->functions->intval($this->dataRecord["quota"]); |
| | | if(($mailquota + $new_mailbox_quota > $reseller["limit_mailquota"]) || ($new_mailbox_quota == 0 && $reseller["limit_mailquota"] != -1)) { |
| | | $max_free_quota = $reseller["limit_mailquota"] - $mailquota; |
| | | if($max_free_quota < 0) $max_free_quota = 0; |
| | | $app->tform->errorMessage .= $app->tform->lng("limit_mailquota_txt").": ".$max_free_quota."<br>"; |
| | | // Set the quota field to the max free space |
| | | $this->dataRecord["quota"] = $max_free_quota; |
| | | } |
| | | unset($tmp); |
| | | unset($tmp_quota); |
| | | } |
| | | } |
| | | } // end if user is not admin |
| | | |
| | |
| | | $maildir = str_replace("[localpart]", strtolower($_POST["email_local_part"]), $maildir); |
| | | $this->dataRecord["maildir"] = $maildir; |
| | | $this->dataRecord["homedir"] = $mail_config["homedir_path"]; |
| | | $this->dataRecord["uid"] = $mail_config["mailuser_uid"]; |
| | | $this->dataRecord["gid"] = $mail_config["mailuser_gid"]; |
| | | |
| | | |
| | | // Will be overwritten by mail_plugin |
| | | $this->dataRecord['uid'] = -1; |
| | | $this->dataRecord['gid'] = -1; |
| | | |
| | | //* Check if there is no alias or forward with this address |
| | | $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE active = 'y' AND source = '".$app->db->quote($this->dataRecord["email"])."'"); |
| | | if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("duplicate_alias_or_forward_txt")."<br>"; |
| | |
| | | $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); |
| | |
| | | $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', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver', disablelda = '$disabledeliver', disabledoveadm = '$disableimap' WHERE mailuser_id = ".$this->id; |
| | | $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); |
| | | } |
| | | |
| | |
| | | |
| | | //* Change backup options when user mail backup options have been changed |
| | | if(isset($this->dataRecord['backup_interval']) && ($this->dataRecord['backup_interval'] != $this->oldDataRecord['backup_interval'] || $this->dataRecord['backup_copies'] != $this->oldDataRecord['backup_copies'])) { |
| | | $backup_interval = $this->dataRecord['backup_interval']; |
| | | $backup_copies = $this->dataRecord['backup_copies']; |
| | | $backup_interval = $app->db->quote($this->dataRecord['backup_interval']); |
| | | $backup_copies = $app->functions->intval($this->dataRecord['backup_copies']); |
| | | $app->db->datalogUpdate('mail_user', "backup_interval = '$backup_interval', backup_copies = '$backup_copies'", 'mailuser_id', $rec['mailuser_id']); |
| | | unset($backup_copies); |
| | | unset($backup_interval); |