Skip to content

Commit ecb6b3a

Browse files
author
mcramer
committed
- Added database, database_user and vhost subdomain functions to the remoting
- Added interface plugins for db and db users - changed remoting (splitted up insert, update and deletequery)
1 parent cb1aa5f commit ecb6b3a

File tree

6 files changed

+349
-141
lines changed

6 files changed

+349
-141
lines changed

interface/lib/classes/remoting.inc.php

Lines changed: 121 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ public function client_delete_everything($session_id, $client_id)
11131113
$client_id = intval($client_id);
11141114
$client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
11151115

1116-
$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';
1116+
$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';
11171117
$tables_array = explode(',',$tables);
11181118
$client_group_id = intval($client_group['groupid']);
11191119

@@ -1143,7 +1143,7 @@ public function client_delete_everything($session_id, $client_id)
11431143
$app->db->query("DELETE FROM sys_user WHERE client_id = $client_id");
11441144

11451145
// Delete all records (sub-clients, mail, web, etc....) of this client.
1146-
$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';
1146+
$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';
11471147
$tables_array = explode(',',$tables);
11481148
$client_group_id = intval($client_group['groupid']);
11491149
if($client_group_id > 1) {
@@ -1257,7 +1257,19 @@ public function sites_database_add($session_id, $client_id, $params)
12571257
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
12581258
return false;
12591259
}
1260-
return $this->insertQuery('../sites/form/database.tform.php',$client_id,$params);
1260+
1261+
$sql = $this->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params);
1262+
if($sql !== false) {
1263+
$app->uses('sites_database_plugin');
1264+
1265+
$this->id = 0;
1266+
$this->dataRecord = $params;
1267+
$app->sites_database_plugin->processDatabaseInsert($this);
1268+
1269+
return $this->insertQueryExecute($sql, $params);
1270+
}
1271+
1272+
return false;
12611273
}
12621274

12631275
//* Update a record
@@ -1267,8 +1279,18 @@ public function sites_database_update($session_id, $client_id, $primary_id, $par
12671279
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
12681280
return false;
12691281
}
1270-
$affected_rows = $this->updateQuery('../sites/form/database.tform.php',$client_id,$primary_id,$params);
1271-
return $affected_rows;
1282+
1283+
$sql = $this->updateQueryPrepare('../sites/form/database.tform.php', $client_id, $primary_id, $params);
1284+
if($sql !== false) {
1285+
$app->uses('sites_database_plugin');
1286+
1287+
$this->id = $primary_id;
1288+
$this->dataRecord = $params;
1289+
$app->sites_database_plugin->processDatabaseUpdate($this);
1290+
return $this->updateQueryExecute($sql, $primary_id, $params);
1291+
}
1292+
1293+
return false;
12721294
}
12731295

12741296
//* Delete a record
@@ -1278,12 +1300,66 @@ public function sites_database_delete($session_id, $primary_id)
12781300
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
12791301
return false;
12801302
}
1303+
1304+
$app->uses('sites_database_plugin');
1305+
$app->sites_database_plugin->processDatabaseDelete($primary_id);
1306+
12811307
$affected_rows = $this->deleteQuery('../sites/form/database.tform.php',$primary_id);
12821308
return $affected_rows;
12831309
}
12841310

12851311
// ----------------------------------------------------------------------------------------------------------
12861312

