Index: /branches/XPressMU/xpressme_integration_kit/include/data.inc.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/data.inc.php	(revision 425)
+++ /branches/XPressMU/xpressme_integration_kit/include/data.inc.php	(revision 426)
@@ -43,5 +43,5 @@
 	$modRes = $xoopsDB->query($modSQL, 0, 0);
 	$modRow = $xoopsDB->fetchArray($modRes);
-	$module_id = $modRow['mid'];	
+	$module_id = $modRow['mid'];
 
 	$table_config = $xoopsDB->prefix('config');
@@ -52,19 +52,34 @@
 
 	$url_mod = XOOPS_URL."/modules/".$mydirname;
-
-	$table_posts      = $xoopsDB->prefix($wp_prefix . "_posts");
-	$table_categories = $xoopsDB->prefix($wp_prefix . "_categories");
-	$table_post2cat   = $xoopsDB->prefix($wp_prefix . "_post2cat");
-	$table_views   = $xoopsDB->prefix($wp_prefix . "_views");
-	$table_term_relationships = $xoopsDB->prefix($wp_prefix . "_term_relationships");
-	$table_term_taxonomy = $xoopsDB->prefix($wp_prefix . "_term_taxonomy");
-	$table_terms = $xoopsDB->prefix($wp_prefix . "_terms");
-
-//	$sql = "SELECT ID, post_title, post_content, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY post_date DESC";
-
-	$sql1 = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status FROM ".$table_posts." WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ORDER BY post_date DESC";
-
 	
-	$res1 = $xoopsDB->query($sql1, $limit, $offset);
+	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+	$prefix = $xoopsDB->prefix($wp_prefix);
+	$options_tables = get_table_list($prefix,'options');
+	$table_count = count($options_tables);
+	$sql1 = '';
+	foreach( $options_tables as $options_table){
+		$blog_url = get_blog_option($options_table , 'siteurl');
+		$blog_url = preg_replace('/\/$/', '' ,$blog_url);
+		$blogname = get_blog_option($options_table , 'blogname');
+		
+		$table_prefix = get_multi_prefix($options_table,'options');
+		
+		$table_posts      = $table_prefix . "posts";
+		
+		$sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname ";
+		$sub_sql .= " FROM ".$table_posts;
+		$sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ";
+
+		if ($table_count > 1){
+			$sub_sql = '(' . $sub_sql . ')';
+			if (!empty($sql1)) $sql1 = $sql1 . ' UNION ';
+			$sql1 = $sql1 . $sub_sql;
+		} else {
+			$sql1 =  $sub_sql;
+		}
+	}
+	$sql1 .= " ORDER BY post_date DESC LIMIT $offset,$limit";
+
+	$res1 = $xoopsDB->queryF($sql1);
 
 	$i = 0;
@@ -74,21 +89,36 @@
 	{
 		$id = $row1['ID'];
-		if ($wp_db_version < 6124){
-			$sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id;
-		} else {
-			$sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name ";
-			$sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id ";
-			$sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";		
-		}
-		$row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) );
+		$blog_url = $row1['blog_url'];
+		$blogname = $row1['blogname'];
+		$table_views   =$modules_table = $xoopsDB->prefix($wp_prefix) . "_views";
+		$table_term_relationships = $row1['table_prefix'] . "term_relationships";
+		$table_term_taxonomy = $row1['table_prefix'] . "term_taxonomy";
+		$table_terms = $row1['table_prefix'] . "terms";
+		$table_categories = $row1['table_prefix'] . "categories";
+		$table_post2cat   = $row1['table_prefix'] . "post2cat";
+
+		if ($table_count <= 1){
+			if ($wp_db_version < 6124){
+				$sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id;
+			} else {
+				$sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name ";
+				$sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id ";
+				$sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";		
+			}
+			$row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) );
+			$ret[$i]['cat_link'] = $blog_url."/index.php?cat=".$row2['cat_ID'];
+			$ret[$i]['cat_name'] = $row2['cat_name'];
+		} else {
+			$ret[$i]['cat_link'] = $blog_url;
+			$ret[$i]['cat_name'] = $blogname;
+		}
+
 		if ($row1['post_type'] == 'page'){
-				$ret[$i]['link']     = $url_mod."/?page_id=".$id;
-		} else {
-			$ret[$i]['link']     = $url_mod."/index.php?p=".$id;
-		}
-		$ret[$i]['cat_link'] = $url_mod."/index.php?cat=".$row2['cat_ID'];
+				$ret[$i]['link']     = $blog_url."/?page_id=".$id;
+		} else {
+			$ret[$i]['link']     = $blog_url."/index.php?p=".$id;
+		}
 
 		$ret[$i]['title']    = $row1['post_title'];
