summaryrefslogtreecommitdiffstats
path: root/modules-available/baseconfig
diff options
context:
space:
mode:
authorSimon Rettberg2016-06-08 18:33:30 +0200
committerSimon Rettberg2016-06-08 18:33:30 +0200
commitffffab643e031524b6fdfe0c39adae1f6c8e9c4d (patch)
tree84e55c5a7ea0e02481b9f44730814ae788f05e12 /modules-available/baseconfig
parent[dashboard] Remove needsSchemaUpdate call (diff)
downloadslx-admin-ffffab643e031524b6fdfe0c39adae1f6c8e9c4d.tar.gz
slx-admin-ffffab643e031524b6fdfe0c39adae1f6c8e9c4d.tar.xz
slx-admin-ffffab643e031524b6fdfe0c39adae1f6c8e9c4d.zip
[install] Implement install scripts for most modules
Diffstat (limited to 'modules-available/baseconfig')
-rw-r--r--modules-available/baseconfig/install.inc.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/modules-available/baseconfig/install.inc.php b/modules-available/baseconfig/install.inc.php
new file mode 100644
index 00000000..8f1cb1e7
--- /dev/null
+++ b/modules-available/baseconfig/install.inc.php
@@ -0,0 +1,58 @@
+<?php
+
+$res = array();
+
+$res[] = tableCreate('setting_global', "
+ `setting` varchar(28) NOT NULL,
+ `value` text NOT NULL,
+ `displayvalue` text NOT NULL,
+ `enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT '1'
+ PRIMARY KEY (`setting`)
+");
+
+// Update path
+
+// Add toggle field
+
+if (!tableHasColumn('setting_global', 'enabled')) {
+ if (tableHasColumn('setting_global', 'toggle')) {
+ $ret = Database::exec("ALTER TABLE `setting_global` CHANGE `toggle` `enabled` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
+ } else {
+ $ret = Database::exec("ALTER TABLE `setting_global` ADD COLUMN `enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT '1'");
+ }
+ if ($ret === false) {
+ finalResponse(UPDATE_FAILED, 'Adding enabled to setting_global failed: ' . Database::lastError());
+ }
+}
+
+// Add displayvalue field
+
+if (!tableHasColumn('setting_global', 'displayvalue')) {
+ Database::exec("ALTER TABLE `setting_global` ADD `displayvalue` TEXT NOT NULL");
+ Database::exec("UPDATE `setting_global` SET `displayvalue` = `value`");
+ $res[] = UPDATE_DONE;
+}
+
+// Delete old tables
+
+/*
+Keep disabled for a while, in case some customer made unexpected important changes etc...
+
+if (tableExists('setting')) {
+ Database::exec('DROP TABLE setting');
+}
+if (tableExists('setting_distro')) {
+ Database::exec('DROP TABLE setting_distro');
+}
+if (tableExists('cat_setting')) {
+ Database::exec('DROP TABLE cat_setting');
+}
+*/
+
+// Create response for browser
+
+if (in_array(UPDATE_DONE, $res)) {
+ finalResponse(UPDATE_DONE, 'Tables created successfully');
+}
+
+finalResponse(UPDATE_NOOP, 'Everything already up to date');