From 84710d22010a71c53ec7a2537b6899d29a31e13a Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Mon, 02 Jan 2012 15:26:47 -0500 Subject: [PATCH] - Improved check for vhosts created with the remote API FS#1950 --- interface/lib/classes/validate_client.inc.php | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/interface/lib/classes/validate_client.inc.php b/interface/lib/classes/validate_client.inc.php index 9c81aa3..97b9221 100644 --- a/interface/lib/classes/validate_client.inc.php +++ b/interface/lib/classes/validate_client.inc.php @@ -36,18 +36,24 @@ function username_unique($field_name, $field_value, $validator) { global $app; - if($app->tform->action == 'NEW') { + if(isset($app->remoting_lib->primary_id)) { + $client_id = $app->remoting_lib->primary_id; + } else { + $client_id = $app->tform->primary_id; + } + + if($client_id == 0) { $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."'"); if($num_rec["number"] > 0) { $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { + if(isset($app->tform->wordbook[$errmsg])) { return $app->tform->wordbook[$errmsg]."<br>\r\n"; } else { return $errmsg."<br>\r\n"; } } } else { - $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."' AND client_id != ".$app->tform->primary_id); + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."' AND client_id != ".$client_id); if($num_rec["number"] > 0) { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { -- Gitblit v1.9.1