summaryrefslogtreecommitdiffstats
path: root/modules-available/usblockoff/install.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/usblockoff/install.inc.php')
-rw-r--r--modules-available/usblockoff/install.inc.php39
1 files changed, 37 insertions, 2 deletions
diff --git a/modules-available/usblockoff/install.inc.php b/modules-available/usblockoff/install.inc.php
index 690f45d4..967771d1 100644
--- a/modules-available/usblockoff/install.inc.php
+++ b/modules-available/usblockoff/install.inc.php
@@ -1,7 +1,7 @@
<?php
$res = array();
-
+/*
$t1 = $res[] = tableCreate('usb_devices', '
`uid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`id` varchar(50),
@@ -13,8 +13,25 @@ $t1 = $res[] = tableCreate('usb_devices', '
`ruleInformation` varchar(1024),
PRIMARY KEY (`uid`)
');
+*/
+
+$t1 = $res[] = tableCreate('usblockoff_hw', '
+ `hwid` INT(10) UNSIGNED NOT NULL ,
+ `serial` VARCHAR(128),
+ PRIMARY KEY (`hwid`, `serial`)
+');
+
+$t2 = $res[] = tableCreate('usblockoff_hw_prop', '
+ `hwid` INT(10) UNSIGNED NOT NULL ,
+ `serial` VARCHAR(128),
+ `prop` CHAR(16),
+ `value` VARCHAR(500),
+ PRIMARY KEY (`hwid`, `serial`, `prop`)
+');
-$t2 = $res[] = tableCreate('usb_configs', '
+// TODO: ADD CONSTRAINT
+
+$res[] = tableCreate('usb_configs', '
`configid` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`configname` VARCHAR(200) NOT NULL,
`rulesconfig` BLOB,
@@ -23,6 +40,24 @@ $t2 = $res[] = tableCreate('usb_configs', '
');
//$ret = Database::exec("DROP TABLE `usb_devices`");
+//$ret = Database::exec("DROP TABLE `usblockoff_hw`");
+//$ret = Database::exec("DROP TABLE `usblockoff_hw_prop`");
+
+if ($t1 === UPDATE_DONE || $t2 === UPDATE_DONE) {
+ $ret = Database::exec('ALTER TABLE `usblockoff_hw`
+ ADD CONSTRAINT `usblockoff_hw_ibfk_1` FOREIGN KEY (`hwid`) REFERENCES `statistic_hw` (`hwid`) ON DELETE CASCADE');
+ if ($ret === false) {
+ finalResponse(UPDATE_FAILED, 'Adding constraints to usblockoff_hw failed: ' . Database::lastError());
+ }
+
+ $ret = Database::exec('ALTER TABLE `usblockoff_hw_prop`
+ ADD CONSTRAINT `usblockoff_hw__prop_ibfk_1` FOREIGN KEY (`hwid`, `serial`) REFERENCES `usblockoff_hw` (`hwid`, `serial`) ON DELETE CASCADE');
+ if ($ret === false) {
+ finalResponse(UPDATE_FAILED, 'Adding constraints to usblockoff_hw_prop failed: ' . Database::lastError());
+ }
+ $res[] = UPDATE_DONE;
+}
+
if (in_array(UPDATE_DONE, $res)) {
finalResponse(UPDATE_DONE, 'Table created successfully');