summaryrefslogtreecommitdiffstats
path: root/modules-available/news
diff options
context:
space:
mode:
authorSimon Rettberg2016-06-24 17:09:16 +0200
committerSimon Rettberg2016-06-24 17:09:16 +0200
commit18ba01785621894900a6407f604f315aee50f460 (patch)
treeab433d658e06044889b8b7181062a6ecf6227b09 /modules-available/news
parent[locations] Support CIDR notion (start field), tweak templates a bit (diff)
downloadslx-admin-18ba01785621894900a6407f604f315aee50f460.tar.gz
slx-admin-18ba01785621894900a6407f604f315aee50f460.tar.xz
slx-admin-18ba01785621894900a6407f604f315aee50f460.zip
[news] Fix install script (SQL syntax), add error messages/handling
Diffstat (limited to 'modules-available/news')
-rw-r--r--modules-available/news/install.inc.php49
1 files changed, 26 insertions, 23 deletions
diff --git a/modules-available/news/install.inc.php b/modules-available/news/install.inc.php
index 48e13a41..620a4580 100644
--- a/modules-available/news/install.inc.php
+++ b/modules-available/news/install.inc.php
@@ -5,32 +5,35 @@ $res = array();
if (tableExists('news')) {
- /* rename news and add column "type" */
- tableRename('news', 'vmchooser_pages');
- Database::exec("ALTER TABLE `vmchooser_pages` ADD COLUMN type varchar(10)", []);
- Database::exec("UPDATE `vmchooser_pages` set `type`='news` WHERE 1", []);
-
- finalResponse(UPDATE_DONE, 'Tables updated successfully');
-
-} else {
- $res[] = tableCreate('vmchooser_pages', "
- `newsid` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `dateline` int(10) unsigned NOT NULL,
- `title` varchar(200) DEFAULT NULL,
- `content` text,
- `type` varchar(10),
- PRIMARY KEY (`newsid`),
- KEY `dateline` (`dateline`)
- ");
+ /* rename news and add column "type" */
+ if (!tableRename('news', 'vmchooser_pages')) {
+ finalResponse(UPDATE_FAILED, "Could not rename news to vmchooser_pages: " . Database::lastError());
+ }
+ $res[] = UPDATE_DONE;
+ if (false === Database::exec("ALTER TABLE `vmchooser_pages` ADD COLUMN type VARCHAR(10)")) {
+ EventLog::warning("Could not add type column to vmchooser_pages: " . Database::lastError());
+ }
+ if (false === Database::exec("UPDATE `vmchooser_pages` SET `type` = 'news' WHERE 1")) {
+ EventLog::warning("News module update: Could not set default type to news: " . Database::lastError());
+ }
- // *crickets*
+}
- // Create response for browser
+$res[] = tableCreate('vmchooser_pages', "
+ `newsid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `dateline` int(10) unsigned NOT NULL,
+ `title` varchar(200) DEFAULT NULL,
+ `content` text,
+ `type` varchar(10),
+ PRIMARY KEY (`newsid`),
+ KEY `dateline` (`dateline`)
+");
- if (in_array(UPDATE_DONE, $res)) {
- finalResponse(UPDATE_DONE, 'Tables created successfully');
- }
+// Create response for browser
- finalResponse(UPDATE_NOOP, 'Everything already up to date');
+if (in_array(UPDATE_DONE, $res)) {
+ finalResponse(UPDATE_DONE, 'Tables created successfully');
}
+
+finalResponse(UPDATE_NOOP, 'Everything already up to date');