blob: b17cf4a9e43847b845675c25a4f61e6370d6affd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?php
class StatisticsHooks
{
private static $row = false;
private static function getRow(string $machineuuid)
{
if (self::$row !== false)
return;
self::$row = Database::queryFirst('SELECT hostname, clientip, locationid FROM machine WHERE machineuuid = :machineuuid',
['machineuuid' => $machineuuid]);
}
public static function getBaseconfigName(string $machineuuid): string
{
self::getRow($machineuuid);
if (self::$row === false)
return false;
return self::$row['hostname'] ?: self::$row['clientip'];
}
public static function baseconfigLocationResolver(string $machineuuid): int
{
self::getRow($machineuuid);
if (self::$row === false)
return 0;
return (int)self::$row['locationid'];
}
/**
* Hook to get inheritance tree for all config vars.
*
* @param string $machineuuid MachineUUID currently being edited
*/
public static function baseconfigInheritance(string $machineuuid): array
{
self::getRow($machineuuid);
if (self::$row === false)
return [];
BaseConfig::prepareWithOverrides([
'locationid' => self::$row['locationid']
]);
return ConfigHolder::getRecursiveConfig(true);
}
}
|