From 1c56baa23f45e097f6dbb14669b604f1b86108f9 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Mon, 25 Mar 2013 06:33:03 -0400
Subject: [PATCH] - Fixed FS#2761 - Missing NameVirtualHost *:443.

---
 interface/lib/classes/listform_actions.inc.php |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php
index c895658..aef3371 100644
--- a/interface/lib/classes/listform_actions.inc.php
+++ b/interface/lib/classes/listform_actions.inc.php
@@ -33,8 +33,9 @@
 	private $id;
 	public $idx_key;
 	public $DataRowColor;
-	public  $SQLExtWhere = '';
-	public  $SQLOrderBy = '';
+	public $SQLExtWhere = '';
+	public $SQLOrderBy = '';
+	public $SQLExtSelect = '';
 	
 	public function onLoad()
     {
@@ -141,13 +142,14 @@
 			if($_SESSION['s']['user']['typ'] == "admin") {
 				$sql_where = '';
 			} else {
-				$sql_where = $app->tform->getAuthSQL('r').' and';
+				$sql_where = $app->tform->getAuthSQL('r', $app->listform->listDef['table']).' and'; 
+                //$sql_where = $app->tform->getAuthSQL('r').' and';
 			}
 		}		
 		if($this->SQLExtWhere != '') {
 			$sql_where .= ' '.$this->SQLExtWhere.' and';
 		}
-
+		
 		$sql_where = $app->listform->getSearchSQL($sql_where);
 		$app->tpl->setVar($app->listform->searchValues);
 		
@@ -169,8 +171,15 @@
 		    $order_by_sql = str_replace('client_id','c.contact_name',$order_by_sql);
 		  } elseif($order == 'parent_domain_id'){
 		    $join .= ' LEFT JOIN web_domain as wd ON '.$app->listform->listDef['table'].'.parent_domain_id = wd.domain_id ';
-		    $order_by_sql = str_replace('parent_domain_id','wd.domain',$order_by_sql);
-		    $sql_where = str_replace('type',$app->listform->listDef['table'].'.type',$sql_where);
+			//$order_by_sql = str_replace(' domain', ' '.$app->listform->listDef['table'].'.domain',$order_by_sql);
+		    //$order_by_sql = str_replace('parent_domain_id','wd.domain',$order_by_sql);
+			$order_by_sql = preg_replace('@( |,|^)(domain)( |,|$)@', '$1'.$app->listform->listDef['table'].'.$2$3', $order_by_sql);
+			$order_by_sql = preg_replace('@( |,|^)(parent_domain_id)( |,|$)@', '$1wd.domain$3', $order_by_sql);
+			
+		    //$sql_where = str_replace('type',$app->listform->listDef['table'].'.type',$sql_where);
+			//$sql_where = str_replace(' domain',' '.$app->listform->listDef['table'].'.domain',$sql_where);
+			$sql_where = preg_replace('@( |,|^)(type)( |,|$)@', '$1'.$app->listform->listDef['table'].'.$2$3', $sql_where);
+			$sql_where = preg_replace('@( |,|^)(domain)( |,|$)@', '$1'.$app->listform->listDef['table'].'.$2$3', $sql_where);
 		  } elseif($order == 'sys_groupid'){
 		    $join .= ' LEFT JOIN sys_group as sg ON '.$app->listform->listDef['table'].'.sys_groupid = sg.groupid ';
 		    $order_by_sql = str_replace('sys_groupid','sg.name',$order_by_sql);
@@ -248,6 +257,12 @@
 		    $order_by_sql = "GROUP BY mailuser_id ".$order_by_sql;
 		  }
 		}
+		
+		if($this->SQLExtSelect != '') {
+			if(substr($this->SQLExtSelect,0,1) != ',') $this->SQLExtSelect = ','.$this->SQLExtSelect; 
+			$extselect .= $this->SQLExtSelect;
+		}
+
 		return 'SELECT '.$app->listform->listDef['table'].'.*'.$extselect.' FROM '.$app->listform->listDef['table']."$join WHERE $sql_where $order_by_sql $limit_sql";
 	}
 	
@@ -278,6 +293,15 @@
 		$app->tpl->setVar($app->listform->wordbook);
 		$app->tpl->setVar('form_action', $app->listform->listDef['file']);
 		
+        if(isset($_SESSION['show_info_msg'])) {
+            $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']);
+            unset($_SESSION['show_info_msg']);
+        }
+        if(isset($_SESSION['show_error_msg'])) {
+            $app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']);
+            unset($_SESSION['show_error_msg']);
+        }
+        
 		//* Parse the templates and send output to the browser
 		$this->onShowEnd();
 	}

--
Gitblit v1.9.1