From 54c57f30a7398dd7b83da9e42f93bcf95275ffd1 Mon Sep 17 00:00:00 2001 From: Demian Date: Tue, 25 Oct 2022 14:21:09 +0200 Subject: [PATCH 1/7] add mail_relay_domain_add function to remote api. #6399 --- interface/lib/classes/remote.d/mail.inc.php | 44 +++++++++++++-------- interface/web/mail/lib/remote.conf.php | 1 + 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php index dfbad27595..d5d892f155 100644 --- a/interface/lib/classes/remote.d/mail.inc.php +++ b/interface/lib/classes/remote.d/mail.inc.php @@ -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,19 @@ 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; + } + //* Get spamfilter whitelist details public function mail_spamfilter_whitelist_get($session_id, $primary_id) { @@ -1117,12 +1129,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); } diff --git a/interface/web/mail/lib/remote.conf.php b/interface/web/mail/lib/remote.conf.php index 3060a8b4cc..faf1d5aa29 100644 --- a/interface/web/mail/lib/remote.conf.php +++ b/interface/web/mail/lib/remote.conf.php @@ -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 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'; -- GitLab From 745b40872c25eb39ee35e43998b80c2c5c6ad6a0 Mon Sep 17 00:00:00 2001 From: Demian Date: Tue, 25 Oct 2022 14:25:44 +0200 Subject: [PATCH 2/7] add documentation and example for new mail_relay_domain_add api function #6399 --- .../API-docs/mail_relay_domain_add.html | 32 +++++++++++++++ .../examples/mail_relay_domain_add.php | 40 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 remoting_client/API-docs/mail_relay_domain_add.html create mode 100644 remoting_client/examples/mail_relay_domain_add.php diff --git a/remoting_client/API-docs/mail_relay_domain_add.html b/remoting_client/API-docs/mail_relay_domain_add.html new file mode 100644 index 0000000000..1c37a96ab9 --- /dev/null +++ b/remoting_client/API-docs/mail_relay_domain_add.html @@ -0,0 +1,32 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

mail_relay_domain_add($session_id, $client_id, $params);

+
+

Description:

+

Adds a new relay domain.


+

Input Variables:

+

$session_id, $client_id, $params

+

Parameters (in $params):

+

server_id  (int(11))

+

source  Recipient address (varchar(255))

+

active  (enum('n','y'))

+

access  (varchar(255))

+

Output:

+

Returns the ID of the newly added record

