Index: /branches/XPressMU/xpressme_integration_kit/include/oninstall.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/oninstall.php	(revision 427)
+++ /branches/XPressMU/xpressme_integration_kit/include/oninstall.php	(revision 428)
@@ -100,4 +100,5 @@
 	}
 	$views_queries ="CREATE TABLE $views_table (
+  		blog_id bigint(20) unsigned NOT NULL default '0',
   		post_id bigint(20) unsigned NOT NULL default '0',
   		post_views bigint(20) unsigned NOT NULL default '0',
Index: /branches/XPressMU/xpressme_integration_kit/include/onupdate.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/onupdate.php	(revision 427)
+++ /branches/XPressMU/xpressme_integration_kit/include/onupdate.php	(revision 428)
@@ -175,7 +175,8 @@
 	$msgs = array();
 
+	$views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ;
 	if (! enhanced_table_check($mydirname,'views')){
-		$views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ;
 		$queries ="CREATE TABLE $views_table (
+  		blog_id bigint(20) unsigned NOT NULL default '0',
   		post_id bigint(20) unsigned NOT NULL default '0',
   		post_views bigint(20) unsigned NOT NULL default '0',
@@ -184,4 +185,10 @@
 		$db->queryF( $queries ) ;
 		$msgs[] = "$views_table table of XPressME was made.";
+	} else {
+		if (!is_found_table_column($views_table,'blog_id')){
+			$queries ="ALTER TABLE $views_table ADD blog_id bigint(20)  FIRST";
+			$db->queryF( $queries ) ;
+			$msgs[] = "$views_table  ADD blog_id .";
+		}
 	}
 	
@@ -261,4 +268,21 @@
 endif;
 
