From 5c80fff2ca165e98b9a7bf5c865ef5de0e4a8cd0 Mon Sep 17 00:00:00 2001
From: cfoe <cfoe@ispconfig3>
Date: Tue, 04 Sep 2012 09:27:33 -0400
Subject: [PATCH] icon generation correction
---
interface/lib/classes/remoting.inc.php | 217 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 195 insertions(+), 22 deletions(-)
diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index e5b1c98..ae731d7 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -1063,7 +1063,8 @@
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
- $affected_rows = $this->klientadd('../client/form/client.tform.php',$reseller_id, $params);
+ if(!isset($params['parent_client_id']) || $params['parent_client_id'] == 0) $params['parent_client_id'] = $reseller_id;
+ $affected_rows = $this->klientadd('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php',$reseller_id, $params);
return $affected_rows;
}
@@ -1077,7 +1078,8 @@
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
- $affected_rows = $this->updateQuery('../client/form/client.tform.php', $reseller_id, $client_id, $params);
+ if(!isset($params['parent_client_id']) || $params['parent_client_id'] == 0) $params['parent_client_id'] = $reseller_id;
+ $affected_rows = $this->updateQuery('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php', $reseller_id, $client_id, $params);
$app->remoting_lib->ispconfig_sysuser_update($params,$client_id);
@@ -1113,7 +1115,7 @@
$client_id = intval($client_id);
$client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
- $tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_domain,web_traffic';
+ $tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain,web_traffic';
$tables_array = explode(',',$tables);
$client_group_id = intval($client_group['groupid']);
@@ -1143,7 +1145,7 @@
$app->db->query("DELETE FROM sys_user WHERE client_id = $client_id");
// Delete all records (sub-clients, mail, web, etc....) of this client.
- $tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_domain,web_traffic';
+ $tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain,web_traffic';
$tables_array = explode(',',$tables);
$client_group_id = intval($client_group['groupid']);
if($client_group_id > 1) {
@@ -1257,7 +1259,19 @@
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
- return $this->insertQuery('../sites/form/database.tform.php',$client_id,$params);
+
+ $sql = $this->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params);
+ if($sql !== false) {
+ $app->uses('sites_database_plugin');
+
+ $this->id = 0;
+ $this->dataRecord = $params;
+ $app->sites_database_plugin->processDatabaseInsert($this);
+
+ return $this->insertQueryExecute($sql, $params);
+ }
+
+ return false;
}
//* Update a record
@@ -1267,8 +1281,18 @@
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
- $affected_rows = $this->updateQuery('../sites/form/database.tform.php',$client_id,$primary_id,$params);
- return $affected_rows;
+
+ $sql = $this->updateQueryPrepare('../sites/form/database.tform.php', $client_id, $primary_id, $params);
+ if($sql !== false) {
+ $app->uses('sites_database_plugin');
+
+ $this->id = $primary_id;
+ $this->dataRecord = $params;
+ $app->sites_database_plugin->processDatabaseUpdate($this);
+ return $this->updateQueryExecute($sql, $primary_id, $params);
+ }
+
+ return false;
}
//* Delete a record
@@ -1278,7 +1302,61 @@
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
+
+ $app->uses('sites_database_plugin');
+ $app->sites_database_plugin->processDatabaseDelete($primary_id);
+
$affected_rows = $this->deleteQuery('../sites/form/database.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_database_user_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_database_user_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_database_user_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_database_user_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+
+ return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params);
+ }
+
+ //* Update a record
+ public function sites_database_user_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_database_user_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+
+ return $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params);
+ }
+
+ //* Delete a record
+ public function sites_database_user_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_database_user_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+
+ $affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php',$primary_id);
return $affected_rows;
}
@@ -1471,6 +1549,75 @@
return false;
}
$affected_rows = $this->deleteQuery('../sites/form/web_domain.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_web_vhost_subdomain_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/web_vhost_subdomain.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_web_vhost_subdomain_add($session_id, $client_id, $params)
+ {
+ global $app;
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+
+ //* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin
+ if($params['document_root'] == '') $params['document_root'] = '-';
+ if($params['system_user'] == '') $params['system_user'] = '-';
+ if($params['system_group'] == '') $params['system_group'] = '-';
+
+ //* Set a few defaults for nginx servers
+ if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
+ if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
+ if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
+ if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
+
+ $domain_id = $this->insertQuery('../sites/form/web_vhost_subdomain.tform.php',$client_id,$params, 'sites:web_vhost_subdomain:on_after_insert');
+ return $domain_id;
+ }
+
+ //* Update a record
+ public function sites_web_vhost_subdomain_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+
+ //* Set a few defaults for nginx servers
+ if($params['pm_max_children'] == '') $params['pm_max_children'] = 1;
+ if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1;
+ if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1;
+ if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1;
+
+ $affected_rows = $this->updateQuery('../sites/form/web_vhost_subdomain.tform.php',$client_id,$primary_id,$params, 'sites:web_vhost_subdomain:on_after_insert');
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function sites_web_vhost_subdomain_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/web_vhost_subdomain.tform.php',$primary_id);
return $affected_rows;
}
@@ -2458,7 +2605,7 @@
protected function klientadd($formdef_file, $reseller_id, $params)
{
- global $app, $tform, $remoting_lib;
+ global $app;
$app->uses('remoting_lib');
//* Load the form definition
@@ -2466,13 +2613,6 @@
//* load the user profile of the client
$app->remoting_lib->loadUserProfile($reseller_id);
-
- //* load the client template
- if(isset($params['template_master']) and $params['template_master'] > 0)
- {
- $template=$app->db->queryOneRecord("SELECT * FROM client_template WHERE template_id=".intval($params['template_master']));
- if(is_array($template)) $params=array_merge($params,$template);
- }
//* Get the SQL query
$sql = $app->remoting_lib->getSQL($params,'INSERT',0);
@@ -2502,7 +2642,7 @@
$this->id = $insert_id;
$this->dataRecord = $params;
- $app->plugin->raiseEvent('client:client:on_after_insert',$this);
+ $app->plugin->raiseEvent('client:' . ($reseller_id ? 'reseller' : 'client') . ':on_after_insert',$this);
/*
if($app->db->errorMessage != '') {
@@ -2530,9 +2670,16 @@
return $insert_id;
}
- protected function insertQuery($formdef_file, $client_id, $params,$event_identifier = '')
+ protected function insertQuery($formdef_file, $client_id, $params,$event_identifier = '')
{
- global $app, $tform, $remoting_lib;
+ $sql = $this->insertQueryPrepare($formdef_file, $client_id, $params);
+ if($sql !== false) return $this->insertQueryExecute($sql, $params,$event_identifier = '');
+ else return false;
+ }
+
+ protected function insertQueryPrepare($formdef_file, $client_id, $params)
+ {
+ global $app;
$app->uses('remoting_lib');
@@ -2549,6 +2696,15 @@
return false;
}
+ return $sql;
+ }
+
+ protected function insertQueryExecute($sql, $params,$event_identifier = '')
+ {
+ global $app;
+
+ $app->uses('remoting_lib');
+
$app->db->query($sql);
if($app->db->errorMessage != '') {
@@ -2572,9 +2728,17 @@
}
return $insert_id;
}
-
-
+
protected function updateQuery($formdef_file, $client_id, $primary_id, $params, $event_identifier = '')
+ {
+ global $app;
+
+ $sql = $this->updateQueryPrepare($formdef_file, $client_id, $primary_id, $params);
+ if($sql !== false) return $this->updateQueryExecute($sql, $primary_id, $params,$event_identifier = '');
+ else return false;
+ }
+
+ protected function updateQueryPrepare($formdef_file, $client_id, $primary_id, $params)
{
global $app;
@@ -2593,6 +2757,15 @@
$this->server->fault('data_processing_error', $app->remoting_lib->errorMessage);
return false;
}
+
+ return $sql;
+ }
+
+ protected function updateQueryExecute($sql, $primary_id, $params, $event_identifier = '')
+ {
+ global $app;
+
+ $app->uses('remoting_lib');
$old_rec = $app->remoting_lib->getDataRecord($primary_id);
@@ -2620,7 +2793,7 @@
return $affected_rows;
}
-
+
protected function deleteQuery($formdef_file, $primary_id, $event_identifier = '')
{
global $app;
@@ -2895,7 +3068,7 @@
return false;
}
$client_id = intval($client_id);
- $sql = "SELECT d.database_id, d.database_name, d.database_user, d.database_password FROM web_database d INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id";
+ $sql = "SELECT d.database_id, d.database_name, d.database_user_id, d.database_ro_user_id, du.database_user, du.database_password FROM web_database d LEFT JOIN web_database_user du ON (du.database_user_id = d.database_user_id) INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id";
$all = $app->db->queryAllRecords($sql);
return $all;
}
--
Gitblit v1.9.1