summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/install.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-06 17:30:12 +0200
committerSimon Rettberg2017-04-06 17:30:12 +0200
commit4a230b9a4843ade82ff12fda31b771a5a9e58977 (patch)
treea9faaf7b4c9327d63302a785ddcf4e3d35e2407a /modules-available/statistics/install.inc.php
parent[statistics_reporting] Fallback to ip if client has no hostname (diff)
downloadslx-admin-4a230b9a4843ade82ff12fda31b771a5a9e58977.tar.gz
slx-admin-4a230b9a4843ade82ff12fda31b771a5a9e58977.tar.xz
slx-admin-4a230b9a4843ade82ff12fda31b771a5a9e58977.zip
[statistics] Handle client screens, manage projectors
Diffstat (limited to 'modules-available/statistics/install.inc.php')
-rw-r--r--modules-available/statistics/install.inc.php55
1 files changed, 52 insertions, 3 deletions
diff --git a/modules-available/statistics/install.inc.php b/modules-available/statistics/install.inc.php
index 7baf046e..5d8ce1bc 100644
--- a/modules-available/statistics/install.inc.php
+++ b/modules-available/statistics/install.inc.php
@@ -12,7 +12,7 @@ $res[] = tableCreate('statistic', "
`dateline` int(10) unsigned NOT NULL,
`typeid` varchar(30) NOT NULL,
`clientip` varchar(40) NOT NULL,
- `machineuuid` varchar(36) CHARACTER SET ascii DEFAULT NULL,
+ `machineuuid` char(36) CHARACTER SET ascii DEFAULT NULL,
`username` varchar(30) NOT NULL,
`data` varchar(255) NOT NULL,
PRIMARY KEY (`logid`),
@@ -24,7 +24,7 @@ $res[] = tableCreate('statistic', "
// Main table containing all known clients
-$res[] = tableCreate('machine', "
+$res[] = $machineCreate = tableCreate('machine', "
`machineuuid` char(36) CHARACTER SET ascii NOT NULL,
`fixedlocationid` int(11) DEFAULT NULL COMMENT 'Manually set location (e.g. roomplanner)',
`subnetlocationid` int(11) DEFAULT NULL COMMENT 'Automatically determined location (e.g. from subnet match),
@@ -61,6 +61,40 @@ $res[] = tableCreate('machine', "
KEY `systemmodel` (`systemmodel`)
");
+$res[] = $machineHwCreate = tableCreate('machine_x_hw', "
+ `machinehwid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `hwid` int(10) unsigned NOT NULL,
+ `machineuuid` char(36) CHARACTER SET ascii NOT NULL,
+ `devpath` char(50) CHARACTER SET ascii NOT NULL,
+ `disconnecttime` int(10) unsigned NOT NULL COMMENT 'time the device was not connected to the pc anymore for the first time, 0 if it is connected',
+ PRIMARY KEY (`machinehwid`),
+ UNIQUE KEY `hwid` (`hwid`,`machineuuid`,`devpath`),
+ KEY `machineuuid` (`machineuuid`,`hwid`),
+ KEY `disconnecttime` (`disconnecttime`)
+ ");
+
+$res[] = tableCreate('machine_x_hw_prop', "
+ `machinehwid` int(10) unsigned NOT NULL,
+ `prop` char(16) CHARACTER SET ascii NOT NULL,
+ `value` varchar(500) NOT NULL,
+ PRIMARY KEY (`machinehwid`,`prop`)
+");
+
+$res[] = tableCreate('statistic_hw', "
+ `hwid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `hwtype` char(11) CHARACTER SET ascii NOT NULL,
+ `hwname` varchar(200) NOT NULL,
+ PRIMARY KEY (`hwid`),
+ UNIQUE KEY `hwtype` (`hwtype`,`hwname`)
+");
+
+$res[] = tableCreate('statistic_hw_prop', "
+ `hwid` int(10) unsigned NOT NULL,
+ `prop` char(16) CHARACTER SET ascii NOT NULL,
+ `value` varchar(500) NOT NULL,
+ PRIMARY KEY (`hwid`,`prop`)
+");
+
// PCI-ID cache
$res[] = tableCreate('pciid', "
@@ -71,7 +105,8 @@ $res[] = tableCreate('pciid', "
PRIMARY KEY (`category`,`id`)
");
-if (in_array(UPDATE_DONE, $res)) {
+// need trigger?
+if ($machineCreate === UPDATE_DONE) {
$addTrigger = true;
}
@@ -165,6 +200,20 @@ if ($addTrigger) {
}
}
+if ($machineHwCreate === UPDATE_DONE) {
+ $ret = true;
+ $ret = Database::exec('ALTER TABLE `machine_x_hw`
+ ADD CONSTRAINT `machine_x_hw_ibfk_1` FOREIGN KEY (`hwid`) REFERENCES `statistic_hw` (`hwid`) ON DELETE CASCADE,
+ ADD CONSTRAINT `machine_x_hw_ibfk_2` FOREIGN KEY (`machineuuid`) REFERENCES `machine` (`machineuuid`) ON DELETE CASCADE') && $ret;
+ $ret = Database::exec('ALTER TABLE `machine_x_hw_prop`
+ ADD CONSTRAINT `machine_x_hw_prop_ibfk_1` FOREIGN KEY (`machinehwid`) REFERENCES `machine_x_hw` (`machinehwid`) ON DELETE CASCADE') && $ret;
+ $ret = Database::exec('ALTER TABLE `statistic_hw_prop`
+ ADD CONSTRAINT `statistic_hw_prop_ibfk_1` FOREIGN KEY (`hwid`) REFERENCES `statistic_hw` (`hwid`) ON DELETE CASCADE') && $ret;
+ if ($ret === false) {
+ finalResponse(UPDATE_FAILED, 'Adding foreign key machineuuid to hardware* failed: ' . Database::lastError());
+ }
+}
+
// Create response
if (in_array(UPDATE_DONE, $res)) {