Index: trunk/include/oninstall.php
===================================================================
--- trunk/include/oninstall.php	(revision 183)
+++ trunk/include/oninstall.php	(revision 210)
@@ -3,5 +3,5 @@
 $mydirname = basename($mydirpath);
 $lang = @$GLOBALS["xoopsConfig"]['language'];
-global $wp_db_version;
+global $wp_db_version,$wp_rewrite;
 include_once $mydirpath .'/wp-includes/version.php' ;
 
@@ -39,8 +39,13 @@
 //xpress
 	global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query;
+	global $xoops_config;
+		
 	define("WP_INSTALLING", true);
 	$site_url= XOOPS_URL."/modules/".$mydirname;
 	$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
 	$path = $mydirpath . '/';
+	$site_name = ucfirst($mydirname) . ' ' . _MI_XP2_NAME;
+	
+// install WordPress
 	if (file_exists($path . 'wp-load.php')) {
 		require_once $path . 'wp-load.php';
@@ -60,59 +65,5 @@
 	populate_roles();
 	
-// Rewrite Option for Xpress
-//	update_option("blog_charset", wp_blog_charset());
-	update_option('blogname', ucfirst($mydirname) . ' ' . _MI_XP2_NAME );	
-	update_option('blogdescription', 'WordPress for XOOPS');
-	update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']);
-	update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/");
-	update_option("home", $site_url);
-	update_option("siteurl", $site_url);
-	update_option("what_to_show", "posts");
-	update_option('default_pingback_flag', 0);
-	$ret[] = 'The initial data was written in the data base of wordpress.';
-	
-	update_option("template", "xpress_default");
-	update_option("stylesheet", "xpress_default");
-	$ret[] = 'The default theme of wordpress was set to xpress_default.';
-	/* add new option for uploads */
-//	update_option('uploads_use_yearmonth_folders', 1);
-	update_option('upload_path', 'wp-content/uploads');
-	
-		
-// Admin User Data write
-	// Change uid field
-	$wpdb->query("ALTER TABLE $wpdb->posts CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'");
-	$user_name = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("uname"):'admin';
-	$email = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("email"):'foo@exsample.com';
-	$pass_md5 = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("pass"):'';
-	
-	$user_id = username_exists($user_name);
-	if ( !$user_id ) {
-		$random_password = 'admin';
-		$user_id = wp_create_user($user_name, $random_password, $email);
-	} else {
-		$random_password = __('User already exists.  Password inherited.');
-	}
-
-	$user = new WP_User($user_id);
-	$user->set_role('administrator');
-	'User ' . $user_name . ' of the administrator was made.';
-	// over write xoops md5 password 
-	$sql = "UPDATE $wpdb->users SET user_pass ='$pass_md5' WHERE ID = $user_id";
-	$wpdb->query($sql);
-	$ret[] = 'The password of XOOPS was copied.';
-	// Set Default data
-	wp_install_defaults($user_id);
-	$ret[] = 'The first sample post & comment was written.';
-//	    generate_page_uri_index();
-
-	/* activate the XPressME plugin */
-	$plugin_current = "xpressme/xpressme.php";
-	update_option('active_plugins', array($plugin_current));
-	include_once(dirname(__FILE__) . '/../wp-content/plugins/'.$plugin_current);
-	do_action('activate_'.$plugin_current);
-	$ret[] = 'The xpressme plug-in was activated.';
-	
-	// create views table
+// create XPressME table
 	$xp_prefix = $mydirname;
 	if ($xp_prefix == 'wordpress'){
@@ -164,7 +115,80 @@
 	$wpdb->query($sql);
 	
-	// make templates
+// make templates
 	include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ;
 	$t_mess = xpress_templates_make($mid,$mydirname);
+	
+// Admin User Data write
+	// Change uid field
+	$wpdb->query("ALTER TABLE $wpdb->posts CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'");
+	$user_name = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("uname"):'admin';
+	$email = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("email"):'foo@exsample.com';
+	$pass_md5 = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("pass"):'';
+	
+	$user_id = username_exists($user_name);
+	if ( !$user_id ) {
+		$random_password = 'admin';
+		if (!$xoops_config->is_wpmu){
+			$user_id = wp_create_user($user_name, $random_password, $email);
+		} else {
+			$user_id = wpmu_create_user($user_name, $random_password, $email);
+		}
+	} else {
+		$random_password = __('User already exists.  Password inherited.');
+	}
+
+	$user = new WP_User($user_id);
+	$user->set_role('administrator');
+	'User ' . $user_name . ' of the administrator was made.';
+	// over write xoops md5 password 
+	$sql = "UPDATE $wpdb->users SET user_pass ='$pass_md5' WHERE ID = $user_id";
+	$wpdb->query($sql);
+	$ret[] = 'The password of XOOPS was copied.';
+	
+	
+// Set Default data
+	if (!$xoops_config->is_wpmu){	// for WordPress 
+		// make WordPress Default data	
+		wp_install_defaults($user_id);
+		$ret[] = 'The first sample post & comment was written.';
+		
+		// Rewrite Option for Xpress
+		//	update_option("blog_charset", wp_blog_charset());
+			update_option('blogname', $site_name );	
+			update_option('blogdescription', 'WordPress for XOOPS');
+			update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']);
+			update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/");
+			update_option("home", $site_url);
+			update_option("siteurl", $site_url);
+			update_option("what_to_show", "posts");
+			update_option('default_pingback_flag', 0);
+			$ret[] = 'The initial data was written in the data base of wordpress.';
+			
+			update_option("template", "xpress_default");
+			update_option("stylesheet", "xpress_default");
+			$ret[] = 'The default theme of wordpress was set to xpress_default.';
+		//	update_option('uploads_use_yearmonth_folders', 1);
+			update_option('upload_path', 'wp-content/uploads');
+			
+	} else {	// for WordPress MU
+		global $base,$current_site, $dirs, $wpmu_version;
+		
+		$base =  $xoops_config->mu_path_current_site;
+		$domain = $xoops_config->mu_domain_current_site;
+		$admin_email = $GLOBALS["xoopsConfig"]['adminmail'];
+		$admin_user_name = $user_name;
+		$admin_user_id = $user_id;
+		include_once($mydirpath . '/include/xpress_mu_function.php');
+		
+		do_htaccess( $xoops_config->module_path . '/htaccess.dist', $xoops_config->module_path . '/.htaccess', $base, '');
+		xpress_mu_install_defaults($domain,$base,$site_name,$admin_user_id,$admin_user_name,$admin_email);
+	}
+	
+// activate the xpressme plugin
+	require_once dirname( __FILE__ ).'/xpress_active_plugin.php';
+	if (xpress_pulugin_activation('xpressme/xpressme.php')){
+		$ret[] = 'The xpressme plug-in was activated.';
+	}
+
 	$ret = array_merge($ret,$t_mess);
 
