Index: trunk/include/oninstall.php
===================================================================
--- trunk/include/oninstall.php	(revision 81)
+++ trunk/include/oninstall.php	(revision 89)
@@ -87,5 +87,5 @@
 //   	require_once($mydirpath . '/include/user_sync.php');
 	$sync_messg = '';
-	xpress_user_sync($ID,$sync_messg);		//this function in XPressME plugin 
+//	user_sync_to_wordpress($ID,$sync_messg);		//this function in XPressME plugin 
 
 	// Set Default data
@@ -138,7 +138,45 @@
 	$sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')";
 	$wpdb->query($sql);
-	// make templates
-//	include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates.php' ;
-//	$ret = xpress_install_templates($mid,$mydirname);
+	
+	// TEMPLATES
+	$tplfile_handler =& xoops_gethandler( 'tplfile' ) ;
+	$tpl_path = dirname( dirname( __FILE__ ) ).'/templates/source' ;
+	if( $handler = @opendir( $tpl_path . '/' ) ) {
+		while( ( $file = readdir( $handler ) ) !== false ) {
+			if( substr( $file , 0 , 1 ) == '.' ) continue ;
+			$file_path = $tpl_path . '/' . $file ;
+			if( is_file( $file_path ) ) {
+				$mtime = intval( @filemtime( $file_path ) ) ;
+				$tplfile =& $tplfile_handler->create() ;
+				$tplfile->setVar( 'tpl_source' , file_get_contents( $file_path ) , true ) ;
+				$tplfile->setVar( 'tpl_refid' , $mid ) ;
+				$tplfile->setVar( 'tpl_tplset' , 'default' ) ;
+				$tplfile->setVar( 'tpl_file' , $mydirname . '_' . $file ) ;
+				$tplfile->setVar( 'tpl_desc' , '' , true ) ;
+				$tplfile->setVar( 'tpl_module' , $mydirname ) ;
+				$tplfile->setVar( 'tpl_lastmodified' , $mtime ) ;
+				$tplfile->setVar( 'tpl_lastimported' , 0 ) ;
+				$tplfile->setVar( 'tpl_type' , 'block' ) ;
+				if( ! $tplfile_handler->insert( $tplfile ) ) {
+					$ret[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> to the database.</span><br />';
+				} else {
+					$tplid = $tplfile->getVar( 'tpl_id' ) ;
+					$ret[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> added to the database. (ID: <b>'.$tplid.'</b>)<br />';
+					// generate compiled file
+					include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
+					include_once XOOPS_ROOT_PATH.'/class/template.php' ;
+					if( ! xoops_template_touch( $tplid ) ) {
+						$ret[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b>.</span><br />';
+					} else {
+						$ret[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> compiled.</span><br />';
+					}
+				}
+			}
+		}
+		closedir( $handler ) ;
+	}
+	include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
+	include_once XOOPS_ROOT_PATH.'/class/template.php' ;
+	xoops_template_clear_module_cache( $mid ) ;
 
 	return true ;