1313+
//* Get record details
1314+
public function sites_database_user_get($session_id, $primary_id)
1315+
{
1316+
global $app;
1317+
1318+
if(!$this->checkPerm($session_id, 'sites_database_user_get')) {
1319+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
1320+
return false;
1321+
}
1322+
$app->uses('remoting_lib');
1323+
$app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php');
1324+
return $app->remoting_lib->getDataRecord($primary_id);
1325+
}
1326+
1327+
//* Add a record
1328+
public function sites_database_user_add($session_id, $client_id, $params)
1329+
{
1330+
if(!$this->checkPerm($session_id, 'sites_database_user_add')) {
1331+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
1332+
return false;
1333+
}
1334+
1335+
return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params);
1336+
}
1337+
1338+
//* Update a record
1339+
public function sites_database_user_update($session_id, $client_id, $primary_id, $params)
1340+
{
1341+
if(!$this->checkPerm($session_id, 'sites_database_user_update')) {
1342+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
1343+
return false;
1344+
}
1345+
1346+
return $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params);
1347+
}
1348+
1349+
//* Delete a record
1350+
public function sites_database_user_delete($session_id, $primary_id)
1351+
{
1352+
if(!$this->checkPerm($session_id, 'sites_database_user_delete')) {
1353+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
1354+
return false;
1355+
}
1356+
1357+
$affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php',$primary_id);
1358+
return $affected_rows;
1359+
}
1360+
1361+
// ----------------------------------------------------------------------------------------------------------
1362+
12871363
//* Get record details
12881364
public function sites_ftp_user_get($session_id, $primary_id)
12891365
{
@@ -2527,7 +2603,7 @@ public function dns_txt_delete($session_id, $primary_id)
25272603

25282604
protected function klientadd($formdef_file, $reseller_id, $params)
25292605
{
2530-
global $app, $tform, $remoting_lib;
2606+
global $app;
25312607
$app->uses('remoting_lib');
25322608

25332609
//* Load the form definition
@@ -2599,9 +2675,16 @@ protected function klientadd($formdef_file, $reseller_id, $params)
25992675
return $insert_id;
26002676
}
26012677

2602-
protected function insertQuery($formdef_file, $client_id, $params,$event_identifier = '')
2678+
protected function insertQuery($formdef_file, $client_id, $params,$event_identifier = '')
26032679
{
2604-
global $app, $tform, $remoting_lib;
2680+
$sql = $this->insertQueryPrepare($formdef_file, $client_id, $params);
2681+
if($sql !== false) return $this->insertQueryExecute($sql, $params,$event_identifier = '');
2682+
else return false;
2683+
}
2684+
2685+
protected function insertQueryPrepare($formdef_file, $client_id, $params)
2686+
{
2687+
global $app;
26052688

26062689
$app->uses('remoting_lib');
26072690

@@ -2618,6 +2701,15 @@ protected function insertQuery($formdef_file, $client_id, $params,$event_identif
26182701
return false;
26192702
}
26202703

2704+
return $sql;
2705+
}
2706+
2707+
protected function insertQueryExecute($sql, $params,$event_identifier = '')
2708+
{
2709+
global $app;
2710+
2711+
$app->uses('remoting_lib');
2712+
26212713
$app->db->query($sql);
26222714

26232715
if($app->db->errorMessage != '') {
@@ -2641,12 +2733,20 @@ protected function insertQuery($formdef_file, $client_id, $params,$event_identif
26412733
}
26422734
return $insert_id;
26432735
}
2644-
2645-
2736+
26462737
protected function updateQuery($formdef_file, $client_id, $primary_id, $params, $event_identifier = '')
26472738
{
26482739
global $app;
26492740

2741+
$sql = $this->updateQueryPrepare($formdef_file, $client_id, $primary_id, $params);
2742+
if($sql !== false) return $this->updateQueryExecute($sql, $primary_id, $params,$event_identifier = '');
2743+
else return false;
2744+
}
2745+
2746+
protected function updateQueryPrepare($formdef_file, $client_id, $primary_id, $params)
2747+
{
2748+
global $app;
2749+
26502750
$app->uses('remoting_lib');
26512751

26522752
//* load the user profile of the client
@@ -2663,6 +2763,15 @@ protected function updateQuery($formdef_file, $client_id, $primary_id, $params,
26632763
return false;
26642764
}
26652765

2766+
return $sql;
2767+
}
2768+
2769+
protected function updateQueryExecute($sql, $primary_id, $params, $event_identifier = '')
2770+
{
2771+
global $app;
2772+
2773+
$app->uses('remoting_lib');
2774+
26662775
$old_rec = $app->remoting_lib->getDataRecord($primary_id);
26672776

26682777
// set a few values for compatibility with tform actions, mostly used by plugins
@@ -2689,7 +2798,7 @@ protected function updateQuery($formdef_file, $client_id, $primary_id, $params,
26892798

26902799
return $affected_rows;
26912800
}
2692-
2801+
26932802
protected function deleteQuery($formdef_file, $primary_id, $event_identifier = '')
26942803
{
26952804
global $app;
@@ -2964,7 +3073,7 @@ public function sites_database_get_all_by_user($session_id, $client_id)
29643073
return false;
29653074
}
29663075
$client_id = intval($client_id);
2967-
$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";
3076+
$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";
29683077
$all = $app->db->queryAllRecords($sql);
29693078
return $all;
29703079
}

0 commit comments

Comments
 (0)