|
71 | 71 | unset($n); |
72 | 72 | $app->tpl->setVar("template_id_option", $template_id_option); |
73 | 73 |
|
| 74 | +$app->uses('ini_parser,getconf'); |
| 75 | +$domains_settings = $app->getconf->get_global_config('domains'); |
| 76 | + |
74 | 77 | // If the user is administrator |
75 | 78 | if($_SESSION['s']['user']['typ'] == 'admin') { |
76 | 79 |
|
|
83 | 86 | } |
84 | 87 | $app->tpl->setVar("server_id", $server_id_option); |
85 | 88 |
|
86 | | - // load the list of clients |
87 | | - $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 sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; |
88 | | - $clients = $app->db->queryAllRecords($sql); |
89 | | - $client_select = ''; |
90 | | - if($_SESSION["s"]["user"]["typ"] == 'admin') $client_select .= "<option value='0'></option>"; |
91 | | - if(is_array($clients)) { |
92 | | - foreach( $clients as $client) { |
93 | | - $selected = ($client["groupid"] == $sys_groupid)?'SELECTED':''; |
94 | | - $client_select .= "<option value='$client[groupid]' $selected>$client[contactname]</option>\r\n"; |
| 89 | + if ($domains_settings['use_domain_module'] != 'y') { |
| 90 | + // load the list of clients |
| 91 | + $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 sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; |
| 92 | + $clients = $app->db->queryAllRecords($sql); |
| 93 | + $client_select = ''; |
| 94 | + if($_SESSION["s"]["user"]["typ"] == 'admin') $client_select .= "<option value='0'></option>"; |
| 95 | + if(is_array($clients)) { |
| 96 | + foreach( $clients as $client) { |
| 97 | + $selected = ($client["groupid"] == $sys_groupid)?'SELECTED':''; |
| 98 | + $client_select .= "<option value='$client[groupid]' $selected>$client[contactname]</option>\r\n"; |
| 99 | + } |
95 | 100 | } |
96 | | - } |
97 | 101 |
|
98 | | - $app->tpl->setVar("client_group_id", $client_select); |
| 102 | + $app->tpl->setVar("client_group_id", $client_select); |
| 103 | + } |
99 | 104 | } |
100 | 105 |
|
101 | 106 | if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
|
105 | 110 | $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_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, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); |
106 | 111 |
|
107 | 112 |
|
108 | | - // load the list of clients |
109 | | - $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 client.company_name, client.contact_name, sys_group.name"; |
110 | | - $clients = $app->db->queryAllRecords($sql); |
111 | | - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client['client_id'])); |
112 | | - $client_select = '<option value="'.$tmp['groupid'].'">'.$client['contactname'].'</option>'; |
113 | | - if(is_array($clients)) { |
114 | | - foreach( $clients as $client) { |
115 | | - $selected = ($client["groupid"] == $sys_groupid)?'SELECTED':''; |
116 | | - $client_select .= "<option value='$client[groupid]' $selected>$client[contactname]</option>\r\n"; |
| 113 | + if ($domains_settings['use_domain_module'] != 'y') { |
| 114 | + // load the list of clients |
| 115 | + $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 client.company_name, client.contact_name, sys_group.name"; |
| 116 | + $clients = $app->db->queryAllRecords($sql); |
| 117 | + $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client['client_id'])); |
| 118 | + $client_select = '<option value="'.$tmp['groupid'].'">'.$client['contactname'].'</option>'; |
| 119 | + if(is_array($clients)) { |
| 120 | + foreach( $clients as $client) { |
| 121 | + $selected = ($client["groupid"] == $sys_groupid)?'SELECTED':''; |
| 122 | + $client_select .= "<option value='$client[groupid]' $selected>$client[contactname]</option>\r\n"; |
| 123 | + } |
117 | 124 | } |
118 | | - } |
119 | 125 |
|
120 | | - $app->tpl->setVar("client_group_id", $client_select); |
| 126 | + $app->tpl->setVar("client_group_id", $client_select); |
| 127 | + } |
121 | 128 | } |
122 | 129 |
|
123 | 130 | if($_SESSION["s"]["user"]["typ"] != 'admin') |
|
162 | 169 | * Now we have to check, if we should use the domain-module to select the domain |
163 | 170 | * or not |
164 | 171 | */ |
165 | | -$app->uses('ini_parser,getconf'); |
166 | | -$settings = $app->getconf->get_global_config('domains'); |
167 | | -if ($settings['use_domain_module'] == 'y') { |
| 172 | +if ($domains_settings['use_domain_module'] == 'y') { |
168 | 173 | /* |
169 | 174 | * The domain-module is in use. |
170 | 175 | */ |
|
215 | 220 | // apply filters |
216 | 221 | if(isset($_POST['domain']) && $_POST['domain'] != ''){ |
217 | 222 | /* check if the domain module is used - and check if the selected domain can be used! */ |
218 | | - if ($settings['use_domain_module'] == 'y') { |
| 223 | + if ($domains_settings['use_domain_module'] == 'y') { |
| 224 | + if ($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
| 225 | + $_POST['client_group_id'] = $app->tools_sites->getClientIdForDomain($_POST['domain']); |
| 226 | + } |
219 | 227 | $domain_check = $app->tools_sites->checkDomainModuleDomain($_POST['domain']); |
220 | 228 | if(!$domain_check) { |
221 | 229 | // invalid domain selected |
|
0 commit comments