Index: trunk/wb/admin/templates/uninstall.php
===================================================================
--- trunk/wb/admin/templates/uninstall.php	(revision 98)
+++ trunk/wb/admin/templates/uninstall.php	(revision 99)
@@ -55,7 +55,7 @@
 
 // Check if we have permissions on the directory
 if(!is_writable(WB_PATH.'/templates/'.$file)) {
-	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
+	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL'].WB_PATH.'/templates/'.$file);
 }
 
 // Try to delete the template dir
Index: trunk/wb/admin/templates/install.php
===================================================================
--- trunk/wb/admin/templates/install.php	(revision 98)
+++ trunk/wb/admin/templates/install.php	(revision 99)
@@ -1,6 +1,6 @@
 <?php
 
-// $Id: install.php,v 1.8 2005/04/02 06:25:53 rdjurovich Exp $
+// $Id$
 
 /*
 
@@ -55,7 +55,7 @@
 // Setup the PclZip object
 $archive = new PclZip($temp_file);
 // Unzip the files to the temp unzip folder
-$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip, PCLZIP_OPT_REMOVE_ALL_PATH);
+$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip);
 // Include the templates info file
 require($temp_unzip.'info.php');
 // Delete the temp unzip directory
@@ -67,10 +67,21 @@
 	$admin->print_error($MESSAGE['GENERIC']['INVALID']);
 }
 
-// Check if a template with the same name already exists
+// Check if this module is already installed
+// and compare versions if so
+$new_template_version=$template_version;
 if(is_dir(WB_PATH.'/templates/'.$template_directory)) {
-	if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
-	$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
+	if(file_exists(WB_PATH.'/templates/'.$template_directory.'/info.php')) {
+		require(WB_PATH.'/templates/'.$template_directory.'/info.php');
+		// Version to be installed is older than currently installed version
+		if ($template_version>$new_template_version) {
+			if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
+			$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
+		}
+	} 
+	$success_message=$MESSAGE['GENERIC']['UPGRADED'];
+} else {
+	$success_message=$MESSAGE['GENERIC']['INSTALLED'];
 }
 
 // Check if template dir is writable
@@ -90,7 +101,7 @@
 }
 
 // Unzip template to the template dir
-$list = $archive->extract(PCLZIP_OPT_PATH, $template_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
+$list = $archive->extract(PCLZIP_OPT_PATH, $template_dir);
 if(!$list) {
 	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNZIP']);
 }
@@ -109,7 +120,7 @@
 }
 
 // Print success message
-$admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
+$admin->print_success($success_message);
 
 // Print admin footer
 $admin->print_footer();
Index: trunk/wb/admin/languages/install.php
===================================================================
--- trunk/wb/admin/languages/install.php	(revision 98)
+++ trunk/wb/admin/languages/install.php	(revision 99)
@@ -1,6 +1,6 @@
 <?php
 
-// $Id: install.php,v 1.5 2005/04/02 06:25:37 rdjurovich Exp $
+// $Id$
 
 /*
 
@@ -68,16 +68,8 @@
 unset($language_code);
 
 // Read the temp file and look for a language code
-$file_contents = file_get_contents($temp_file);
-$search_for_code = strstr($file_contents, '$language_code');
-if($search_for_code != '') {
-	if(strstr($search_for_code, "'")) {
-		$search_for_code2 = strstr($search_for_code, "'");
-	} else {
-		$search_for_code2 = strstr($search_for_code, '"');
-	}
-	$language_code = substr($search_for_code2, 1, 2);
-}
+require($temp_file);
+$new_language_version=$language_version;
 
 // Check if the file is valid
 if(!isset($language_code)) {
@@ -91,6 +83,14 @@
 $language_file = WB_PATH.'/languages/'.$language_code.'.php';
 
 // Move to new location
+if (file_exists($language_file)) {
+	require($language_file);
+	if ($language_version>$new_language_version) {
+		$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
+	}
+	unlink($language_file);
+}
+
 rename($temp_file, $language_file);
 
 // Chmod the file
Index: trunk/wb/admin/modules/install.php
===================================================================
--- trunk/wb/admin/modules/install.php	(revision 98)
+++ trunk/wb/admin/modules/install.php	(revision 99)
@@ -55,7 +55,7 @@
 // Setup the PclZip object
 $archive = new PclZip($temp_file);
 // Unzip the files to the temp unzip folder
-$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip, PCLZIP_OPT_REMOVE_ALL_PATH);
+$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip);
 // Include the modules info file
 require($temp_unzip.'info.php');
 // Delete the temp unzip directory
@@ -80,7 +80,7 @@
 			$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
 		}
 		$action="upgrade";
-	} 
+	}
 }
 
 // Check if module dir is writable
@@ -120,9 +120,9 @@
 }
 
 // Print success message
-if ($action="install") {
+if ($action=="install") {
 	$admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
-} else if ($action="upgrade") {
+} else if ($action=="upgrade") {
 	$admin->print_success($MESSAGE['GENERIC']['UPGRADED']);
 }	
 
