Commit 07186a8c authored by Till Brehm's avatar Till Brehm
Browse files

Merge branch '6399-mail-relay-domain-functions' into 'develop'

add mail_relay_domain API functions #6399

See merge request !1644
parents 95377233 78ebd62d
Pipeline #12750 passed with stage
in 9 seconds
......@@ -223,7 +223,7 @@ class remoting_mail extends remoting {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// Email addresses must always be lower case
$params['email'] = strtolower($params['email']);
......@@ -331,17 +331,17 @@ class remoting_mail extends remoting {
// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
return $affected_rows;
}
// Mail backup list function by Dominik Müller, info@profi-webdesign.net
public function mail_user_backup_list($session_id, $primary_id = null)
{
global $app;
if(!$this->checkPerm($session_id, 'mail_user_backup')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$params = array();
if ($site_id != null) {
$params[] = $site_id;
......@@ -350,47 +350,47 @@ class remoting_mail extends remoting {
else {
$sql = "SELECT * FROM mail_backup";
}
$result = $app->db->queryAllRecords($sql, true, $params);
return $result;
}
// Mail backup restore/download functions by Dominik Müller, info@profi-webdesign.net
public function mail_user_backup($session_id, $primary_id, $action_type)
{
global $app;
if(!$this->checkPerm($session_id, 'mail_user_backup')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
//*Set variables
$backup_record = $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`=?", $primary_id);
$server_id = $backup_record['server_id'];
//*Set default action state
$action_state = "pending";
$tstamp = time();
//* Basic validation of variables
if ($server_id <= 0) {
throw new SoapFault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
return false;
}
if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail' and $action_type != 'backup_delete_mail') {
throw new SoapFault('invalid_action', "Invalid action_type $action_type");
return false;
}
//* Validate instance
$instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`=? and `action_type`=? and `action_state`='pending'", $primary_id, $action_type);
if ($instance_record['action_id'] >= 1) {
throw new SoapFault('duplicate_action', "There is already a pending $action_type action");
return false;
}
//* Save the record
if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) {
return true;
......@@ -666,7 +666,55 @@ class remoting_mail extends remoting {
$affected_rows = $this->deleteQuery('../mail/form/mail_relay_recipient.tform.php', $primary_id);
return $affected_rows;
}
//* add relay domain
public function mail_relay_domain_add($session_id, $client_id, $params)
{
if(!$this->checkPerm($session_id, 'mail_relay_add'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->insertQuery('../mail/form/mail_relay_domain.tform.php', $client_id, $params);
return $affected_rows;
}
public function mail_relay_domain_delete($session_id, $primary_id)
{
if(!$this->checkPerm($session_id, 'mail_relay_delete'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->deleteQuery('../mail/form/mail_relay_domain.tform.php', $primary_id);
return $affected_rows;
}
public function mail_relay_domain_get($session_id, $primary_id)
{
global $app;
if(!$this->checkPerm($session_id, 'mail_relay_get'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$app->uses('remoting_lib');
$app->remoting_lib->loadFormDef('../mail/form/mail_relay_domain.tform.php');
return $app->remoting_lib->getDataRecord($primary_id);
}
public function mail_relay_domain_update($session_id, $client_id, $primary_id, $params)
{
if(!$this->checkPerm($session_id, 'mail_relay_update'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->updateQuery('../mail/form/mail_relay_domain.tform.php', $client_id, $primary_id, $params);
return $affected_rows;
}
//* Get spamfilter whitelist details
public function mail_spamfilter_whitelist_get($session_id, $primary_id)
{
......@@ -1117,12 +1165,12 @@ class remoting_mail extends remoting {
{
global $app;
$app->uses('quota_lib');
if(!$this->checkPerm($session_id, 'mailquota_get_by_user')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
return $app->quota_lib->get_mailquota_data($client_id, false);
}
......
......@@ -9,6 +9,7 @@ $function_list['mail_forward_get,mail_forward_add,mail_forward_update,mail_forwa
$function_list['mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions';
$function_list['mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions';
$function_list['mail_relay_get,mail_relay_add,mail_relay_update,mail_relay_delete'] = 'Mail relay functions';
$function_list['mail_relay_domain_add,mail_relay_domain_delete,mail_relay_domain_get,mail_relay_domain_update'] = 'Mail relay domain functions';
$function_list['mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions';
$function_list['mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions';
$function_list['mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user 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>mail_relay_domain_add(<span class="var">$session_id</span>, <span class="var">$client_id</span>, <span class="var">$params</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Adds a new relay domain.</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">$params</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin"> server_id&nbsp;&nbsp;(<span class="paratype">int(11)</span>)</p>
<p class="margin"> source&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
<p class="margin"> active&nbsp;&nbsp;(<span class="paratype">enum('n','y')</span>)</p>
<p class="margin"> access&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns the ID of the newly added record</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<!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>mail_domain_delete(<span class="var">$session_id</span>, <span class="var">$primary_id</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Deletes a mail domain.</p><br>
<p class="headgrp">Input Variables: </p>
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin">None</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns the number of deleted records.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<!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>mail_relay_domain_get(<span class="var">$session_id</span>, <span class="var">$primary_id</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Retrieves information about a relay domain.</p><br>
<p class="headgrp">Input Variables: </p>
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin"> None</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns all fields and values of the chosen relay domain.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<!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>mail_relay_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>
<b>Description: </b>
<p class="margin"> Updates a relay domain.</p><br>
<b>Input Variables: </b>
<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>
<b>Parameters (in <span class="var">$params</span>): </b>
<p class="margin"> server_id&nbsp;&nbsp;(<span class="paratype">int(11)</span>)</p>
<p class="margin"> source&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
<p class="margin"> active&nbsp;&nbsp;(<span class="paratype">enum('n','y')</span>)</p>
<p class="margin"> access&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
<b>Output: </b>
<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;
$params = array(
'server_id' => 1,
'domain' => 'test.tld',
'active' => 'y',
'access' => 'OK'
);
$relay_domain_id = $client->mail_relay_domain_add($session_id, $client_id, $params);
echo "Relay domain ID: ".$relay_domain_id."<br>";
if($client->logout($session_id)) {
echo 'Logged out.<br />';
}
} catch (SoapFault $e) {
echo $client->__getLastResponse();
die('SOAP Error: '.$e->getMessage());
}
?>
<?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.
$mail_relay_domain_id = 3;
$affected_rows = $client->mail_relay_domain_delete($session_id, $mail_relay_domain_id);
echo "Number of records that have been deleted: ".$affected_rows."<br>";
if($client->logout($session_id)) {
echo 'Logged out.<br />';
}
} catch (SoapFault $e) {
echo $client->__getLastResponse();
die('SOAP Error: '.$e->getMessage());
}
?>
<?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.
$relay_domain_id = 1;
// Lookup by primary key, gets back a single record.
$relay_domain = $client->mail_relay_domain_get($session_id, $relay_domain_id);
print_r($relay_domain);
if($client->logout($session_id)) {
echo 'Logged out.<br />';
}
} catch (SoapFault $e) {
echo $client->__getLastResponse();
die('SOAP Error: '.$e->getMessage());
}
?>
<?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 = 1;
$params = array(
'server_id' => 1,
'domain' => 'test.tld',
'active' => 'y',
'access' => 'OK'
);
$affected_rows = $client->mail_relay_domain_update($session_id, $client_id, $primary_id, $params);
echo "Affected Rows: ".$affected_rows."<br>";
if($client->logout($session_id)) {
echo 'Logged out.<br />';
}
} catch (SoapFault $e) {
echo $client->__getLastResponse();
die('SOAP Error: '.$e->getMessage());
}
?>
Supports Markdown
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