Skip to content

Commit a5796fc

Browse files
author
Till Brehm
committed
Merge branch 'domains_domain_update-3.1' into 'stable-3.1'
Add domains domain update API function See merge request ispconfig/ispconfig3!845
2 parents 7bd740f + c632066 commit a5796fc

File tree

7 files changed

+84
-5
lines changed

7 files changed

+84
-5
lines changed

interface/lib/classes/remote.d/domains.inc.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ public function domains_domain_add($session_id, $client_id, $params)
6565
return $this->insertQuery('../client/form/domain.tform.php', $client_id, $params);
6666
}
6767

68+
//* Update a record
69+
public function domains_domain_update($session_id, $client_id, $primary_id, $params)
70+
{
71+
if(!$this->checkPerm($session_id, 'domains_domain_update')) {
72+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
73+
return false;
74+
}
75+
return $this->updateQuery('../client/form/domain.tform.php', $client_id, $primary_id, $params);
76+
}
77+
6878
//* Delete a record
6979
public function domains_domain_delete($session_id, $primary_id)
7080
{

interface/lib/classes/remoting.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ protected function updateQueryPrepare($formdef_file, $client_id, $primary_id, $p
383383
$app->remoting_lib->loadFormDef($formdef_file);
384384

385385
//* get old record and merge with params, so only new values have to be set in $params
386-
$old_rec = $app->remoting_lib->getDataRecord($primary_id);
386+
$old_rec = $app->remoting_lib->getDataRecord($primary_id, $client_id);
387387

388388
foreach ($app->remoting_lib->formDef['fields'] as $fieldName => $fieldConf)
389389
{

interface/lib/classes/remoting_lib.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ function getDeleteSQL($primary_id) {
225225
return $sql;
226226
}
227227

228-
function getDataRecord($primary_id) {
228+
function getDataRecord($primary_id, $client_id = 0) {
229229
global $app;
230230
$escape = '`';
231-
$this->loadUserProfile();
231+
$this->loadUserProfile($client_id);
232232
if(@is_numeric($primary_id)) {
233233
if($primary_id > 0) {
234234
// Return a single record

interface/lib/classes/tform_base.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ protected function _getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $
13841384
} else {
13851385
if($this->formDef['auth'] == 'yes') {
13861386
if($primary_id != 0) {
1387-
if($api == true && $_SESSION["s"]["user"]["client_id"] > 0 && $_SESSION["s"]["user"]["iserid"] > 0 && $_SESSION["s"]["user"]["default_group"] > 0) {
1387+
if($api == true && $_SESSION["s"]["user"]["client_id"] > 0 && $_SESSION["s"]["user"]["userid"] > 0 && $_SESSION["s"]["user"]["default_group"] > 0) {
13881388
$sql_update .= '`sys_userid` = '.$this->sys_userid.', ';
13891389
$sql_update .= '`sys_groupid` = '.$this->sys_default_group.', ';
13901390
}

interface/web/client/lib/remote.conf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
$function_list['client_get_all,client_get,client_add,client_update,client_delete,client_get_sites_by_user,client_get_by_username,client_get_by_customer_no,client_change_password,client_get_id,client_delete_everything,client_get_emailcontact'] = 'Client functions';
4-
$function_list['domains_domain_get,domains_domain_add,domains_domain_delete,domains_get_all_by_user'] = 'Domaintool functions';
4+
$function_list['domains_domain_get,domains_domain_add,domains_domain_update,domains_domain_delete,domains_get_all_by_user'] = 'Domaintool functions';
55
$function_list['quota_get_by_user,trafficquota_get_by_user,mailquota_get_by_user,databasequota_get_by_user'] = 'Quota functions';
66

77

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2+
<html><head><title>ISPCOnfig 3 remote API documentation</title>
3+
4+
5+
6+
7+
8+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9+
<link rel="stylesheet" type="text/css" href="definitionen.css">
10+
<style type="text/css">
11+
</style></head>
12+
13+
<body>
14+
<div style="padding:40px">
15+
<h1>domains_domain_update(<span class="var">$session_id</span>, <span class="var">$client_id</span>, <span class="var">$primary_id</span>, <span class="var">$params</span>);</h1>
16+
<br>
17+
<p class="headgrp">Description: </p>
18+
<p class="margin"> Updates domain to move it to another client.</p><br>
19+
<p class="headgrp">Input Variables: </p>
20+
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$client_id</span>, <span class="var">$primary_id</span>, <span class="var">$params</span></p>
21+
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
22+
<p class="margin"> domain&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
23+
<p class="margin"> client_id&nbsp;&nbsp;(<span class="paratype">int(11)</span>)</p>
24+
<p class="headgrp">Output: </p>
25+
<p class="margin"> Returns the number of affected rows.</p>
26+
<!--<b>Output:</b>
27+
<p style="margin-left:100px">Gives a record of </p> -->
28+
</div>
29+
30+
</body></html>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
require 'soap_config.php';
4+
5+
6+
$client = new SoapClient(null, array('location' => $soap_location,
7+
'uri' => $soap_uri,
8+
'trace' => 1,
9+
'exceptions' => 1));
10+
11+
12+
try {
13+
if($session_id = $client->login($username, $password)) {
14+
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
15+
}
16+
17+
//* Set the function parameters.
18+
$client_id = 1;
19+
$primary_id = 42; // The domain_id
20+
$params = array(
21+
'domain' => 'cellar.door'
22+
);
23+
24+
$result = $client->domains_domain_update($session_id, $client_id, $primary_id, $params);
25+
26+
if ($result) {
27+
echo 'Domain updated.<br />';
28+
}
29+
if ($client->logout($session_id)) {
30+
echo 'Logged out.<br />';
31+
}
32+
33+
34+
} catch (SoapFault $e) {
35+
echo $client->__getLastResponse();
36+
die('SOAP Error: '.$e->getMessage());
37+
}
38+
39+
?>

0 commit comments

Comments
 (0)