From 24f38b424a3d12c7f4fac1829c83725b200b1e97 Mon Sep 17 00:00:00 2001
From: vogelor <vogelor@ispconfig3>
Date: Wed, 26 May 2010 09:42:11 +0000
Subject: [PATCH] Enhancement of the Website-List. The user can only select the
 server as filter, he has some sites at (and not ALL Servers of the
 server-farm)

---
 interface/lib/classes/listform.inc.php       |  2 ++
 interface/lib/classes/tform.inc.php          | 11 +++++++----
 interface/web/sites/list/web_domain.list.php |  2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php
index c97e39d9f..f385da6d8 100644
--- a/interface/lib/classes/listform.inc.php
+++ b/interface/lib/classes/listform.inc.php
@@ -91,6 +91,8 @@ class listform {
             //$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring);
 			$app->uses('tform');
             $querystring = str_replace("{AUTHSQL}",$app->tform->getAuthSQL('r'),$querystring);
+            $querystring = str_replace("{AUTHSQL-A}",$app->tform->getAuthSQL('r','a'),$querystring);
+            $querystring = str_replace("{AUTHSQL-B}",$app->tform->getAuthSQL('r','b'),$querystring);
 
             //* Getting the records
             $tmp_records = $app->db->queryAllRecords($querystring);
diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index d2969439f..9396b4b46 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -1125,15 +1125,18 @@ class tform {
 
         }
 
-        function getAuthSQL($perm) {
+        function getAuthSQL($perm, $table = '') {
 				if($_SESSION["s"]["user"]["typ"] == 'admin') {
 					return '1';
 				} else {
+					if ($table != ''){
+						$table = ' ' . $table . '.';
+					}
                 	$groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0;
 					$sql = '(';
-                	$sql .= "(sys_userid = ".$_SESSION["s"]["user"]["userid"]." AND sys_perm_user like '%$perm%') OR  ";
-                	$sql .= "(sys_groupid IN (".$groups.") AND sys_perm_group like '%$perm%') OR ";
-                	$sql .= "sys_perm_other like '%$perm%'";
+                	$sql .= "(" . $table . "sys_userid = ".$_SESSION["s"]["user"]["userid"]." AND " . $table . "sys_perm_user like '%$perm%') OR  ";
+                	$sql .= "(" . $table . "sys_groupid IN (".$groups.") AND " . $table ."sys_perm_group like '%$perm%') OR ";
+                	$sql .= $table . "sys_perm_other like '%$perm%'";
                 	$sql .= ')';
 
                 	return $sql;
diff --git a/interface/web/sites/list/web_domain.list.php b/interface/web/sites/list/web_domain.list.php
index 502f93bd3..271c8354a 100644
--- a/interface/web/sites/list/web_domain.list.php
+++ b/interface/web/sites/list/web_domain.list.php
@@ -74,7 +74,7 @@ $liste["item"][] = array(	'field'		=> "server_id",
 							'prefix'	=> "%",
 							'suffix'	=> "%",
 							'datasource'	=> array ( 	'type'	=> 'SQL',
-														'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
+														'querystring' => 'SELECT a.server_id, a.server_name FROM server a, web_domain b WHERE (a.server_id = b.server_id) AND ({AUTHSQL-B}) ORDER BY a.server_name',
 														'keyfield'=> 'server_id',
 														'valuefield'=> 'server_name'
 									 				  ),
-- 
GitLab