From 9d4bb8679bd2ef0934ac94ae3ccedc864c0078cc Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Mon, 02 Mar 2015 11:58:49 -0500
Subject: [PATCH] Merge branch 'master' of git.ispconfig.org:ispconfig/ispconfig3

---
 interface/lib/classes/remote.d/mail.inc.php |   66 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 1 deletions(-)

diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php
index d97f575..29ff0d8 100644
--- a/interface/lib/classes/remote.d/mail.inc.php
+++ b/interface/lib/classes/remote.d/mail.inc.php
@@ -309,6 +309,71 @@
 		// $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')) {
+			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+			return false;
+		}
+	
+		if ($site_id != null) {
+			$sql  = "SELECT * FROM mail_backup WHERE parent_domain_id = ".$app->functions->intval($site_id);
+		}
+		else {
+			$sql  = "SELECT * FROM mail_backup";
+		}
+	
+		$result = $app->db->queryAllRecords($sql);
+		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')) {
+			$this->server->fault('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) {
+			$this->server->fault('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') {
+			$this->server->fault('invalid_action', "Invalid action_type $action_type");
+			return false;
+		}
+	
+		//* Validate instance
+		$instance_record        =       $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`='$primary_id' and `action_type`='$action_type' and `action_state`='pending'");
+		if ($instance_record['action_id'] >= 1) {
+			$this->server->fault('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` = '$server_id', `tstamp` = '$tstamp', `action_type` = '$action_type', `action_param` = '$primary_id', `action_state` = '$action_state'")) {
+			return true;
+		} else {
+			return false;
+		}
+	}
 
 	//* Get alias details
 	public function mail_alias_get($session_id, $primary_id)
@@ -1034,7 +1099,6 @@
 			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
 			return false;
 		}
-		$client_id = $app->functions->intval($client_id);
 		
 		return $app->quota_lib->get_mailquota_data($client_id, false);
 	}

--
Gitblit v1.9.1