-		$ret[$i]['cat_name'] = $row2['cat_name'];
 
 		$ret[$i]['uid'] = wp_uid_to_xoops_uid($row1['post_author'],$mydirname);
@@ -139,7 +169,31 @@
 		$wp_prefix = $mydirname;
 	}
-
-	$sql = "SELECT count(*) FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." ORDER BY ID";
-	$array = $xoopsDB->fetchRow( $xoopsDB->query($sql) );
+	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+	$prefix = $xoopsDB->prefix($wp_prefix);
+	$options_tables = get_table_list($prefix,'options');
+	$table_count = count($options_tables);
+	$sql = '';
+	foreach( $options_tables as $options_table){
+		$blog_url = get_blog_option($options_table , 'siteurl');
+		$blog_url = preg_replace('/\/$/', '' ,$blog_url);
+		$blogname = get_blog_option($options_table , 'blogname');
+		
+		$table_prefix = get_multi_prefix($options_table,'options');
+		$table_posts      = $table_prefix . "posts";
+
+		$sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname ";
+		$sub_sql .= " FROM ".$table_posts;
+		$sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ";
+
+		if ($table_count > 1){
+			$sub_sql = '(' . $sub_sql . ')';
+			if (!empty($sql)) $sql = $sql . ' UNION ';
+			$sql = $sql . $sub_sql;
+		} else {
+			$sql =  $sub_sql;
+		}
+	}
+
+	$array = $xoopsDB->fetchRow( $xoopsDB->queryF($sql) );
 	$num = $array[0];
 	if (empty($num)) $num = 0;
@@ -160,6 +214,32 @@
 		$wp_prefix = $mydirname;
 	}
-	$sql = "SELECT ID, post_title, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY ID";
-	$result = $xoopsDB->query($sql,$limit,$offset);
+	
+	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+	$prefix = $xoopsDB->prefix($wp_prefix);
+	$options_tables = get_table_list($prefix,'options');
+	$table_count = count($options_tables);
+	$sql = '';
+	foreach( $options_tables as $options_table){
+		$blog_url = get_blog_option($options_table , 'siteurl');
+		$blog_url = preg_replace('/\/$/', '' ,$blog_url);
+		$blogname = get_blog_option($options_table , 'blogname');
+		
+		$table_prefix = get_multi_prefix($options_table,'options');
+		$table_posts      = $table_prefix . "posts";
+
+		$sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname ";
+		$sub_sql .= " FROM ".$table_posts;
+		$sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ";
+
+		if ($table_count > 1){
+			$sub_sql = '(' . $sub_sql . ')';
+			if (!empty($sql)) $sql = $sql . ' UNION ';
+			$sql = $sql . $sub_sql;
+		} else {
+			$sql =  $sub_sql;
+		}
+	}
+
+	$result = $xoopsDB->queryF($sql,$limit,$offset);
 
 	$i = 0;
@@ -169,6 +249,8 @@
 	{
 		$id = $row1['ID'];
+		$blog_url = $row1['blog_url'];
+		$blogname = $row1['blogname'];
 		$ret[$i]['id'] = $id;
-		$ret[$i]['link'] = XOOPS_URL."/modules/xpress/index.php?p=".$id."";
+		$ret[$i]['link'] = $blog_url . "/index.php?p=".$id;
 		$ret[$i]['title'] = $row1['post_title'];
 		$ret[$i]['time']  = $row1['unix_post_date'];
@@ -180,4 +262,19 @@
 }
 
+if( ! function_exists( 'get_blog_option' ) ) {
+	function get_blog_option($option_table,$option_name){
+		$xoopsDB =& Database::getInstance();
+
+		$sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'";
+		
+		$result =  $xoopsDB->query($sql, 0, 0);
+		if ($xoopsDB->getRowsNum($result)  > 0){
+			$row = $xoopsDB->fetchArray($result);
+			return $row['option_value'];
+		}
+		return 0;
+	}
+}
+
 
 // --- function end ---
