From 5e18b299fdf51f5ee259ba54a7d6b21462b6cef1 Mon Sep 17 00:00:00 2001
From: Branislav Viest <info@branoviest.com>
Date: Wed, 13 Dec 2017 14:47:55 +0100
Subject: [PATCH] New API functions: mail_catchall_get_all, mail_user_get_all,
 sites_database_user_get_by_name, sites_web_domainid_get

---
 interface/lib/classes/remote.d/mail.inc.php  | 33 ++++++++++++++++++++++++++--
 interface/lib/classes/remote.d/sites.inc.php | 30 +++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php
index bda7e86..ce8eaf2 100644
--- a/interface/lib/classes/remote.d/mail.inc.php
+++ b/interface/lib/classes/remote.d/mail.inc.php
@@ -182,6 +182,35 @@ class remoting_mail extends remoting {
 		return $affected_rows;
 	}
 
+	//* Get all mail users 
+	public function mail_user_get_all($session_id, $client_id) {
+		global $app;
+
+		if(!$this->checkPerm($session_id, 'mail_user_get')) {
+				$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+				return false;
+		}
+
+		$sql = "SELECT * FROM mail_user LEFT JOIN sys_user ON sys_user.userid = mail_user.sys_userid WHERE sys_user.client_id='$client_id'";
+		$all = $app->db->queryAllRecords($sql);
+		return $all;
+
+	}
+
+	//* Get all catchalls 
+	public function mail_catchall_get_all($session_id, $client_id) {
+		global $app;
+
+		if(!$this->checkPerm($session_id, 'mail_catchall_get')) {
+			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+			return false;
+		}
+
+		$sql = "SELECT * FROM mail_forwarding LEFT JOIN sys_user ON sys_user.userid = mail_forwarding.sys_userid WHERE sys_user.client_id='$client_id' AND mail_forwarding.type='catchall'";
+		$all = $app->db->queryAllRecords($sql);
+		return $all;
+	}
+
 	//* Get mail user details
 	public function mail_user_get($session_id, $primary_id)
 	{
@@ -311,7 +340,7 @@ class remoting_mail extends remoting {
 		return $affected_rows;
 	}
 	
-	// Mail backup list function by Dominik M�ller, info@profi-webdesign.net
+	// 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;
@@ -334,7 +363,7 @@ class remoting_mail extends remoting {
 		return $result;
 	}
 	
-	// Mail backup restore/download functions by Dominik M�ller, info@profi-webdesign.net
+	// 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;
diff --git a/interface/lib/classes/remote.d/sites.inc.php b/interface/lib/classes/remote.d/sites.inc.php
index a2f15d6..cc7a2ec 100644
--- a/interface/lib/classes/remote.d/sites.inc.php
+++ b/interface/lib/classes/remote.d/sites.inc.php
@@ -395,6 +395,21 @@ class remoting_sites extends remoting {
 
 	// ----------------------------------------------------------------------------------------------------------
 
+	//* Get domain id
+	public function sites_web_domainid_get($session_id, $domain) 
+	{
+			global $app;
+
+			if(!$this->checkPerm($session_id, 'sites_web_domain_get')) {
+					throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
+					return false;
+			}
+
+			$sql = "SELECT domain_id FROM web_domain WHERE domain='$domain'";
+			$all = $app->db->queryOneRecord($sql);
+			return $all['domain_id'];
+	}
+
 	//* Get record details
 	public function sites_web_domain_get($session_id, $primary_id)
 	{
@@ -885,6 +900,21 @@ class remoting_sites extends remoting {
 		}
 	}
 
+	//* Get Database user id by username
+	public function sites_database_user_get_by_name($session_id, $dbuser) 
+	{
+			global $app;
+
+			if(!$this->checkPerm($session_id, 'sites_database_add')) {
+					throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
+					return false;
+			}
+
+			$sql = "SELECT database_user_id FROM web_database_user WHERE database_user='$dbuser'";
+			$res = $app->db->queryOneRecord($sql);
+			return $res['database_user_id'];
+	}
+
 	/**
 	 * Get all databases by user
 	 * @author Julio Montoya <gugli100@gmail.com> BeezNest 2010
-- 
2.7.4

