Project

General

Profile

« Previous | Next » 

Revision 99

Added by stefan about 19 years ago

Implemented upgrade functionality in templates and languages. Fixed some bugs.

View differences:

trunk/wb/admin/templates/uninstall.php
55 55

  
56 56
// Check if we have permissions on the directory
57 57
if(!is_writable(WB_PATH.'/templates/'.$file)) {
58
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
58
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL'].WB_PATH.'/templates/'.$file);
59 59
}
60 60

  
61 61
// Try to delete the template dir
trunk/wb/admin/templates/install.php
1 1
<?php
2 2

  
3
// $Id: install.php,v 1.8 2005/04/02 06:25:53 rdjurovich Exp $
3
// $Id$
4 4

  
5 5
/*
6 6

  
......
55 55
// Setup the PclZip object
56 56
$archive = new PclZip($temp_file);
57 57
// Unzip the files to the temp unzip folder
58
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip, PCLZIP_OPT_REMOVE_ALL_PATH);
58
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip);
59 59
// Include the templates info file
60 60
require($temp_unzip.'info.php');
61 61
// Delete the temp unzip directory
......
67 67
	$admin->print_error($MESSAGE['GENERIC']['INVALID']);
68 68
}
69 69

  
70
// Check if a template with the same name already exists
70
// Check if this module is already installed
71
// and compare versions if so
72
$new_template_version=$template_version;
71 73
if(is_dir(WB_PATH.'/templates/'.$template_directory)) {
72
	if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
73
	$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
74
	if(file_exists(WB_PATH.'/templates/'.$template_directory.'/info.php')) {
75
		require(WB_PATH.'/templates/'.$template_directory.'/info.php');
76
		// Version to be installed is older than currently installed version
77
		if ($template_version>$new_template_version) {
78
			if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
79
			$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
80
		}
81
	} 
82
	$success_message=$MESSAGE['GENERIC']['UPGRADED'];
83
} else {
84
	$success_message=$MESSAGE['GENERIC']['INSTALLED'];
74 85
}
75 86

  
76 87
// Check if template dir is writable
......
90 101
}
91 102

  
92 103
// Unzip template to the template dir
93
$list = $archive->extract(PCLZIP_OPT_PATH, $template_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
104
$list = $archive->extract(PCLZIP_OPT_PATH, $template_dir);
94 105
if(!$list) {
95 106
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNZIP']);
96 107
}
......
109 120
}
110 121

  
111 122
// Print success message
112
$admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
123
$admin->print_success($success_message);
113 124

  
114 125
// Print admin footer
115 126
$admin->print_footer();
trunk/wb/admin/languages/install.php
1 1
<?php
2 2

  
3
// $Id: install.php,v 1.5 2005/04/02 06:25:37 rdjurovich Exp $
3
// $Id$
4 4

  
5 5
/*
6 6

  
......
68 68
unset($language_code);
69 69

  
70 70
// Read the temp file and look for a language code
71
$file_contents = file_get_contents($temp_file);
72
$search_for_code = strstr($file_contents, '$language_code');
73
if($search_for_code != '') {
74
	if(strstr($search_for_code, "'")) {
75
		$search_for_code2 = strstr($search_for_code, "'");
76
	} else {
77
		$search_for_code2 = strstr($search_for_code, '"');
78
	}
79
	$language_code = substr($search_for_code2, 1, 2);
80
}
71
require($temp_file);
72
$new_language_version=$language_version;
81 73

  
82 74
// Check if the file is valid
83 75
if(!isset($language_code)) {
......
91 83
$language_file = WB_PATH.'/languages/'.$language_code.'.php';
92 84

  
93 85
// Move to new location
86
if (file_exists($language_file)) {
87
	require($language_file);
88
	if ($language_version>$new_language_version) {
89
		$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
90
	}
91
	unlink($language_file);
92
}
93

  
94 94
rename($temp_file, $language_file);
95 95

  
96 96
// Chmod the file
trunk/wb/admin/modules/install.php
55 55
// Setup the PclZip object
56 56
$archive = new PclZip($temp_file);
57 57
// Unzip the files to the temp unzip folder
58
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip, PCLZIP_OPT_REMOVE_ALL_PATH);
58
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip);
59 59
// Include the modules info file
60 60
require($temp_unzip.'info.php');
61 61
// Delete the temp unzip directory
......
80 80
			$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
81 81
		}
82 82
		$action="upgrade";
83
	} 
83
	}
84 84
}
85 85

  
86 86
// Check if module dir is writable
......
120 120
}
121 121

  
122 122
// Print success message
123
if ($action="install") {
123
if ($action=="install") {
124 124
	$admin->print_success($MESSAGE['GENERIC']['INSTALLED']);
125
} else if ($action="upgrade") {
125
} else if ($action=="upgrade") {
126 126
	$admin->print_success($MESSAGE['GENERIC']['UPGRADED']);
127 127
}	
128 128

  

Also available in: Unified diff