Index: /trunk/xpressme_integration_kit/include/data.inc.php
===================================================================
--- /trunk/xpressme_integration_kit/include/data.inc.php	(revision 425)
+++ /trunk/xpressme_integration_kit/include/data.inc.php	(revision 426)
@@ -43,5 +43,5 @@
 	$modRes = $xoopsDB->query($modSQL, 0, 0);
 	$modRow = $xoopsDB->fetchArray($modRes);
-	$module_id = $modRow['mid'];	
+	$module_id = $modRow['mid'];
 
 	$table_config = $xoopsDB->prefix('config');
@@ -52,19 +52,34 @@
 
 	$url_mod = XOOPS_URL."/modules/".$mydirname;
-
-	$table_posts      = $xoopsDB->prefix($wp_prefix . "_posts");
-	$table_categories = $xoopsDB->prefix($wp_prefix . "_categories");
-	$table_post2cat   = $xoopsDB->prefix($wp_prefix . "_post2cat");
-	$table_views   = $xoopsDB->prefix($wp_prefix . "_views");
-	$table_term_relationships = $xoopsDB->prefix($wp_prefix . "_term_relationships");
-	$table_term_taxonomy = $xoopsDB->prefix($wp_prefix . "_term_taxonomy");
-	$table_terms = $xoopsDB->prefix($wp_prefix . "_terms");
-
-//	$sql = "SELECT ID, post_title, post_content, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY post_date DESC";
-
-	$sql1 = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status FROM ".$table_posts." WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ORDER BY post_date DESC";
-
 	
-	$res1 = $xoopsDB->query($sql1, $limit, $offset);
+	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+	$prefix = $xoopsDB->prefix($wp_prefix);
+	$options_tables = get_table_list($prefix,'options');
+	$table_count = count($options_tables);
+	$sql1 = '';
+	foreach( $options_tables as $options_table){
+		$blog_url = get_blog_option($options_table , 'siteurl');
+		$blog_url = preg_replace('/\/$/', '' ,$blog_url);
+		$blogname = get_blog_option($options_table , 'blogname');
+		
+		$table_prefix = get_multi_prefix($options_table,'options');
+		
+		$table_posts      = $table_prefix . "posts";
+		
+		$sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname ";
+		$sub_sql .= " FROM ".$table_posts;
+		$sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ";
+
+		if ($table_count > 1){
+			$sub_sql = '(' . $sub_sql . ')';
+			if (!empty($sql1)) $sql1 = $sql1 . ' UNION ';
+			$sql1 = $sql1 . $sub_sql;
+		} else {
+			$sql1 =  $sub_sql;
+		}
+	}
+	$sql1 .= " ORDER BY post_date DESC LIMIT $offset,$limit";
+
+	$res1 = $xoopsDB->queryF($sql1);
 
 	$i = 0;
@@ -74,21 +89,36 @@
 	{
 		$id = $row1['ID'];
-		if ($wp_db_version < 6124){
-			$sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id;
-		} else {
-			$sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name ";
-			$sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id ";
-			$sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";		
-		}
-		$row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) );
+		$blog_url = $row1['blog_url'];
+		$blogname = $row1['blogname'];
+		$table_views   =$modules_table = $xoopsDB->prefix($wp_prefix) . "_views";
+		$table_term_relationships = $row1['table_prefix'] . "term_relationships";
+		$table_term_taxonomy = $row1['table_prefix'] . "term_taxonomy";
+		$table_terms = $row1['table_prefix'] . "terms";
+		$table_categories = $row1['table_prefix'] . "categories";
+		$table_post2cat   = $row1['table_prefix'] . "post2cat";
+
+		if ($table_count <= 1){
+			if ($wp_db_version < 6124){
+				$sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id;
+			} else {
+				$sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name ";
+				$sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id ";
+				$sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";		
+			}
+			$row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) );
+			$ret[$i]['cat_link'] = $blog_url."/index.php?cat=".$row2['cat_ID'];
+			$ret[$i]['cat_name'] = $row2['cat_name'];
+		} else {
+			$ret[$i]['cat_link'] = $blog_url;
+			$ret[$i]['cat_name'] = $blogname;
+		}
+
 		if ($row1['post_type'] == 'page'){
-				$ret[$i]['link']     = $url_mod."/?page_id=".$id;
-		} else {
-			$ret[$i]['link']     = $url_mod."/index.php?p=".$id;
-		}
-		$ret[$i]['cat_link'] = $url_mod."/index.php?cat=".$row2['cat_ID'];
+				$ret[$i]['link']     = $blog_url."/?page_id=".$id;
+		} else {
+			$ret[$i]['link']     = $blog_url."/index.php?p=".$id;
+		}
 
 		$ret[$i]['title']    = $row1['post_title'];
