| | |
| | | unset($tmp); |
| | | |
| | | // Fill the client select field |
| | | $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY sys_group.name"; |
| | | $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$app->functions->intval($client['client_id'])." ORDER BY sys_group.name"; |
| | | $clients = $app->db->queryAllRecords($sql); |
| | | $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']); |
| | | $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client['client_id'])); |
| | | $client_select = '<option value="'.$tmp['groupid'].'">'.$client['contactname'].'</option>'; |
| | | //$tmp_data_record = $app->tform->getDataRecord($this->id); |
| | | if(is_array($clients)) { |
| | |
| | | } |
| | | } |
| | | $app->tpl->setVar("client_group_id", $client_select); |
| | | |
| | | } |
| | | |
| | | if($_SESSION["s"]["user"]["typ"] != 'admin') |
| | | { |
| | | $client_group_id = $_SESSION["s"]["user"]["default_group"]; |
| | | $client_mail = $app->db->queryOneRecord("SELECT mail_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
| | | |
| | | $client_mail['mail_servers_ids'] = explode(',', $client_mail['mail_servers']); |
| | | |
| | | $only_one_server = count($client_mail['mail_servers_ids']) === 1; |
| | | $app->tpl->setVar('only_one_server', $only_one_server); |
| | | |
| | | if ($only_one_server) { |
| | | $app->tpl->setVar('server_id_value', $client_mail['mail_servers_ids'][0]); |
| | | } |
| | | |
| | | $sql = "SELECT server_id, server_name FROM server WHERE server_id IN (" . $client_mail['mail_servers'] . ");"; |
| | | $mail_servers = $app->db->queryAllRecords($sql); |
| | | |
| | | $options_mail_servers = ""; |
| | | |
| | | foreach ($mail_servers as $mail_server) { |
| | | $options_mail_servers .= "<option value='$mail_server[server_id]'>$mail_server[server_name]</option>"; |
| | | } |
| | | |
| | | $app->tpl->setVar("client_server_id", $options_mail_servers); |
| | | unset($options_mail_servers); |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | // Get the spamfilter policys for the user |
| | | $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '@".$this->dataRecord["domain"]."'"); |
| | | $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '@".$app->db->quote($this->dataRecord["domain"])."'"); |
| | | $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r'); |
| | | $policys = $app->db->queryAllRecords($sql); |
| | | $policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>"; |
| | |
| | | } |
| | | |
| | | if($_SESSION["s"]["user"]["typ"] != 'admin') { |
| | | |
| | | // Get the limits of the client |
| | | $client_group_id = $_SESSION["s"]["user"]["default_group"]; |
| | | $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
| | | $client = $app->db->queryOneRecord("SELECT limit_maildomain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
| | | |
| | | // When the record is updated |
| | | if($this->id > 0) { |
| | | // restore the server ID if the user is not admin and record is edited |
| | |
| | | unset($tmp); |
| | | // When the record is inserted |
| | | } else { |
| | | // set the server ID to the default mailserver of the client |
| | | $this->dataRecord["server_id"] = $client["default_mailserver"]; |
| | | $client['mail_servers_ids'] = explode(',', $client['mail_servers']); |
| | | |
| | | // Check if the user may add another mail_domain |
| | | // Check if chosen server is in authorized servers for this client |
| | | if (!(is_array($client['mail_servers_ids']) && in_array($this->dataRecord["server_id"], $client['mail_servers_ids']))) { |
| | | $app->error($app->tform->wordbook['error_not_allowed_server_id']); |
| | | } |
| | | |
| | | if($client["limit_maildomain"] >= 0) { |
| | | $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE sys_groupid = $client_group_id"); |
| | | if($tmp["number"] >= $client["limit_maildomain"]) { |
| | |
| | | $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id); |
| | | // We create a new record |
| | | $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) |
| | | VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".$app->db->quote($this->dataRecord["domain"])."', '@".$app->db->quote($this->dataRecord["domain"])."', 'Y')"; |
| | | VALUES (".$_SESSION["s"]["user"]["userid"].", ".$app->functions->intval($tmp_domain["sys_groupid"]).", 'riud', 'riud', '', ".$app->functions->intval($this->dataRecord["server_id"]).", 5, ".$app->functions->intval($policy_id).", '@".$app->db->quote($this->dataRecord["domain"])."', '@".$app->db->quote($this->dataRecord["domain"])."', 'Y')"; |
| | | $app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); |
| | | unset($tmp_domain); |
| | | } |
| | |
| | | $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id); |
| | | // We create a new record |
| | | $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) |
| | | VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".$app->db->quote($this->dataRecord["domain"])."', '@".$app->db->quote($this->dataRecord["domain"])."', 'Y')"; |
| | | VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$app->functions->intval($this->dataRecord["server_id"]).", 5, ".$app->functions->intval($policy_id).", '@".$app->db->quote($this->dataRecord["domain"])."', '@".$app->db->quote($this->dataRecord["domain"])."', 'Y')"; |
| | | $app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); |
| | | unset($tmp_domain); |
| | | } |
| | |
| | | |
| | | //* Update the mailboxes |
| | | $mailusers = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE email like '%@".$app->db->quote($this->oldDataRecord['domain'])."'"); |
| | | $sys_groupid = (isset($this->dataRecord['client_group_id']))?$this->dataRecord['client_group_id']:$this->oldDataRecord['sys_groupid']; |
| | | $sys_groupid = $app->functions->intval((isset($this->dataRecord['client_group_id']))?$this->dataRecord['client_group_id']:$this->oldDataRecord['sys_groupid']); |
| | | $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id"); |
| | | $client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1; |
| | | $client_user_id = $app->functions->intval(($tmp['userid'] > 0)?$tmp['userid']:1); |
| | | if(is_array($mailusers)) { |
| | | foreach($mailusers as $rec) { |
| | | // setting Maildir, Homedir, UID and GID |