Project

General

Profile

« Previous | Next » 

Revision 67

Added by stefan about 19 years ago

Implemented Installation of modules on top of an older version. This is done via checking $module_version. Instead of install.php, upgrade.php is then called if it exists in the module package. For module developers: $module_version and $new_module_version are accessible in upgrade.php to find out what upgrade steps need to be taken.

View differences:

install.php
1 1
<?php
2 2

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

  
5 5
/*
6 6

  
......
67 67
	$admin->print_error($MESSAGE['GENERIC']['INVALID']);
68 68
}
69 69

  
70
// Check if a module with the same name already exists
70
// Check if this module is already installed
71
// and compare versions if so
72
$new_module_version=$module_version;
71 73
if(is_dir(WB_PATH.'/modules/'.$module_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.'/modules/'.$module_directory.'/info.php')) {
75
		require(WB_PATH.'/modules/'.$module_directory.'/info.php');
76
		// Version to be installed is older than currently installed version
77
		if ($module_version>$new_module_version) {
78
			if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
79
			$admin->print_error($MESSAGE['GENERIC']['ALREADY_INSTALLED']);
80
		}
81
		$action="upgrade";
82
	} else {
83
		$action="install";
84
	}
74 85
}
75 86

  
87

  
76 88
// Check if module dir is writable
77 89
if(!is_writable(WB_PATH.'/modules/')) {
78 90
	if(file_exists($temp_file)) { unlink($temp_file); } // Remove temp file
......
104 116
	}
105 117
}
106 118

  
107
// Run the modules install script if there is one
108
if(file_exists(WB_PATH.'/modules/'.$module_directory.'/install.php')) {
109
	require(WB_PATH.'/modules/'.$module_directory.'/install.php');
119
// Run the modules install // upgrade script if there is one
120
if(file_exists(WB_PATH.'/modules/'.$module_directory.'/'.$action.'.php')) {
121
	require(WB_PATH.'/modules/'.$module_directory.'/'.$action.'.php');
110 122
}
111 123

  
112 124
// Print success message

Also available in: Unified diff