-		$ret[$i]['cat_name'] = $row2['cat_name'];
 
 		$ret[$i]['uid'] = wp_uid_to_xoops_uid($row1['post_author'],$mydirname);
@@ -139,7 +169,31 @@
 		$wp_prefix = $mydirname;
 	}
-
-	$sql = "SELECT count(*) FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." ORDER BY ID";
-	$array = $xoopsDB->fetchRow( $xoopsDB->query($sql) );
+	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+	$prefix = $xoopsDB->prefix($wp_prefix);
+	$options_tables = get_table_list($prefix,'options');
+	$table_count = count($options_tables);
+	$sql = '';
+	foreach( $options_tables as $options_table){
+		$blog_url = get_blog_option($options_table , 'siteurl');
+		$blog_url = preg_replace('/\/$/', '' ,$blog_url);
+		$blogname = get_blog_option($options_table , 'blogname');
+		
+		$table_prefix = get_multi_prefix($options_table,'options');
+		$table_posts      = $table_prefix . "posts";
+
+		$sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname ";
+		$sub_sql .= " FROM ".$table_posts;
+		$sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ";
+
+		if ($table_count > 1){
+			$sub_sql = '(' . $sub_sql . ')';
+			if (!empty($sql)) $sql = $sql . ' UNION ';
+			$sql = $sql . $sub_sql;
+		} else {
+			$sql =  $sub_sql;
+		}
+	}
+
+	$array = $xoopsDB->fetchRow( $xoopsDB->queryF($sql) );
 	$num = $array[0];
 	if (empty($num)) $num = 0;
@@ -160,6 +214,32 @@
 		$wp_prefix = $mydirname;
 	}
-	$sql = "SELECT ID, post_title, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY ID";
-	$result = $xoopsDB->query($sql,$limit,$offset);
+	
+	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+	$prefix = $xoopsDB->prefix($wp_prefix);
+	$options_tables = get_table_list($prefix,'options');
+	$table_count = count($options_tables);
+	$sql = '';
+	foreach( $options_tables as $options_table){
+		$blog_url = get_blog_option($options_table , 'siteurl');
+		$blog_url = preg_replace('/\/$/', '' ,$blog_url);
+		$blogname = get_blog_option($options_table , 'blogname');
+		
+		$table_prefix = get_multi_prefix($options_table,'options');
+		$table_posts      = $table_prefix . "posts";
+
+		$sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname ";
+		$sub_sql .= " FROM ".$table_posts;
+		$sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ";
+
+		if ($table_count > 1){
+			$sub_sql = '(' . $sub_sql . ')';
+			if (!empty($sql)) $sql = $sql . ' UNION ';
+			$sql = $sql . $sub_sql;
+		} else {
+			$sql =  $sub_sql;
+		}
+	}
+
+	$result = $xoopsDB->queryF($sql,$limit,$offset);
 
 	$i = 0;
@@ -169,6 +249,8 @@
 	{
 		$id = $row1['ID'];
+		$blog_url = $row1['blog_url'];
+		$blogname = $row1['blogname'];
 		$ret[$i]['id'] = $id;
-		$ret[$i]['link'] = XOOPS_URL."/modules/xpress/index.php?p=".$id."";
+		$ret[$i]['link'] = $blog_url . "/index.php?p=".$id;
 		$ret[$i]['title'] = $row1['post_title'];
 		$ret[$i]['time']  = $row1['unix_post_date'];
@@ -180,4 +262,19 @@
 }
 
+if( ! function_exists( 'get_blog_option' ) ) {
+	function get_blog_option($option_table,$option_name){
+		$xoopsDB =& Database::getInstance();
+
+		$sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'";
+		
+		$result =  $xoopsDB->query($sql, 0, 0);
+		if ($xoopsDB->getRowsNum($result)  > 0){
+			$row = $xoopsDB->fetchArray($result);
+			return $row['option_value'];
+		}
+		return 0;
+	}
+}
+
 
 // --- function end ---
