Skip to content

Commit

Permalink
If a module has been installed and the module files were deleted, the…
Browse files Browse the repository at this point in the history
… parameters would still exist in the database. If the module files were copied again to the modules directory, installing the module would introduce duplicate module parameters, so when installing a module, check if it has been installed previously and call its remove() function before installing the module again.
  • Loading branch information
scottcwilson authored and haraldpdl committed Jun 4, 2014
1 parent 32237c6 commit dd85c79
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions catalog/admin/modules.php
Expand Up @@ -46,17 +46,29 @@
include($module_directory . $class . $file_extension);
$module = new $class;
if ($action == 'install') {
if ($module->check() > 0) { // remove module if already installed
$module->remove();
}

$module->install();

$modules_installed = explode(';', constant($module_key));
$modules_installed[] = $class . $file_extension;

if (!in_array($class . $file_extension, $modules_installed)) {
$modules_installed[] = $class . $file_extension;
}

tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . implode(';', $modules_installed) . "' where configuration_key = '" . $module_key . "'");
tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class));
} elseif ($action == 'remove') {
$module->remove();

$modules_installed = explode(';', constant($module_key));
unset($modules_installed[array_search($class . $file_extension, $modules_installed)]);

if (in_array($class . $file_extension, $modules_installed)) {
unset($modules_installed[array_search($class . $file_extension, $modules_installed)]);
}

tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . implode(';', $modules_installed) . "' where configuration_key = '" . $module_key . "'");
tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set));
}
Expand Down Expand Up @@ -178,7 +190,7 @@
}
?>
<td class="dataTableContent"><?php echo $module->title; ?></td>
<td class="dataTableContent" align="right"><?php if (is_numeric($module->sort_order)) echo $module->sort_order; ?></td>
<td class="dataTableContent" align="right"><?php if (in_array($module->code . $file_extension, $modules_installed) && is_numeric($module->sort_order)) echo $module->sort_order; ?></td>
<td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . (isset($HTTP_GET_VARS['list']) ? '&list=new' : '') . '&module=' . $class) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
</tr>
<?php
Expand Down Expand Up @@ -246,7 +258,7 @@
default:
$heading[] = array('text' => '<strong>' . $mInfo->title . '</strong>');

if ($mInfo->status == '1') {
if (in_array($mInfo->code . $file_extension, $modules_installed) && ($mInfo->status > 0)) {
$keys = '';
reset($mInfo->keys);
while (list(, $value) = each($mInfo->keys)) {
Expand Down

0 comments on commit dd85c79

Please sign in to comment.