From 66bc13da957b8897ebc6a18e3cb99da39c48ac4b Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 15 Sep 2010 10:35:24 -0400
Subject: [PATCH] Updated Dovecot sql user queries.

---
 interface/web/client/reseller_edit.php       |    7 +++++++
 install/tpl/opensuse_dovecot-sql.conf.master |    2 +-
 install/tpl/debian6_dovecot-sql.conf.master  |    1 +
 install/tpl/debian_dovecot-sql.conf.master   |    2 +-
 install/tpl/fedora_dovecot-sql.conf.master   |    2 +-
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/install/tpl/debian6_dovecot-sql.conf.master b/install/tpl/debian6_dovecot-sql.conf.master
index 0258b23..73dd0fc 100644
--- a/install/tpl/debian6_dovecot-sql.conf.master
+++ b/install/tpl/debian6_dovecot-sql.conf.master
@@ -121,5 +121,6 @@
 default_pass_scheme = CRYPT
 
 password_query = SELECT password FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
+#user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
 user_query = SELECT email AS user, maildir AS home, CONCAT('*:storage=', quota , 'B') AS quota_rule FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
 
diff --git a/install/tpl/debian_dovecot-sql.conf.master b/install/tpl/debian_dovecot-sql.conf.master
index 523237d..8777d73 100644
--- a/install/tpl/debian_dovecot-sql.conf.master
+++ b/install/tpl/debian_dovecot-sql.conf.master
@@ -121,6 +121,6 @@
 default_pass_scheme = CRYPT
 
 password_query = SELECT password FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
-user_query = SELECT email as user, maildir as home, CONCAT(maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
+user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
 
 
diff --git a/install/tpl/fedora_dovecot-sql.conf.master b/install/tpl/fedora_dovecot-sql.conf.master
index 3053e3c..17f7422 100644
--- a/install/tpl/fedora_dovecot-sql.conf.master
+++ b/install/tpl/fedora_dovecot-sql.conf.master
@@ -134,4 +134,4 @@
 default_pass_scheme = CRYPT
 
 password_query = SELECT password FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
-user_query = SELECT email as user, maildir as home, CONCAT(maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
+user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
diff --git a/install/tpl/opensuse_dovecot-sql.conf.master b/install/tpl/opensuse_dovecot-sql.conf.master
index 71b0c58..17f7422 100644
--- a/install/tpl/opensuse_dovecot-sql.conf.master
+++ b/install/tpl/opensuse_dovecot-sql.conf.master
@@ -134,4 +134,4 @@
 default_pass_scheme = CRYPT
 
 password_query = SELECT password FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
-user_query = SELECT email as user, maildir as home, CONCAT(maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', quota) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
+user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
diff --git a/interface/web/client/reseller_edit.php b/interface/web/client/reseller_edit.php
index 44c65be..747c924 100644
--- a/interface/web/client/reseller_edit.php
+++ b/interface/web/client/reseller_edit.php
@@ -200,6 +200,13 @@
 			$app->db->query($sql);
 		}
 		
+		// ensure that a reseller is not converted to a client in demo mode when client_id <= 2
+		if($conf['demo_mode'] == true && $this->id <= 2) {
+			if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != -1) {
+				$app->db->query('UPDATE client set limit_client = -1 WHERE client_id = '.$this->id);
+			}
+		}
+		
 		// reseller status changed
 		if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) {
 			$modules = $conf['interface_modules_enabled'] . ',client';

--
Gitblit v1.9.1