Commit a5796fc0 authored by Till Brehm's avatar Till Brehm

Merge branch 'domains_domain_update-3.1' into 'stable-3.1'

Add domains domain update API function

See merge request !845
parents 7bd740fa c6320660
......@@ -65,6 +65,16 @@ class remoting_domains extends remoting {
return $this->insertQuery('../client/form/domain.tform.php', $client_id, $params);
}
//* Update a record
public function domains_domain_update($session_id, $client_id, $primary_id, $params)
{
if(!$this->checkPerm($session_id, 'domains_domain_update')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
return $this->updateQuery('../client/form/domain.tform.php', $client_id, $primary_id, $params);
}
//* Delete a record
public function domains_domain_delete($session_id, $primary_id)
{
......
......@@ -383,7 +383,7 @@ class remoting {
$app->remoting_lib->loadFormDef($formdef_file);
//* get old record and merge with params, so only new values have to be set in $params
$old_rec = $app->remoting_lib->getDataRecord($primary_id);
$old_rec = $app->remoting_lib->getDataRecord($primary_id, $client_id);
foreach ($app->remoting_lib->formDef['fields'] as $fieldName => $fieldConf)
{
......
......@@ -225,10 +225,10 @@ class remoting_lib extends tform_base {
return $sql;
}
function getDataRecord($primary_id) {
function getDataRecord($primary_id, $client_id = 0) {
global $app;
$escape = '`';
$this->loadUserProfile();
$this->loadUserProfile($client_id);
if(@is_numeric($primary_id)) {
if($primary_id > 0) {
// Return a single record
......
......@@ -1384,7 +1384,7 @@ class tform_base {
} else {
if($this->formDef['auth'] == 'yes') {
if($primary_id != 0) {
if($api == true && $_SESSION["s"]["user"]["client_id"] > 0 && $_SESSION["s"]["user"]["iserid"] > 0 && $_SESSION["s"]["user"]["default_group"] > 0) {
if($api == true && $_SESSION["s"]["user"]["client_id"] > 0 && $_SESSION["s"]["user"]["userid"] > 0 && $_SESSION["s"]["user"]["default_group"] > 0) {
$sql_update .= '`sys_userid` = '.$this->sys_userid.', ';
$sql_update .= '`sys_groupid` = '.$this->sys_default_group.', ';
}
......
<?php
$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';
$function_list['domains_domain_get,domains_domain_add,domains_domain_delete,domains_get_all_by_user'] = 'Domaintool functions';
$function_list['domains_domain_get,domains_domain_add,domains_domain_update,domains_domain_delete,domains_get_all_by_user'] = 'Domaintool functions';
$function_list['quota_get_by_user,trafficquota_get_by_user,mailquota_get_by_user,databasequota_get_by_user'] = 'Quota functions';
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>ISPCOnfig 3 remote API documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="definitionen.css">
<style type="text/css">
</style></head>
<body>
<div style="padding:40px">
<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>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Updates domain to move it to another client.</p><br>
<p class="headgrp">Input Variables: </p>
<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>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin"> domain&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
<p class="margin"> client_id&nbsp;&nbsp;(<span class="paratype">int(11)</span>)</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns the number of affected rows.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<?php
require 'soap_config.php';
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri,
'trace' => 1,
'exceptions' => 1));
try {
if($session_id = $client->login($username, $password)) {
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
}
//* Set the function parameters.
$client_id = 1;
$primary_id = 42; // The domain_id
$params = array(
'domain' => 'cellar.door'
);
$result = $client->domains_domain_update($session_id, $client_id, $primary_id, $params);
if ($result) {
echo 'Domain updated.<br />';
}
if ($client->logout($session_id)) {
echo 'Logged out.<br />';
}
} catch (SoapFault $e) {
echo $client->__getLastResponse();
die('SOAP Error: '.$e->getMessage());
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment