Index: trunk/wp-content/plugins/xpressme/xpressme_class.php
===================================================================
--- trunk/wp-content/plugins/xpressme/xpressme_class.php	(revision 81)
+++ trunk/wp-content/plugins/xpressme/xpressme_class.php	(revision 88)
@@ -13,5 +13,5 @@
 	var $newer_post_link_text;
 	var $is_author_view_count;
-	var $groupe_role_serial;
+	var $is_sql_debug;
 	var $groupe_role;
 
@@ -48,4 +48,5 @@
 		$this->newer_post_link_text = __('to Newer Post', 'xpressme');
 		$this->is_author_view_count = false;
+		$this->is_sql_debug = false;
 	}
 	
@@ -77,5 +78,6 @@
 			'old_post_link_text' => $this->old_post_link_text ,
 			'newer_post_link_text' => $this->newer_post_link_text,
-			'is_author_view_count' => $this->is_author_view_count
+			'is_author_view_count' => $this->is_author_view_count,
+			'is_sql_debug' => $this->is_sql_debug
 		);
 		if ($mode == 'add_new') {
@@ -141,4 +143,5 @@
 		if(empty($this->newer_post_link_text)) $this->newer_post_link_text = __('to Newer Post', 'xpressme');
 		$this->is_author_view_count = stripslashes(trim($_POST['ch_is_author_view_count']));
+		$this->is_sql_debug = stripslashes(trim($_POST['ch_is_sql_debug']));
 		
 		global $xoops_db;
@@ -307,4 +310,10 @@
 												__('NO','xpressme')		
 												);
+		echo				$this->yes_no_radio_option('is_sql_debug',
+												__('Is SQL debugging window displayed?','xpressme'),
+												__('YES','xpressme'),
+												__('NO','xpressme')		
+												);
+		
 		echo				$this->groupe_role_option();				
 //		$this->is_use_xoops_upload_path_html();
@@ -339,4 +348,53 @@
 		}
 		return $uploads;
+	}
+
+	// SQL DEBUG TEST
+	function is_sql_debug_permission()
+	{
+		global $current_user;
+
+		if ($this->is_sql_debug && ($current_user->user_level >= 10))
+			return true;
+		else
+			return false;
+	}
+	
+	function xpress_sql_debug($query_strings)
+	{
+		if ($this->is_sql_debug_permission()){
+			if (empty($GLOBALS['XPress_SQL_Query'])) $GLOBALS['XPress_SQL_Query'] = '';
+			$GLOBALS['XPress_SQL_Query'] .= $query_strings . '<br />';
+		}
+		return $query_strings;
+	}
+	
+	function displayDebugLog()
+	{
+		if ($this->is_sql_debug_permission()){
+			$content = '';
+			$content .= '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" />';
+			$content .= '<meta http-equiv="content-language" content="'._LANGCODE.'" />' ;
+			$content .= '<title>XPressME SQL DEBUG</title>' ;
+			$content .= '<link rel="stylesheet" type="text/css" media="all" href="'.getcss($GLOBALS['xoopsConfig']['theme_set']).'" />';
+			$content .= '</head><body>';
+			$content .= $GLOBALS['XPress_SQL_Query'];
+			$content .= '<div style="text-align:center;"><input class="formButton" value="CLOSE" type="button" onclick="javascript:window.close();" /></div></body></html>';
+
+			echo '<script type="text/javascript">
+				<!--//
+				xpress_debug_window = window.open("", "xpress_debug", "width=680 , height=600 ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no");
+				xpress_debug_window.document.clear();
+				xpress_debug_window.focus();
+				';
+			$lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
+			foreach ($lines as $line) {
+				echo 'xpress_debug_window.document.writeln("'.str_replace('"', '\"', $line).'");';
+			}
+			echo '
+				xpress_debug_window.document.close();
+				//-->
+			</script>';
+		}
 	}	
 