+if( ! function_exists( 'is_found_table_column' ) ) :
+function is_found_table_column($table,$column){
+		global $xoopsModule;
+		$xoopsDB =& Database::getInstance();
+
+		$sql = "DESCRIBE $table $column";
+		$res = $xoopsDB->queryF($sql, 0, 0);
+		if ($res === false){
+			return false;
+		} else {
+			if ($xoopsDB->getRowsNum($res)  > 0)
+				return true;
+			else
+				return false;
+		}
+}
+endif;
 
 
Index: /branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php	(revision 427)
+++ /branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php	(revision 428)
@@ -422,5 +422,5 @@
 function xpress_post_views_count($args ='') {
 	global $xoops_db,$wpdb;
-
+	global $blog_id;
 	static $post_cache_views;
 
@@ -442,6 +442,11 @@
 	if($post_id==0) return null;
 	if(!isset($post_cache_views[$post_id])){
-        $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id";
-        $post_views = $xoops_db->get_var($sql);
+		if (is_null($blog_id)){
+			$blog_where = '';
+		} else {
+			$blog_where = ' AND blog_id = '. $blog_id;
+		}
+		$sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id " .  $blog_where;
+       $post_views = $xoops_db->get_var($sql);
         if (!$post_views) {
 	        $post_cache_views[$post_id] = 0;
@@ -473,4 +478,5 @@
 	global $xoops_db,$wpdb;
 	global $table_prefix;
+	global $blog_id;
 	static $views;
 	
@@ -481,4 +487,5 @@
 
 	$views_db = get_wp_prefix() . 'views';
+	if (is_null($blog_id)) $blog_id = 0;
 
 	if($post_id==0 || !empty($views[$post_id])) return null;
@@ -489,11 +496,19 @@
 		if ($current_user_id ==$post_author_id) return null;
 	}
-
-    $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id";
+	if (is_null($blog_id)){
+		$blog_where = '';
+	} else {
+		$blog_where = ' AND blog_id = ' . $blog_id;
+	}
+	$sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id" . $blog_where;
 	$post_views_found = $xoops_db->get_var($sql);
 	if($post_views_found){
-        $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id";
+        $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id" . $blog_where;
     }else{
-        $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
+    	if (is_null($blog_id)){
+			$sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
+		} else {
+			$sql = "INSERT INTO " . $views_db . " (blog_id, post_id, post_views) VALUES ($blog_id, $post_id, 1)";
+		}
     }
     $xoops_db->query($sql);
Index: /trunk/xpressme_integration_kit/include/oninstall.php
===================================================================
--- /trunk/xpressme_integration_kit/include/oninstall.php	(revision 427)
+++ /trunk/xpressme_integration_kit/include/oninstall.php	(revision 428)
@@ -100,4 +100,5 @@
 	}
 	$views_queries ="CREATE TABLE $views_table (
+  		blog_id bigint(20) unsigned NOT NULL default '0',
   		post_id bigint(20) unsigned NOT NULL default '0',
   		post_views bigint(20) unsigned NOT NULL default '0',
Index: /trunk/xpressme_integration_kit/include/onupdate.php
===================================================================
--- /trunk/xpressme_integration_kit/include/onupdate.php	(revision 427)
+++ /trunk/xpressme_integration_kit/include/onupdate.php	(revision 428)
@@ -175,7 +175,8 @@
 	$msgs = array();
 
+	$views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ;
 	if (! enhanced_table_check($mydirname,'views')){
-		$views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ;
 		$queries ="CREATE TABLE $views_table (
+  		blog_id bigint(20) unsigned NOT NULL default '0',
   		post_id bigint(20) unsigned NOT NULL default '0',
   		post_views bigint(20) unsigned NOT NULL default '0',
@@ -184,4 +185,10 @@
 		$db->queryF( $queries ) ;
 		$msgs[] = "$views_table table of XPressME was made.";
+	} else {
+		if (!is_found_table_column($views_table,'blog_id')){
+			$queries ="ALTER TABLE $views_table ADD blog_id bigint(20)  FIRST";
+			$db->queryF( $queries ) ;
+			$msgs[] = "$views_table  ADD blog_id .";
+		}
 	}
 	
@@ -261,4 +268,21 @@
 endif;
 
+if( ! function_exists( 'is_found_table_column' ) ) :
+function is_found_table_column($table,$column){
+		global $xoopsModule;
+		$xoopsDB =& Database::getInstance();
+
+		$sql = "DESCRIBE $table $column";
+		$res = $xoopsDB->queryF($sql, 0, 0);
+		if ($res === false){
+			return false;
+		} else {
+			if ($xoopsDB->getRowsNum($res)  > 0)
+				return true;
+			else
+				return false;
+		}
+}
+endif;
 
 
Index: /trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php
===================================================================
--- /trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php	(revision 427)
+++ /trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php	(revision 428)
@@ -422,5 +422,5 @@
 function xpress_post_views_count($args ='') {
 	global $xoops_db,$wpdb;
-
+	global $blog_id;
 	static $post_cache_views;
 
@@ -442,6 +442,11 @@
 	if($post_id==0) return null;
 	if(!isset($post_cache_views[$post_id])){
-        $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id";
-        $post_views = $xoops_db->get_var($sql);
+		if (is_null($blog_id)){
+			$blog_where = '';
+		} else {
+			$blog_where = ' AND blog_id = '. $blog_id;
+		}
+		$sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id " .  $blog_where;
+       $post_views = $xoops_db->get_var($sql);
         if (!$post_views) {
 	        $post_cache_views[$post_id] = 0;
@@ -473,4 +478,5 @@
 	global $xoops_db,$wpdb;
 	global $table_prefix;
+	global $blog_id;
 	static $views;
 	
@@ -481,4 +487,5 @@
 
 	$views_db = get_wp_prefix() . 'views';
+	if (is_null($blog_id)) $blog_id = 0;
 
 	if($post_id==0 || !empty($views[$post_id])) return null;
@@ -489,11 +496,19 @@
 		if ($current_user_id ==$post_author_id) return null;
 	}
-
-    $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id";
+	if (is_null($blog_id)){
+		$blog_where = '';
+	} else {
+		$blog_where = ' AND blog_id = ' . $blog_id;
+	}
+	$sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id" . $blog_where;
 	$post_views_found = $xoops_db->get_var($sql);
 	if($post_views_found){
-        $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id";
+        $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id" . $blog_where;
     }else{
-        $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
+    	if (is_null($blog_id)){
+			$sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)";
+		} else {
+			$sql = "INSERT INTO " . $views_db . " (blog_id, post_id, post_views) VALUES ($blog_id, $post_id, 1)";
+		}
     }
     $xoops_db->query($sql);
