Revision 373
Added by Matthias almost 19 years ago
| functions.php | ||
|---|---|---|
| 754 | 754 |
} |
| 755 | 755 |
} |
| 756 | 756 |
|
| 757 |
// Upgrade module info in DB, optionally start upgrade script |
|
| 758 |
function upgrade_module($directory, $upgrade = false) {
|
|
| 759 |
global $database, $admin, $MESSAGE; |
|
| 760 |
$directory = WB_PATH . "/modules/$directory"; |
|
| 761 |
if(file_exists($directory.'/info.php')) {
|
|
| 762 |
require($directory.'/info.php'); |
|
| 763 |
if(isset($module_name)) {
|
|
| 764 |
if(!isset($module_license)) { $module_license = 'GNU General Public License'; }
|
|
| 765 |
if(!isset($module_platform) AND isset($module_designed_for)) { $module_platform = $module_designed_for; }
|
|
| 766 |
if(!isset($module_function) AND isset($module_type)) { $module_function = $module_type; }
|
|
| 767 |
$module_function = strtolower($module_function); |
|
| 768 |
// Check that it does already exist |
|
| 769 |
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$module_directory."' LIMIT 0,1");
|
|
| 770 |
if($result->numRows() > 0) {
|
|
| 771 |
// Update in DB |
|
| 772 |
$query = "UPDATE " . TABLE_PREFIX . "addons SET " . |
|
| 773 |
"version = '$module_version', " . |
|
| 774 |
"description = '" . addslashes($module_description) . "', " . |
|
| 775 |
"platform = '$module_platform', " . |
|
| 776 |
"author = '$module_author', " . |
|
| 777 |
"license = '$module_license'" . |
|
| 778 |
"WHERE directory = '$module_directory'"; |
|
| 779 |
$database->query($query); |
|
| 780 |
// Run upgrade script |
|
| 781 |
if($upgrade == true) {
|
|
| 782 |
if(file_exists($directory.'/upgrade.php')) {
|
|
| 783 |
require($directory.'/upgrade.php'); |
|
| 784 |
} |
|
| 785 |
} |
|
| 786 |
} |
|
| 787 |
} |
|
| 788 |
} |
|
| 789 |
} |
|
| 790 |
|
|
| 757 | 791 |
?> |
Also available in: Unified diff
Fixed addons table isn't updated when a modul is updated (#332)
Added new upgrade_function (thanks to kozmoz)