From ac3b1f6f8c7d22096888e493c9036bca12f96685 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 06 Feb 2007 18:01:19 -0500
Subject: [PATCH] Changes in mail module.

---
 interface/web/mail/mail_user_edit.php |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/interface/web/mail/mail_box_edit.php b/interface/web/mail/mail_user_edit.php
similarity index 81%
rename from interface/web/mail/mail_box_edit.php
rename to interface/web/mail/mail_user_edit.php
index a93d14a..ee384f7 100644
--- a/interface/web/mail/mail_box_edit.php
+++ b/interface/web/mail/mail_user_edit.php
@@ -32,7 +32,7 @@
 * Begin Form configuration
 ******************************************/
 
-$tform_def_file = "form/mail_box.tform.php";
+$tform_def_file = "form/mail_user.tform.php";
 
 /******************************************
 * End Form configuration
@@ -61,14 +61,20 @@
 		$app->tpl->setVar("email_local_part",$email_parts[0]);
 		
 		// Getting Domains of the user
-		$sql = "SELECT domain FROM mail_domain WHERE type = 'local' AND ".$app->tform->getAuthSQL('r');
+		$sql = "SELECT domain FROM mail_domain WHERE ".$app->tform->getAuthSQL('r');
 		$domains = $app->db->queryAllRecords($sql);
 		$domain_select = '';
-		foreach( $domains as $domain) {
-			$selected = ($domain["domain"] == $email_parts[1])?'SELECTED':'';
-			$domain_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n";
+		if(is_array($domains)) {
+			foreach( $domains as $domain) {
+				$selected = ($domain["domain"] == $email_parts[1])?'SELECTED':'';
+				$domain_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n";
+			}
 		}
 		$app->tpl->setVar("email_domain",$domain_select);
+		
+		// Convert quota from Bytes to MB
+		$app->tpl->setVar("quota",$this->dataRecord["quota"] / 1024);
+		
 		
 		parent::onShowEnd();
 	}
@@ -81,7 +87,7 @@
 		if($domain["domain"] != $_POST["email_domain"]) $app->tform->errorMessage .= $app->tform->wordbook["no_domain_perm"];
 		
 		// if its an insert, check for password
-		if($this->id == 0 and $_POST["cryptpwd"] == '') {
+		if($this->id == 0 and $_POST["password"] == '') {
 			$app->tform->errorMessage .= $app->tform->wordbook["error_no_pwd"]."<br>";
 		}
 		
@@ -93,12 +99,18 @@
 		unset($this->dataRecord["email_local_part"]);
 		unset($this->dataRecord["email_domain"]);
 		
-		// setting Maildir
+		// Convert quota from MB to Bytes
+		$this->dataRecord["quota"] = $this->dataRecord["quota"] * 1024;
+		
+		// setting Maildir, Homedir, UID and GID
 		$app->uses('getconf');
 		$mail_config = $app->getconf->get_server_config($domain["server_id"],'mail');
 		$maildir = str_replace("[domain]",$domain["domain"],$mail_config["maildir_path"]);
 		$maildir = str_replace("[localpart]",$_POST["email_local_part"],$maildir);
 		$this->dataRecord["maildir"] = $maildir;
+		$this->dataRecord["homedir"] = $mail_config["homedir_path"];
+		$this->dataRecord["uid"] = $mail_config["mailuser_uid"];
+		$this->dataRecord["gid"] = $mail_config["mailuser_gid"];
 		
 		parent::onSubmit();
 	}

--
Gitblit v1.9.1