+ +
+ + diff --git a/remoting_client/examples/mail_relay_domain_add.php b/remoting_client/examples/mail_relay_domain_add.php new file mode 100644 index 0000000000..06f82b0e00 --- /dev/null +++ b/remoting_client/examples/mail_relay_domain_add.php @@ -0,0 +1,40 @@ + $soap_location, + 'uri' => $soap_uri, + 'trace' => 1, + 'exceptions' => 1)); + + +try { + if($session_id = $client->login($username, $password)) { + echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + + //* 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."
"; + + if($client->logout($session_id)) { + echo 'Logged out.
'; + } + + +} catch (SoapFault $e) { + echo $client->__getLastResponse(); + die('SOAP Error: '.$e->getMessage()); +} + +?> -- GitLab From a518a30d4d98184c11296b459705af8bc3e91a66 Mon Sep 17 00:00:00 2001 From: Demian Date: Thu, 27 Oct 2022 10:35:11 +0200 Subject: [PATCH 3/7] add mail_relay_domain_delete function to remote api #6399 add documentation and example for mail_relay_domain_delete function #6399 --- interface/lib/classes/remote.d/mail.inc.php | 11 ++++++ interface/web/mail/lib/remote.conf.php | 2 +- .../API-docs/mail_relay_domain_delete.html | 29 ++++++++++++++++ .../examples/mail_relay_domain_delete.php | 34 +++++++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 remoting_client/API-docs/mail_relay_domain_delete.html create mode 100644 remoting_client/examples/mail_relay_domain_delete.php diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php index d5d892f155..4de37613b6 100644 --- a/interface/lib/classes/remote.d/mail.inc.php +++ b/interface/lib/classes/remote.d/mail.inc.php @@ -679,6 +679,17 @@ class remoting_mail extends remoting { 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; + } + //* Get spamfilter whitelist details public function mail_spamfilter_whitelist_get($session_id, $primary_id) { diff --git a/interface/web/mail/lib/remote.conf.php b/interface/web/mail/lib/remote.conf.php index faf1d5aa29..bc9f8b27d5 100644 --- a/interface/web/mail/lib/remote.conf.php +++ b/interface/web/mail/lib/remote.conf.php @@ -9,7 +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 functions'; +$function_list['mail_relay_domain_add,mail_relay_domain_delete'] = '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'; diff --git a/remoting_client/API-docs/mail_relay_domain_delete.html b/remoting_client/API-docs/mail_relay_domain_delete.html new file mode 100644 index 0000000000..c2af410d90 --- /dev/null +++ b/remoting_client/API-docs/mail_relay_domain_delete.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

mail_domain_delete($session_id, $primary_id);

+
+

Description:

+

Deletes a mail domain.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns the number of deleted records.

+ +
+ + diff --git a/remoting_client/examples/mail_relay_domain_delete.php b/remoting_client/examples/mail_relay_domain_delete.php new file mode 100644 index 0000000000..60dd49c4af --- /dev/null +++ b/remoting_client/examples/mail_relay_domain_delete.php @@ -0,0 +1,34 @@ + $soap_location, + 'uri' => $soap_uri, + 'trace' => 1, + 'exceptions' => 1)); + + +try { + if($session_id = $client->login($username, $password)) { + echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + + //* 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."
"; + + if($client->logout($session_id)) { + echo 'Logged out.
'; + } + + +} catch (SoapFault $e) { + echo $client->__getLastResponse(); + die('SOAP Error: '.$e->getMessage()); +} + +?> -- GitLab From ed40da27d834898bc7049000056892c40ebae978 Mon Sep 17 00:00:00 2001 From: Demian Date: Thu, 27 Oct 2022 12:00:03 +0200 Subject: [PATCH 4/7] add mail_relay_domain_get function to remote api. #6399 --- interface/lib/classes/remote.d/mail.inc.php | 12 ++++++++++++ interface/web/mail/lib/remote.conf.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php index 4de37613b6..1e94dcd85f 100644 --- a/interface/lib/classes/remote.d/mail.inc.php +++ b/interface/lib/classes/remote.d/mail.inc.php @@ -690,6 +690,18 @@ class remoting_mail extends remoting { return $affected_rows; } + public function mail_relay_domain_get($session_id, $primary_id) + { + 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); + } + //* Get spamfilter whitelist details public function mail_spamfilter_whitelist_get($session_id, $primary_id) { diff --git a/interface/web/mail/lib/remote.conf.php b/interface/web/mail/lib/remote.conf.php index bc9f8b27d5..ec8adf80fb 100644 --- a/interface/web/mail/lib/remote.conf.php +++ b/interface/web/mail/lib/remote.conf.php @@ -9,7 +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 functions'; +$function_list['mail_relay_domain_add,mail_relay_domain_delete,mail_relay_domain_get'] = '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'; -- GitLab From 679f9eb2c7d720f5eb351832377ddfb521fd97e5 Mon Sep 17 00:00:00 2001 From: Demian Date: Thu, 3 Nov 2022 09:34:49 +0100 Subject: [PATCH 5/7] Fixed mail_relay_domain_get; Added mail_relay_domain_update #6399 --- interface/lib/classes/remote.d/mail.inc.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php index 1e94dcd85f..2d26b1969f 100644 --- a/interface/lib/classes/remote.d/mail.inc.php +++ b/interface/lib/classes/remote.d/mail.inc.php @@ -692,6 +692,8 @@ class remoting_mail extends remoting { 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.'); @@ -702,6 +704,17 @@ class remoting_mail extends remoting { 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) { -- GitLab From 5b95bd9c74e06833f69ebff7de8617f601fdb8f7 Mon Sep 17 00:00:00 2001 From: Demian Date: Thu, 3 Nov 2022 09:46:08 +0100 Subject: [PATCH 6/7] Fixed and added documentation for mail_relay_domain_* functions --- .../API-docs/mail_relay_domain_add.html | 2 +- .../API-docs/mail_relay_domain_get.html | 29 +++++++++++++ .../API-docs/mail_relay_domain_update.html | 32 +++++++++++++++ .../examples/mail_relay_domain_get.php | 34 +++++++++++++++ .../examples/mail_relay_domain_update.php | 41 +++++++++++++++++++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 remoting_client/API-docs/mail_relay_domain_get.html create mode 100644 remoting_client/API-docs/mail_relay_domain_update.html create mode 100644 remoting_client/examples/mail_relay_domain_get.php create mode 100644 remoting_client/examples/mail_relay_domain_update.php diff --git a/remoting_client/API-docs/mail_relay_domain_add.html b/remoting_client/API-docs/mail_relay_domain_add.html index 1c37a96ab9..cb2beb5ec6 100644 --- a/remoting_client/API-docs/mail_relay_domain_add.html +++ b/remoting_client/API-docs/mail_relay_domain_add.html @@ -20,7 +20,7 @@

$session_id, $client_id, $params

Parameters (in $params):

server_id  (int(11))

-

source  Recipient address (varchar(255))

+

source  (varchar(255))

active  (enum('n','y'))

access  (varchar(255))

Output:

diff --git a/remoting_client/API-docs/mail_relay_domain_get.html b/remoting_client/API-docs/mail_relay_domain_get.html new file mode 100644 index 0000000000..e9e03d80d6 --- /dev/null +++ b/remoting_client/API-docs/mail_relay_domain_get.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

mail_relay_domain_get($session_id, $primary_id);

+
+

Description:

+

Retrieves information about a relay domain.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns all fields and values of the chosen relay domain.

+ +
+ + diff --git a/remoting_client/API-docs/mail_relay_domain_update.html b/remoting_client/API-docs/mail_relay_domain_update.html new file mode 100644 index 0000000000..d755f5781d --- /dev/null +++ b/remoting_client/API-docs/mail_relay_domain_update.html @@ -0,0 +1,32 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

mail_relay_domain_update($session_id, $client_id, $primary_id, $params);

+
+Description: +

Updates a relay domain.


+Input Variables: +

$session_id, $client_id, $primary_id, $params

+Parameters (in $params): +

server_id  (int(11))

+

source  (varchar(255))

+

active  (enum('n','y'))

+

access  (varchar(255))

+Output: +

Returns the number of affected rows.

+ +
+ + diff --git a/remoting_client/examples/mail_relay_domain_get.php b/remoting_client/examples/mail_relay_domain_get.php new file mode 100644 index 0000000000..509a1993ed --- /dev/null +++ b/remoting_client/examples/mail_relay_domain_get.php @@ -0,0 +1,34 @@ + $soap_location, + 'uri' => $soap_uri, + 'trace' => 1, + 'exceptions' => 1)); + + +try { + if($session_id = $client->login($username, $password)) { + echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + + //* 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.
'; + } + + +} catch (SoapFault $e) { + echo $client->__getLastResponse(); + die('SOAP Error: '.$e->getMessage()); +} + +?> diff --git a/remoting_client/examples/mail_relay_domain_update.php b/remoting_client/examples/mail_relay_domain_update.php new file mode 100644 index 0000000000..7c42946474 --- /dev/null +++ b/remoting_client/examples/mail_relay_domain_update.php @@ -0,0 +1,41 @@ + $soap_location, + 'uri' => $soap_uri, + 'trace' => 1, + 'exceptions' => 1)); + + +try { + if($session_id = $client->login($username, $password)) { + echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + + //* 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."
"; + + if($client->logout($session_id)) { + echo 'Logged out.
'; + } + + +} catch (SoapFault $e) { + echo $client->__getLastResponse(); + die('SOAP Error: '.$e->getMessage()); +} + +?> -- GitLab From 78ebd62da33bddbad8096d5455750c7c51788a29 Mon Sep 17 00:00:00 2001 From: Demian Date: Thu, 3 Nov 2022 10:13:39 +0100 Subject: [PATCH 7/7] remote.conf.php: fixed $function_list for mail_relay_domain_* #6399 --- interface/web/mail/lib/remote.conf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/web/mail/lib/remote.conf.php b/interface/web/mail/lib/remote.conf.php index ec8adf80fb..38f57fcf19 100644 --- a/interface/web/mail/lib/remote.conf.php +++ b/interface/web/mail/lib/remote.conf.php @@ -9,7 +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 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'; -- GitLab