Skip to content

Commit 07186a8

Browse files
author
Till Brehm
committed
Merge branch '6399-mail-relay-domain-functions' into 'develop'
add mail_relay_domain API functions #6399 See merge request ispconfig/ispconfig3!1644
2 parents 9537723 + 78ebd62 commit 07186a8

File tree

10 files changed

+336
-16
lines changed

10 files changed

+336
-16
lines changed

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

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function mail_user_add($session_id, $client_id, $params){
223223
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
224224
return false;
225225
}
226-
226+
227227
// Email addresses must always be lower case
228228
$params['email'] = strtolower($params['email']);
229229

@@ -331,17 +331,17 @@ public function mail_user_filter_delete($session_id, $primary_id)
331331
// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
332332
return $affected_rows;
333333
}
334-
334+
335335
// Mail backup list function by Dominik Müller, info@profi-webdesign.net
336336
public function mail_user_backup_list($session_id, $primary_id = null)
337337
{
338338
global $app;
339-
339+
340340
if(!$this->checkPerm($session_id, 'mail_user_backup')) {
341341
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
342342
return false;
343343
}
344-
344+
345345
$params = array();
346346
if ($site_id != null) {
347347
$params[] = $site_id;
@@ -350,47 +350,47 @@ public function mail_user_backup_list($session_id, $primary_id = null)
350350
else {
351351
$sql = "SELECT * FROM mail_backup";
352352
}
353-
353+
354354
$result = $app->db->queryAllRecords($sql, true, $params);
355355
return $result;
356356
}
357-
357+
358358
// Mail backup restore/download functions by Dominik Müller, info@profi-webdesign.net
359359
public function mail_user_backup($session_id, $primary_id, $action_type)
360360
{
361361
global $app;
362-
362+
363363
if(!$this->checkPerm($session_id, 'mail_user_backup')) {
364364
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
365365
return false;
366366
}
367-
367+
368368
//*Set variables
369369
$backup_record = $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`=?", $primary_id);
370370
$server_id = $backup_record['server_id'];
371-
371+
372372
//*Set default action state
373373
$action_state = "pending";
374374
$tstamp = time();
375-
375+
376376
//* Basic validation of variables
377377
if ($server_id <= 0) {
378378
throw new SoapFault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
379379
return false;
380380
}
381-
381+
382382
if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail' and $action_type != 'backup_delete_mail') {
383383
throw new SoapFault('invalid_action', "Invalid action_type $action_type");
384384
return false;
385385
}
386-
386+
387387
//* Validate instance
388388
$instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`=? and `action_type`=? and `action_state`='pending'", $primary_id, $action_type);
389389
if ($instance_record['action_id'] >= 1) {
390390
throw new SoapFault('duplicate_action', "There is already a pending $action_type action");
391391
return false;
392392
}
393-
393+
394394
//* Save the record
395395
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)) {
396396
return true;
@@ -666,7 +666,55 @@ public function mail_relay_recipient_delete($session_id, $primary_id)
666666
$affected_rows = $this->deleteQuery('../mail/form/mail_relay_recipient.tform.php', $primary_id);
667667
return $affected_rows;
668668
}
669-
669+
670+
//* add relay domain
671+
public function mail_relay_domain_add($session_id, $client_id, $params)
672+
{
673+
if(!$this->checkPerm($session_id, 'mail_relay_add'))
674+
{
675+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
676+
return false;
677+
}
678+
$affected_rows = $this->insertQuery('../mail/form/mail_relay_domain.tform.php', $client_id, $params);
679+
return $affected_rows;
680+
}
681+
682+
public function mail_relay_domain_delete($session_id, $primary_id)
683+
{
684+
if(!$this->checkPerm($session_id, 'mail_relay_delete'))
685+
{
686+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
687+
return false;
688+
}
689+
$affected_rows = $this->deleteQuery('../mail/form/mail_relay_domain.tform.php', $primary_id);
690+
return $affected_rows;
691+
}
692+
693+
public function mail_relay_domain_get($session_id, $primary_id)
694+
{
695+
global $app;
696+
697+
if(!$this->checkPerm($session_id, 'mail_relay_get'))
698+
{
699+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
700+
return false;
701+
}
702+
$app->uses('remoting_lib');
703+
$app->remoting_lib->loadFormDef('../mail/form/mail_relay_domain.tform.php');
704+
return $app->remoting_lib->getDataRecord($primary_id);
705+
}
706+
707+
public function mail_relay_domain_update($session_id, $client_id, $primary_id, $params)
708+
{
709+
if(!$this->checkPerm($session_id, 'mail_relay_update'))
710+
{
711+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
712+
return false;
713+
}
714+
$affected_rows = $this->updateQuery('../mail/form/mail_relay_domain.tform.php', $client_id, $primary_id, $params);
715+
return $affected_rows;
716+
}
717+
670718
//* Get spamfilter whitelist details
671719
public function mail_spamfilter_whitelist_get($session_id, $primary_id)
672720
{
@@ -1117,12 +1165,12 @@ public function mailquota_get_by_user($session_id, $client_id)
11171165
{
11181166
global $app;
11191167
$app->uses('quota_lib');
1120-
1168+
11211169
if(!$this->checkPerm($session_id, 'mailquota_get_by_user')) {
11221170
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
11231171
return false;
11241172
}
1125-
1173+
11261174
return $app->quota_lib->get_mailquota_data($client_id, false);
11271175
}
11281176

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
$function_list['mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions';
1010
$function_list['mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions';
1111
$function_list['mail_relay_get,mail_relay_add,mail_relay_update,mail_relay_delete'] = 'Mail relay functions';
12+
$function_list['mail_relay_domain_add,mail_relay_domain_delete,mail_relay_domain_get,mail_relay_domain_update'] = 'Mail relay domain functions';
1213
$function_list['mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions';
1314
$function_list['mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions';
1415
$function_list['mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user functions';
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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>mail_relay_domain_add(<span class="var">$session_id</span>, <span class="var">$client_id</span>, <span class="var">$params</span>);</h1>
16+
<br>
17+
<p class="headgrp">Description: </p>
18+
<p class="margin"> Adds a new relay domain.</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">$params</span></p>
21+
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
22+
<p class="margin"> server_id&nbsp;&nbsp;(<span class="paratype">int(11)</span>)</p>
23+
<p class="margin"> source&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
24+
<p class="margin"> active&nbsp;&nbsp;(<span class="paratype">enum('n','y')</span>)</p>
25+
<p class="margin"> access&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
26+
<p class="headgrp">Output: </p>
27+
<p class="margin"> Returns the ID of the newly added record</p>
28+
<!--<b>Output:</b>
29+
<p style="margin-left:100px">Gives a record of </p> -->
30+
</div>
31+
32+
</body></html>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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>mail_domain_delete(<span class="var">$session_id</span>, <span class="var">$primary_id</span>);</h1>
16+
<br>
17+
<p class="headgrp">Description: </p>
18+
<p class="margin"> Deletes a mail domain.</p><br>
19+
<p class="headgrp">Input Variables: </p>
20+
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span></p>
21+
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
22+
<p class="margin">None</p>
23+
<p class="headgrp">Output: </p>
24+
<p class="margin"> Returns the number of deleted records.</p>
25+
<!--<b>Output:</b>
26+
<p style="margin-left:100px">Gives a record of </p> -->
27+
</div>
28+
29+
</body></html>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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>mail_relay_domain_get(<span class="var">$session_id</span>, <span class="var">$primary_id</span>);</h1>
16+
<br>
17+
<p class="headgrp">Description: </p>
18+
<p class="margin"> Retrieves information about a relay domain.</p><br>
19+
<p class="headgrp">Input Variables: </p>
20+
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span></p>
21+
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
22+
<p class="margin"> None</p>
23+
<p class="headgrp">Output: </p>
24+
<p class="margin"> Returns all fields and values of the chosen relay domain.</p>
25+
<!--<b>Output:</b>
26+
<p style="margin-left:100px">Gives a record of </p> -->
27+
</div>
28+
29+
</body></html>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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>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>
16+
<br>
17+
<b>Description: </b>
18+
<p class="margin"> Updates a relay domain.</p><br>
19+
<b>Input Variables: </b>
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+
<b>Parameters (in <span class="var">$params</span>): </b>
22+
<p class="margin"> server_id&nbsp;&nbsp;(<span class="paratype">int(11)</span>)</p>
23+
<p class="margin"> source&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
24+
<p class="margin"> active&nbsp;&nbsp;(<span class="paratype">enum('n','y')</span>)</p>
25+
<p class="margin"> access&nbsp;&nbsp;(<span class="paratype">varchar(255)</span>)</p>
26+
<b>Output: </b>
27+
<p class="margin"> Returns the number of affected rows.</p>
28+
<!--<b>Output:</b>
29+
<p style="margin-left:100px">Gives a record of </p> -->
30+
</div>
31+
32+
</body></html>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
$params = array(
20+
'server_id' => 1,
21+
'domain' => 'test.tld',
22+
'active' => 'y',
23+
'access' => 'OK'
24+
);
25+
26+
$relay_domain_id = $client->mail_relay_domain_add($session_id, $client_id, $params);
27+
28+
echo "Relay domain ID: ".$relay_domain_id."<br>";
29+
30+
if($client->logout($session_id)) {
31+
echo 'Logged out.<br />';
32+
}
33+
34+
35+
} catch (SoapFault $e) {
36+
echo $client->__getLastResponse();
37+
die('SOAP Error: '.$e->getMessage());
38+
}
39+
40+
?>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
$mail_relay_domain_id = 3;
19+
20+
$affected_rows = $client->mail_relay_domain_delete($session_id, $mail_relay_domain_id);
21+
22+
echo "Number of records that have been deleted: ".$affected_rows."<br>";
23+
24+
if($client->logout($session_id)) {
25+
echo 'Logged out.<br />';
26+
}
27+
28+
29+
} catch (SoapFault $e) {
30+
echo $client->__getLastResponse();
31+
die('SOAP Error: '.$e->getMessage());
32+
}
33+
34+
?>

0 commit comments

Comments
 (0)