From 1d467abd8745e4bda87a5dc06513d0722b2238ac Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Thu, 21 May 2020 10:28:12 +0200 Subject: [PATCH 01/15] Draft for a interface_concat_client_sql var --- interface/lib/config.inc.php | 5 +++++ interface/web/dns/dns_wizard.php | 15 ++++++++++++--- interface/web/dns/list/dns_soa.list.php | 5 ++++- .../web/sites/list/web_vhost_domain.list.php | 5 ++++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/interface/lib/config.inc.php b/interface/lib/config.inc.php index 3c534f3f21..ace2f9f657 100644 --- a/interface/lib/config.inc.php +++ b/interface/lib/config.inc.php @@ -152,6 +152,11 @@ $conf['country'] = 'DE'; //** Misc. $conf['interface_logout_url'] = ''; // example: http://www.domain.tld/ +# 38 x times found ( space padded to align with the lines below. +$conf['interface_concat_client_sql'] = "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; + +# From sites list +$conf['interface_concat_client_sql'] = "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; //** Auto Load Modules $conf['start_db'] = true; diff --git a/interface/web/dns/dns_wizard.php b/interface/web/dns/dns_wizard.php index 91b2307dc5..9280829bb9 100644 --- a/interface/web/dns/dns_wizard.php +++ b/interface/web/dns/dns_wizard.php @@ -100,7 +100,11 @@ if($_SESSION['s']['user']['typ'] == 'admin') { if ($domains_settings['use_domain_module'] != 'y') { // load the list of clients - $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"; + $sql = "SELECT sys_group.groupid, sys_group.name, + " . $conf['interface_concat_client_sql'] . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -120,12 +124,17 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $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); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, " . $app->conf['interface_concat_client_sql'] . " AS contactname, sys_group.name + FROM sys_group, client + WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); if ($domains_settings['use_domain_module'] != 'y') { // load the list of clients - $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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $conf['interface_concat_client_sql'] . " AS contactname + FROM sys_group, client + WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? + ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/dns/list/dns_soa.list.php b/interface/web/dns/list/dns_soa.list.php index c08a3802cb..de8cef8140 100644 --- a/interface/web/dns/list/dns_soa.list.php +++ b/interface/web/dns/list/dns_soa.list.php @@ -84,7 +84,10 @@ if($_SESSION['s']['user']['typ'] == 'admin') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, " . $conf['interface_concat_client_sql'] . " as name + FROM sys_group, client + WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id + ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), diff --git a/interface/web/sites/list/web_vhost_domain.list.php b/interface/web/sites/list/web_vhost_domain.list.php index e6b0cd2519..e3a5407ae5 100644 --- a/interface/web/sites/list/web_vhost_domain.list.php +++ b/interface/web/sites/list/web_vhost_domain.list.php @@ -89,7 +89,10 @@ if($_SESSION['s']['user']['typ'] == 'admin' && $vhostdomain_type == 'domain') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, " . $conf['interface_concat_client_sql'] . " AS name + FROM sys_group, client + WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id + ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), -- GitLab From 03c14602c1ca46b751ea2c9f99af5e07a3e4b856 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 21 Jun 2020 21:08:49 +0200 Subject: [PATCH 02/15] cleanup --- interface/lib/config.inc.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/interface/lib/config.inc.php b/interface/lib/config.inc.php index ace2f9f657..99e6ecc74f 100644 --- a/interface/lib/config.inc.php +++ b/interface/lib/config.inc.php @@ -152,12 +152,6 @@ $conf['country'] = 'DE'; //** Misc. $conf['interface_logout_url'] = ''; // example: http://www.domain.tld/ -# 38 x times found ( space padded to align with the lines below. -$conf['interface_concat_client_sql'] = "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; - -# From sites list -$conf['interface_concat_client_sql'] = "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; - //** Auto Load Modules $conf['start_db'] = true; $conf['start_session'] = true; -- GitLab From 3cdc4fbdf866cedbb4b0b19841d2f65d41ee635d Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 21 Jun 2020 21:07:44 +0200 Subject: [PATCH 03/15] Add get_client_sql_concat_query function --- interface/lib/classes/functions.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 03e331f0f1..7a6b1522e3 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -499,7 +499,10 @@ class functions { return 'en'; } } - + + function get_client_sql_concat_query() { + return "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; + } } ?> -- GitLab From 05a08f1397d0c4eb7c77b17b66a4527daef8c195 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 21 Jun 2020 20:57:40 +0200 Subject: [PATCH 04/15] Replace the {CLIENTNAMESQL} pattern --- interface/lib/classes/tform_base.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index e6174d2da7..77c0b13cef 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -275,6 +275,7 @@ class tform_base { $querystring = str_replace("{RECORDID}", $tmp_recordid, $querystring); unset($tmp_recordid); + $querystring = str_replace("{CLIENTNAMESQL}", $app->functions->get_client_sql_concat_query(), $querystring); $querystring = str_replace("{AUTHSQL}", $this->getAuthSQL('r'), $querystring); $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring); -- GitLab From 961263685ce326813d3b329c7ea4e4873b1379f1 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 21 Jun 2020 22:29:36 +0200 Subject: [PATCH 05/15] Replace long sql snippit with {CLIENTNAMESQL} --- interface/web/admin/form/server_ip.tform.php | 2 +- interface/web/admin/form/server_php.tform.php | 2 +- interface/web/client/client_edit.php | 2 +- interface/web/client/domain_edit.php | 6 +++--- interface/web/dns/dns_import.php | 6 +++--- interface/web/dns/dns_slave_edit.php | 6 +++--- interface/web/dns/dns_soa_edit.php | 6 +++--- interface/web/help/form/support_message.tform.php | 2 +- interface/web/mail/mail_domain_edit.php | 6 +++--- interface/web/mail/mail_mailinglist_edit.php | 6 +++--- interface/web/mail/xmpp_domain_edit.php | 6 +++--- interface/web/sites/database_user_edit.php | 4 ++-- interface/web/sites/web_vhost_domain_edit.php | 10 +++++----- interface/web/vm/openvz_vm_edit.php | 6 +++--- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/interface/web/admin/form/server_ip.tform.php b/interface/web/admin/form/server_ip.tform.php index d86dbb7535..0b6c3bd719 100644 --- a/interface/web/admin/form/server_ip.tform.php +++ b/interface/web/admin/form/server_ip.tform.php @@ -105,7 +105,7 @@ $form["tabs"]['server_ip'] = array ( 'formtype' => 'SELECT', 'default' => '', 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "(SELECT 0 AS client_id, '' AS name) UNION ALL (SELECT client_id,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM client WHERE {AUTHSQL} ORDER BY contact_name)", + 'querystring' => "(SELECT 0 AS client_id, '' AS name) UNION ALL (SELECT client_id, {CLIENTNAMESQL} as name FROM client WHERE {AUTHSQL} ORDER BY contact_name)", 'keyfield'=> 'client_id', 'valuefield'=> 'name' ), diff --git a/interface/web/admin/form/server_php.tform.php b/interface/web/admin/form/server_php.tform.php index 6d443e8d50..218a1166ca 100644 --- a/interface/web/admin/form/server_php.tform.php +++ b/interface/web/admin/form/server_php.tform.php @@ -100,7 +100,7 @@ $form["tabs"]['php_name'] = array ( 'formtype' => 'SELECT', 'default' => '', 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "(SELECT 0 AS client_id, '' AS name) UNION ALL (SELECT client_id,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM client WHERE {AUTHSQL} ORDER BY contact_name)", + 'querystring' => "(SELECT 0 AS client_id, '' AS name) UNION ALL (SELECT client_id, {CLIENTNAMESQL} as name FROM client WHERE {AUTHSQL} ORDER BY contact_name)", 'keyfield'=> 'client_id', 'valuefield'=> 'name' ), diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index bbc7849f1f..c9c5b08f23 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -218,7 +218,7 @@ class page_action extends tform_actions { if($app->auth->is_admin()) { // Fill the client select field - $sql = "SELECT client.client_id, 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 AND client.limit_client != 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client != 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; diff --git a/interface/web/client/domain_edit.php b/interface/web/client/domain_edit.php index 094e1899be..921b3c5f8f 100644 --- a/interface/web/client/domain_edit.php +++ b/interface/web/client/domain_edit.php @@ -81,7 +81,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Clients of the user //$sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY 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 sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -98,11 +98,11 @@ class page_action extends tform_actions { } else { // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $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); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; //die($sql); $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); diff --git a/interface/web/dns/dns_import.php b/interface/web/dns/dns_import.php index b0c19bfff0..4702f22779 100644 --- a/interface/web/dns/dns_import.php +++ b/interface/web/dns/dns_import.php @@ -101,7 +101,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { $app->tpl->setVar("server_id", $server_id_option); // load the list of clients - $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"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -120,11 +120,11 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO // Get the limits of the client $client_group_id = intval($_SESSION["s"]["user"]["default_group"]); - $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); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // load the list of clients - $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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/dns/dns_slave_edit.php b/interface/web/dns/dns_slave_edit.php index 020a044593..14e0dff15a 100644 --- a/interface/web/dns/dns_slave_edit.php +++ b/interface/web/dns/dns_slave_edit.php @@ -83,7 +83,7 @@ class page_action extends tform_actions { // If user is admin, we will allow him to select to whom this record belongs if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Domains of the user - $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"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -100,11 +100,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, sys_group.name, 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 FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, sys_group.name, client.contact_name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/dns/dns_soa_edit.php b/interface/web/dns/dns_soa_edit.php index ec5ba67c79..2a48a69d65 100644 --- a/interface/web/dns/dns_soa_edit.php +++ b/interface/web/dns/dns_soa_edit.php @@ -105,7 +105,7 @@ class page_action extends tform_actions { // If user is admin, we will allow him to select to whom this record belongs if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Domains of the user - $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"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -122,11 +122,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = intval($_SESSION["s"]["user"]["default_group"]); - $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); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/help/form/support_message.tform.php b/interface/web/help/form/support_message.tform.php index 6313b4da67..171c53a5c9 100644 --- a/interface/web/help/form/support_message.tform.php +++ b/interface/web/help/form/support_message.tform.php @@ -71,7 +71,7 @@ $form["tabs"]['message'] = array ( 'formtype' => 'SELECT', 'default' => $sm_default_recipient_id, 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT sys_user.userid, 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_user, client WHERE sys_user.userid != 1 AND sys_user.client_id = client.client_id AND $authsql ORDER BY sys_user.username", + 'querystring' => "SELECT sys_user.userid, {CLIENTNAMESQL} as contactname FROM sys_user, client WHERE sys_user.userid != 1 AND sys_user.client_id = client.client_id AND $authsql ORDER BY sys_user.username", 'keyfield' => 'userid', 'valuefield' => 'contactname' ), diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php index 51d55ef2de..a2d29c2b9b 100644 --- a/interface/web/mail/mail_domain_edit.php +++ b/interface/web/mail/mail_domain_edit.php @@ -77,7 +77,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] == 'admin' && $settings['use_domain_module'] != 'y') { // Getting Clients of the user - $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"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); @@ -96,7 +96,7 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, 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 = ? order by client.contact_name", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by client.contact_name", $client_group_id); $client = $app->functions->htmlentities($client); // Set the mailserver to the default server of the client @@ -106,7 +106,7 @@ class page_action extends tform_actions { if ($settings['use_domain_module'] != 'y') { // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/mail/mail_mailinglist_edit.php b/interface/web/mail/mail_mailinglist_edit.php index 913611323d..8aa71da283 100644 --- a/interface/web/mail/mail_mailinglist_edit.php +++ b/interface/web/mail/mail_mailinglist_edit.php @@ -72,7 +72,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Clients of the user - $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"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -90,11 +90,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, 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 = ? order by contact_name", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by contact_name", $client_group_id); $client = $app->functions->htmlentities($client); // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/mail/xmpp_domain_edit.php b/interface/web/mail/xmpp_domain_edit.php index 500757c159..469f43b3c4 100644 --- a/interface/web/mail/xmpp_domain_edit.php +++ b/interface/web/mail/xmpp_domain_edit.php @@ -105,7 +105,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] == 'admin' && $settings['use_domain_module'] != 'y') { // Getting Clients of the user - $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"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); @@ -124,12 +124,12 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $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 = ? order by client.contact_name", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by client.contact_name", $client_group_id); $client = $app->functions->htmlentities($client); if ($settings['use_domain_module'] != 'y') { // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/sites/database_user_edit.php b/interface/web/sites/database_user_edit.php index 07fa1315f0..16d6051b4a 100644 --- a/interface/web/sites/database_user_edit.php +++ b/interface/web/sites/database_user_edit.php @@ -85,7 +85,7 @@ class page_action extends tform_actions { $client = $app->db->queryOneRecord("SELECT client.company_name, client.contact_name, client.client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); @@ -100,7 +100,7 @@ class page_action extends tform_actions { $app->tpl->setVar("client_group_id", $client_select); } elseif($_SESSION["s"]["user"]["typ"] == 'admin') { // 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 sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php index 82da18ae1e..f8c8b6b4ae 100644 --- a/interface/web/sites/web_vhost_domain_edit.php +++ b/interface/web/sites/web_vhost_domain_edit.php @@ -284,12 +284,12 @@ class page_action extends tform_actions { $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); if($this->_vhostdomain_type == 'domain') { - $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_domain, client.web_servers, client.default_webserver, 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, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_domain, client.web_servers, client.default_webserver, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $app->tpl->setVar('only_one_server', $only_one_server); } elseif($this->_vhostdomain_type == 'subdomain') { - $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_subdomain, client.web_servers, client.default_webserver, 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, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_subdomain, client.web_servers, client.default_webserver, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); } elseif($this->_vhostdomain_type == 'aliasdomain') { - $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_aliasdomain, client.web_servers, client.default_webserver, 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, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_aliasdomain, client.web_servers, client.default_webserver, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); } $client = $app->functions->htmlentities($client); @@ -326,7 +326,7 @@ class page_action extends tform_actions { if ($settings['use_domain_module'] != 'y') { // 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); @@ -588,7 +588,7 @@ class page_action extends tform_actions { $this->dataRecord["sys_groupid"] = $tmp["sys_groupid"]; } // 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 sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; diff --git a/interface/web/vm/openvz_vm_edit.php b/interface/web/vm/openvz_vm_edit.php index 4dd1a551de..2070a968f6 100644 --- a/interface/web/vm/openvz_vm_edit.php +++ b/interface/web/vm/openvz_vm_edit.php @@ -96,11 +96,11 @@ class page_action extends tform_actions { //* Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id, 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); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); //* 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); @@ -133,7 +133,7 @@ class page_action extends tform_actions { } else { //* 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 sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; -- GitLab From ea61dbaa75e7480691e2eafc8a7c71c3d7aaf1b5 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 21 Jun 2020 22:32:43 +0200 Subject: [PATCH 06/15] Replace long sql snippit with {CLIENTNAMESQL}, batch 2 --- interface/web/client/list/client_template.list.php | 2 +- interface/web/client/list/domain.list.php | 2 +- interface/web/dns/list/dns_slave.list.php | 2 +- interface/web/mail/list/mail_domain.list.php | 2 +- interface/web/sites/list/database.list.php | 2 +- interface/web/sites/list/database_user.list.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/web/client/list/client_template.list.php b/interface/web/client/list/client_template.list.php index a63776ff88..8a27e82a4b 100644 --- a/interface/web/client/list/client_template.list.php +++ b/interface/web/client/list/client_template.list.php @@ -52,7 +52,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { 'prefix' => '', 'suffix' => '', 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), diff --git a/interface/web/client/list/domain.list.php b/interface/web/client/list/domain.list.php index 8fc81eeef9..d05dc5b6ff 100644 --- a/interface/web/client/list/domain.list.php +++ b/interface/web/client/list/domain.list.php @@ -93,7 +93,7 @@ $liste["item"][] = array( 'field' => "sys_groupid", 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT a.groupid, a.name FROM sys_group a, domain b WHERE (a.groupid = b.sys_groupid) AND ({AUTHSQL-B}) ORDER BY name', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id AND {AUTHSQL} ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id AND {AUTHSQL} ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), diff --git a/interface/web/dns/list/dns_slave.list.php b/interface/web/dns/list/dns_slave.list.php index de0fd3a211..bd32b6a407 100644 --- a/interface/web/dns/list/dns_slave.list.php +++ b/interface/web/dns/list/dns_slave.list.php @@ -84,7 +84,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), diff --git a/interface/web/mail/list/mail_domain.list.php b/interface/web/mail/list/mail_domain.list.php index 5304ab6226..e2a7b015c1 100644 --- a/interface/web/mail/list/mail_domain.list.php +++ b/interface/web/mail/list/mail_domain.list.php @@ -71,7 +71,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), diff --git a/interface/web/sites/list/database.list.php b/interface/web/sites/list/database.list.php index 25e1b8de7f..6ecaa7e07e 100644 --- a/interface/web/sites/list/database.list.php +++ b/interface/web/sites/list/database.list.php @@ -92,7 +92,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), diff --git a/interface/web/sites/list/database_user.list.php b/interface/web/sites/list/database_user.list.php index dd25d03349..f8935d33ec 100644 --- a/interface/web/sites/list/database_user.list.php +++ b/interface/web/sites/list/database_user.list.php @@ -61,7 +61,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", 'keyfield'=> 'groupid', 'valuefield'=> 'name' ), -- GitLab From a33dcbb7fe5e2a7f9b5dfe48980dd2c15ab3e6a3 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 21 Jun 2020 22:41:29 +0200 Subject: [PATCH 07/15] Replace long sql snippit with {CLIENTNAMESQL}, batch 3 --- interface/web/dns/dns_wizard.php | 6 +++--- interface/web/dns/list/dns_soa.list.php | 2 +- interface/web/sites/list/web_vhost_domain.list.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/web/dns/dns_wizard.php b/interface/web/dns/dns_wizard.php index 9280829bb9..680cc67b65 100644 --- a/interface/web/dns/dns_wizard.php +++ b/interface/web/dns/dns_wizard.php @@ -101,7 +101,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { if ($domains_settings['use_domain_module'] != 'y') { // load the list of clients $sql = "SELECT sys_group.groupid, sys_group.name, - " . $conf['interface_concat_client_sql'] . " as contactname + {CLIENTNAMESQL} 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"; @@ -124,14 +124,14 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, " . $app->conf['interface_concat_client_sql'] . " AS contactname, sys_group.name + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} AS contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); if ($domains_settings['use_domain_module'] != 'y') { // load the list of clients - $sql = "SELECT sys_group.groupid, sys_group.name, " . $conf['interface_concat_client_sql'] . " AS contactname + $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} AS contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; diff --git a/interface/web/dns/list/dns_soa.list.php b/interface/web/dns/list/dns_soa.list.php index de8cef8140..006479bc3d 100644 --- a/interface/web/dns/list/dns_soa.list.php +++ b/interface/web/dns/list/dns_soa.list.php @@ -84,7 +84,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid, " . $conf['interface_concat_client_sql'] . " as name + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} as name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", diff --git a/interface/web/sites/list/web_vhost_domain.list.php b/interface/web/sites/list/web_vhost_domain.list.php index e3a5407ae5..fddf8f5f72 100644 --- a/interface/web/sites/list/web_vhost_domain.list.php +++ b/interface/web/sites/list/web_vhost_domain.list.php @@ -89,7 +89,7 @@ if($_SESSION['s']['user']['typ'] == 'admin' && $vhostdomain_type == 'domain') { 'suffix' => "", 'datasource' => array ( 'type' => 'SQL', //'querystring' => 'SELECT groupid, name FROM sys_group WHERE groupid != 1 ORDER BY name', - 'querystring' => "SELECT sys_group.groupid, " . $conf['interface_concat_client_sql'] . " AS name + 'querystring' => "SELECT sys_group.groupid, {CLIENTNAMESQL} AS name FROM sys_group, client WHERE sys_group.groupid != 1 AND sys_group.client_id = client.client_id ORDER BY client.company_name, client.contact_name", -- GitLab From 4c175435c83d5f8259a592bbb5f2a87f15b351f2 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Mon, 22 Jun 2020 09:30:05 +0200 Subject: [PATCH 08/15] Restore space --- interface/lib/config.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/lib/config.inc.php b/interface/lib/config.inc.php index 99e6ecc74f..3c534f3f21 100644 --- a/interface/lib/config.inc.php +++ b/interface/lib/config.inc.php @@ -152,6 +152,7 @@ $conf['country'] = 'DE'; //** Misc. $conf['interface_logout_url'] = ''; // example: http://www.domain.tld/ + //** Auto Load Modules $conf['start_db'] = true; $conf['start_session'] = true; -- GitLab From cac333b4fcdecb0d35f4d53ed9bfb822fab05b02 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Mon, 22 Jun 2020 21:47:19 +0200 Subject: [PATCH 09/15] Add missing str_replace, this should be not only for forms --- interface/lib/classes/listform.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index 4b92daa73c..0430cb667d 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -94,6 +94,7 @@ class listform { //$table_idx = $this->formDef['db_table_idx']; //$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring); $app->uses('tform'); + $querystring = str_replace("{CLIENTNAMESQL}", $app->functions->get_client_sql_concat_query(), $querystring); $querystring = str_replace("{AUTHSQL}", $app->tform->getAuthSQL('r'), $querystring); $querystring = str_replace("{AUTHSQL-A}", $app->tform->getAuthSQL('r', 'a'), $querystring); $querystring = str_replace("{AUTHSQL-B}", $app->tform->getAuthSQL('r', 'b'), $querystring); -- GitLab From 7a8e2f271d2e678338432498846d470d26158830 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Mon, 22 Jun 2020 21:49:05 +0200 Subject: [PATCH 10/15] Opt for the SQL pattern that also used the firstname field --- interface/lib/classes/functions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 7a6b1522e3..2e6076bb29 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -501,7 +501,7 @@ class functions { } function get_client_sql_concat_query() { - return "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; + return "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; } } -- GitLab From e8ea97b00e5de60b2c417dbc4701a8da83ff572a Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Tue, 23 Jun 2020 12:04:45 +0200 Subject: [PATCH 11/15] Move get_client_sql_concat_query() to the db class --- interface/lib/classes/db_mysql.inc.php | 6 ++++++ interface/lib/classes/functions.inc.php | 4 ---- interface/lib/classes/listform.inc.php | 1 - interface/lib/classes/tform_base.inc.php | 1 - 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index 9c7269e568..23abf87c79 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -190,9 +190,15 @@ class db } } + $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); + return $sQuery; } + function get_client_sql_concat_query() { + return "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; + } + /**#@-*/ diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 2e6076bb29..b999efedab 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -499,10 +499,6 @@ class functions { return 'en'; } } - - function get_client_sql_concat_query() { - return "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; - } } ?> diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index 0430cb667d..4b92daa73c 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -94,7 +94,6 @@ class listform { //$table_idx = $this->formDef['db_table_idx']; //$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring); $app->uses('tform'); - $querystring = str_replace("{CLIENTNAMESQL}", $app->functions->get_client_sql_concat_query(), $querystring); $querystring = str_replace("{AUTHSQL}", $app->tform->getAuthSQL('r'), $querystring); $querystring = str_replace("{AUTHSQL-A}", $app->tform->getAuthSQL('r', 'a'), $querystring); $querystring = str_replace("{AUTHSQL-B}", $app->tform->getAuthSQL('r', 'b'), $querystring); diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index 77c0b13cef..e6174d2da7 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -275,7 +275,6 @@ class tform_base { $querystring = str_replace("{RECORDID}", $tmp_recordid, $querystring); unset($tmp_recordid); - $querystring = str_replace("{CLIENTNAMESQL}", $app->functions->get_client_sql_concat_query(), $querystring); $querystring = str_replace("{AUTHSQL}", $this->getAuthSQL('r'), $querystring); $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring); -- GitLab From 306998f93c80dd4f7204566bad16f7cb8ace5cf6 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Tue, 23 Jun 2020 13:56:25 +0200 Subject: [PATCH 12/15] Move {CLIENTNAMESQL} higher up to avoid replacing placeholder data --- interface/lib/classes/db_mysql.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index 23abf87c79..a6dd64c2ee 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -134,6 +134,8 @@ class db } public function _build_query_string($sQuery = '') { + $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); + $iArgs = func_num_args(); if($iArgs > 1) { $aArgs = func_get_args(); @@ -190,8 +192,6 @@ class db } } - $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); - return $sQuery; } -- GitLab From 4570911fd3210ce6c1954baea7b38398b9770184 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Fri, 24 Jul 2020 22:22:45 +0200 Subject: [PATCH 13/15] One new extra occuance of {CLIENTNAMESQL} --- interface/web/mail/mail_domain_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php index 95b1ea4a19..7b27873190 100644 --- a/interface/web/mail/mail_domain_edit.php +++ b/interface/web/mail/mail_domain_edit.php @@ -76,7 +76,7 @@ class page_action extends tform_actions { $settings = $app->getconf->get_global_config('domains'); if($_SESSION["s"]["user"]["typ"] == 'admin' && $settings['use_domain_module'] == 'y') { - $sql = "SELECT 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.groupid = ?"; + $sql = "SELECT {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = ?"; $clients = $app->db->queryAllRecords($sql, $this->dataRecord['sys_groupid']); $client_select = ''; $app->tpl->setVar("client_group_name", $client_select); -- GitLab From 0df596d8840f18f7e5c87604b627c4f5102d1c73 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 22 May 2022 21:34:24 +0200 Subject: [PATCH 14/15] Move the CLIENTNAMESQL replace out of the way from form postings These two are the only ones being used by the respective queries and the onUpdateSave() methods use query() directly. --- interface/lib/classes/db_mysql.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index 35e58637ce..49fd378d79 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -134,8 +134,6 @@ class db } public function _build_query_string($sQuery = '') { - $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); - $iArgs = func_num_args(); if($iArgs > 1) { $aArgs = func_get_args(); @@ -356,6 +354,7 @@ class db * @return array result row or NULL if none found */ public function queryOneRecord($sQuery = '') { + $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); $aArgs = func_get_args(); if(!empty($aArgs)) { @@ -395,6 +394,7 @@ class db * @return array all the rows in the result set */ public function queryAllRecords($sQuery = '') { + $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); $aArgs = func_get_args(); $oResult = call_user_func_array(array(&$this, 'query'), $aArgs); if(!$oResult) return array(); -- GitLab From f297d7771fa3a79e60b4314ca235990880d837b4 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sun, 21 Jun 2020 21:07:44 +0200 Subject: [PATCH 15/15] Move back out of db class again --- interface/lib/classes/db_mysql.inc.php | 6 ------ interface/lib/classes/functions.inc.php | 4 ++++ interface/lib/classes/listform.inc.php | 1 + interface/lib/classes/tform_base.inc.php | 1 + interface/web/client/client_edit.php | 2 +- interface/web/client/domain_edit.php | 6 +++--- interface/web/dns/dns_import.php | 6 +++--- interface/web/dns/dns_slave_edit.php | 6 +++--- interface/web/dns/dns_soa_edit.php | 6 +++--- interface/web/dns/dns_wizard.php | 6 +++--- interface/web/mail/mail_domain_edit.php | 8 ++++---- interface/web/mail/mail_mailinglist_edit.php | 6 +++--- interface/web/mail/xmpp_domain_edit.php | 6 +++--- interface/web/sites/database_user_edit.php | 4 ++-- interface/web/sites/web_vhost_domain_edit.php | 10 +++++----- interface/web/vm/openvz_vm_edit.php | 6 +++--- 16 files changed, 42 insertions(+), 42 deletions(-) diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index 49fd378d79..cd9c333b22 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -189,10 +189,6 @@ class db return $sQuery; } - function get_client_sql_concat_query() { - return "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), IF(client.contact_firstname != '', CONCAT(client.contact_firstname, ' '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; - } - /**#@-*/ @@ -354,7 +350,6 @@ class db * @return array result row or NULL if none found */ public function queryOneRecord($sQuery = '') { - $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); $aArgs = func_get_args(); if(!empty($aArgs)) { @@ -394,7 +389,6 @@ class db * @return array all the rows in the result set */ public function queryAllRecords($sQuery = '') { - $sQuery = str_replace("{CLIENTNAMESQL}", $this->get_client_sql_concat_query(), $sQuery); $aArgs = func_get_args(); $oResult = call_user_func_array(array(&$this, 'query'), $aArgs); if(!$oResult) return array(); diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 1b39668674..2e3ca3bcee 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -640,6 +640,10 @@ class functions { return $result; } + // SQL query snippit for the client's company and username. + function get_client_sql_concat_query() { + return "CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')')"; + } } ?> diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index 4b92daa73c..26557bbf3a 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -94,6 +94,7 @@ class listform { //$table_idx = $this->formDef['db_table_idx']; //$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring); $app->uses('tform'); + $querystring = str_replace("{CLIENTNAMESQL}", $app->functions->get_client_sql_concat_query(), $querystring); $querystring = str_replace("{AUTHSQL}", $app->tform->getAuthSQL('r'), $querystring); $querystring = str_replace("{AUTHSQL-A}", $app->tform->getAuthSQL('r', 'a'), $querystring); $querystring = str_replace("{AUTHSQL-B}", $app->tform->getAuthSQL('r', 'b'), $querystring); diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index cfaf0958d5..a916f3000d 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -275,6 +275,7 @@ class tform_base { $querystring = str_replace("{RECORDID}", $tmp_recordid, $querystring); unset($tmp_recordid); + $querystring = str_replace("{CLIENTNAMESQL}", $app->functions->get_client_sql_concat_query(), $querystring); $querystring = str_replace("{AUTHSQL}", $this->getAuthSQL('r'), $querystring); $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring); diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index 166170a7e2..b912e356fb 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -235,7 +235,7 @@ class page_action extends tform_actions { if($app->auth->is_admin()) { // Fill the client select field - $sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client != 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client != 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; diff --git a/interface/web/client/domain_edit.php b/interface/web/client/domain_edit.php index 1a8bb7feec..8859d4e209 100644 --- a/interface/web/client/domain_edit.php +++ b/interface/web/client/domain_edit.php @@ -81,7 +81,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Clients of the user //$sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name"; - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -98,11 +98,11 @@ class page_action extends tform_actions { } else { // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; //die($sql); $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); diff --git a/interface/web/dns/dns_import.php b/interface/web/dns/dns_import.php index 4702f22779..7c5d0493ef 100644 --- a/interface/web/dns/dns_import.php +++ b/interface/web/dns/dns_import.php @@ -101,7 +101,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { $app->tpl->setVar("server_id", $server_id_option); // load the list of clients - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -120,11 +120,11 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO // Get the limits of the client $client_group_id = intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // load the list of clients - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/dns/dns_slave_edit.php b/interface/web/dns/dns_slave_edit.php index 14e0dff15a..843e27f745 100644 --- a/interface/web/dns/dns_slave_edit.php +++ b/interface/web/dns/dns_slave_edit.php @@ -83,7 +83,7 @@ class page_action extends tform_actions { // If user is admin, we will allow him to select to whom this record belongs if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Domains of the user - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -100,11 +100,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, sys_group.name, client.contact_name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, sys_group.name, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/dns/dns_soa_edit.php b/interface/web/dns/dns_soa_edit.php index e1ab3f33df..9c0d064cf7 100644 --- a/interface/web/dns/dns_soa_edit.php +++ b/interface/web/dns/dns_soa_edit.php @@ -105,7 +105,7 @@ class page_action extends tform_actions { // If user is admin, we will allow him to select to whom this record belongs if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Domains of the user - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -122,11 +122,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/dns/dns_wizard.php b/interface/web/dns/dns_wizard.php index 3a4e528843..09ac128618 100644 --- a/interface/web/dns/dns_wizard.php +++ b/interface/web/dns/dns_wizard.php @@ -101,7 +101,7 @@ if($_SESSION['s']['user']['typ'] == 'admin') { if ($domains_settings['use_domain_module'] != 'y') { // load the list of clients $sql = "SELECT sys_group.groupid, sys_group.name, - {CLIENTNAMESQL} as contactname + " . $app->functions->get_client_sql_concat_query() . " 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"; @@ -124,14 +124,14 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} AS contactname, sys_group.name + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " AS contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); if ($domains_settings['use_domain_module'] != 'y') { // load the list of clients - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} AS contactname + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " AS contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php index ac61328f1f..803fe55c9c 100644 --- a/interface/web/mail/mail_domain_edit.php +++ b/interface/web/mail/mail_domain_edit.php @@ -76,14 +76,14 @@ class page_action extends tform_actions { $settings = $app->getconf->get_global_config('domains'); if($_SESSION["s"]["user"]["typ"] == 'admin' && $settings['use_domain_module'] == 'y') { - $sql = "SELECT {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = ?"; + $sql = "SELECT " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = ?"; $clients = $app->db->queryAllRecords($sql, $this->dataRecord['sys_groupid']); $client_select = ''; $app->tpl->setVar("client_group_name", $client_select); } elseif($_SESSION["s"]["user"]["typ"] == 'admin' && $settings['use_domain_module'] != 'y') { // Getting Clients of the user - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); @@ -102,7 +102,7 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by client.contact_name", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by client.contact_name", $client_group_id); $client = $app->functions->htmlentities($client); // Set the mailserver to the default server of the client @@ -112,7 +112,7 @@ class page_action extends tform_actions { if ($settings['use_domain_module'] != 'y') { // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/mail/mail_mailinglist_edit.php b/interface/web/mail/mail_mailinglist_edit.php index 8aa71da283..bba970d711 100644 --- a/interface/web/mail/mail_mailinglist_edit.php +++ b/interface/web/mail/mail_mailinglist_edit.php @@ -72,7 +72,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Clients of the user - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ''; @@ -90,11 +90,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by contact_name", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.default_mailserver, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by contact_name", $client_group_id); $client = $app->functions->htmlentities($client); // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/mail/xmpp_domain_edit.php b/interface/web/mail/xmpp_domain_edit.php index 469f43b3c4..9d7656cacc 100644 --- a/interface/web/mail/xmpp_domain_edit.php +++ b/interface/web/mail/xmpp_domain_edit.php @@ -105,7 +105,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] == 'admin' && $settings['use_domain_module'] != 'y') { // Getting Clients of the user - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); @@ -124,12 +124,12 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by client.contact_name", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? order by client.contact_name", $client_group_id); $client = $app->functions->htmlentities($client); if ($settings['use_domain_module'] != 'y') { // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql, $client['client_id']); $clients = $app->functions->htmlentities($clients); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); diff --git a/interface/web/sites/database_user_edit.php b/interface/web/sites/database_user_edit.php index 16d6051b4a..84b1f33606 100644 --- a/interface/web/sites/database_user_edit.php +++ b/interface/web/sites/database_user_edit.php @@ -85,7 +85,7 @@ class page_action extends tform_actions { $client = $app->db->queryOneRecord("SELECT client.company_name, client.contact_name, client.client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); @@ -100,7 +100,7 @@ class page_action extends tform_actions { $app->tpl->setVar("client_group_id", $client_select); } elseif($_SESSION["s"]["user"]["typ"] == 'admin') { // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php index e8f5f01cda..25fa69d8b4 100644 --- a/interface/web/sites/web_vhost_domain_edit.php +++ b/interface/web/sites/web_vhost_domain_edit.php @@ -279,12 +279,12 @@ class page_action extends tform_actions { $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); if($this->_vhostdomain_type == 'domain') { - $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_domain, client.web_servers, client.default_webserver, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_domain, client.web_servers, client.default_webserver, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $app->tpl->setVar('only_one_server', $only_one_server); } elseif($this->_vhostdomain_type == 'subdomain') { - $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_subdomain, client.web_servers, client.default_webserver, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_subdomain, client.web_servers, client.default_webserver, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); } elseif($this->_vhostdomain_type == 'aliasdomain') { - $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_aliasdomain, client.web_servers, client.default_webserver, client.contact_name, {CLIENTNAMESQL} as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_aliasdomain, client.web_servers, client.default_webserver, client.contact_name, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); } $client = $app->functions->htmlentities($client); @@ -321,7 +321,7 @@ class page_action extends tform_actions { if ($settings['use_domain_module'] != 'y') { // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); @@ -539,7 +539,7 @@ class page_action extends tform_actions { $this->dataRecord["sys_groupid"] = $tmp["sys_groupid"]; } // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; diff --git a/interface/web/vm/openvz_vm_edit.php b/interface/web/vm/openvz_vm_edit.php index 2070a968f6..0c4e0f3b19 100644 --- a/interface/web/vm/openvz_vm_edit.php +++ b/interface/web/vm/openvz_vm_edit.php @@ -96,11 +96,11 @@ class page_action extends tform_actions { //* Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id, {CLIENTNAMESQL} as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id, " . $app->functions->get_client_sql_concat_query() . " as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); $client = $app->functions->htmlentities($client); //* Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; $records = $app->db->queryAllRecords($sql, $client['client_id']); $records = $app->functions->htmlentities($records); $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); @@ -133,7 +133,7 @@ class page_action extends tform_actions { } else { //* Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, {CLIENTNAMESQL} 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"; + $sql = "SELECT sys_group.groupid, sys_group.name, " . $app->functions->get_client_sql_concat_query() . " 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"; $clients = $app->db->queryAllRecords($sql); $clients = $app->functions->htmlentities($clients); $client_select = ""; -- GitLab