|
7 | 7 | * @copyright (c) 2014-2019, Zen4All
|
8 | 8 | * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License V2.0
|
9 | 9 | */
|
10 |
| - if (!defined('IS_ADMIN_FLAG')) { |
11 |
| - die('Illegal access'); |
12 |
| - } |
13 |
| - |
14 |
| - $module_constant = 'SO_VERSION'; |
15 |
| - $module_installer_directory = DIR_FS_ADMIN . 'includes/installers/super_orders'; |
16 |
| - $module_name = 'Super Orders'; |
17 |
| - $module_file_for_version_check = ''; |
18 |
| - $zencart_com_plugin_id = 155; |
19 |
| - |
20 |
| - $configuration_group_id = ''; |
21 |
| - if (defined($module_constant)) { |
22 |
| - $current_version = constant($module_constant); |
23 |
| - } else { |
24 |
| - $current_version = '0.0.0'; |
25 |
| - $db->Execute("INSERT INTO " . TABLE_CONFIGURATION_GROUP . " (configuration_group_title, configuration_group_description, sort_order, visible) |
26 |
| - VALUES ('" . $module_name . "', '" . $module_name . " Settings', '1', '1');"); |
27 |
| - $configuration_group_id = $db->Insert_ID(); |
| 10 | +if (!defined('IS_ADMIN_FLAG')) { |
| 11 | + die('Illegal Access'); |
| 12 | +} |
28 | 13 |
|
| 14 | +$module_constant = 'SO_VERSION'; |
| 15 | +$module_installer_directory = DIR_FS_ADMIN . 'includes/installers/super_orders'; |
| 16 | +$module_name = 'Super Orders'; |
| 17 | +$zencart_com_plugin_id = 155; |
| 18 | + |
| 19 | +$configuration_group_id = ''; |
| 20 | +if (defined($module_constant)) { |
| 21 | + $current_version = constant($module_constant); |
| 22 | +} else { |
| 23 | + $current_version = '0.0.0'; |
| 24 | + // Checking for old Existing Super Orders installtions in database |
| 25 | + $check = $db->Execute("SELECT configuration_group_id |
| 26 | + FROM " . TABLE_CONFIGURATION_GROUP . " |
| 27 | + WHERE configuration_group_title = '" . $module_name . "'"); |
| 28 | + if ($check->RecordCount() < 0) { |
| 29 | + $db->Execute("INSERT INTO " . TABLE_CONFIGURATION_GROUP . " (configuration_group_title, configuration_group_description, sort_order, visible) |
| 30 | + VALUES ('" . $module_name . "', '" . $module_name . " Settings', '1', '1');"); |
| 31 | + $configuration_group_id = $db->Insert_ID(); |
| 32 | + } else { |
| 33 | + $configuration_group_id = $check->fields['configuration_group_id']; |
| 34 | + } |
29 | 35 | $db->Execute("UPDATE " . TABLE_CONFIGURATION_GROUP . "
|
30 | 36 | SET sort_order = " . $configuration_group_id . "
|
31 | 37 | WHERE configuration_group_id = " . $configuration_group_id . ";");
|
|
42 | 48 | $installers = scandir($module_installer_directory, 1);
|
43 | 49 |
|
44 | 50 | $newest_version = $installers[0];
|
45 |
| -$newest_version = substr($newest_version, 0 - 4); |
| 51 | +$newest_version = substr($newest_version, 0, -4); |
46 | 52 |
|
47 | 53 | sort($installers);
|
48 | 54 | if (version_compare($newest_version, $current_version) > 0) {
|
49 | 55 | foreach ($installers as $installer) {
|
50 |
| - if (version_compare($newest_version, substr($installer, 0, - 4)) >= 0 && version_compare($current_version, substr($installer, 0, - 4)) < 0) { |
| 56 | + if (version_compare($newest_version, substr($installer, 0, -4)) >= 0 && version_compare($current_version, substr($installer, 0, -4)) < 0) { |
51 | 57 | include($module_installer_directory . '/' . $installer);
|
52 |
| - $current_version = str_replace('_', '.', substr($installer, 0, - 4)); |
| 58 | + $current_version = str_replace('_', '.', substr($installer, 0, -4)); |
53 | 59 | $db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '" . $current_version . "' WHERE configuration_key = '" . $module_constant . "' LIMIT 1;");
|
54 | 60 | $messageStack->add("Installed " . $module_name . " v" . $current_version, 'success');
|
55 | 61 | }
|
|
0 commit comments