summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/inc/statisticshooks.inc.php
blob: ead4917bf9ee435dec35bfae05e667f423306e99 (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
<?php

class StatisticsHooks
{

	private static $row = false;

	private static function getRow($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($machineuuid)
	{
		self::getRow($machineuuid);
		if (self::$row === false)
			return false;
		return self::$row['hostname'] ? self::$row['hostname'] : self::$row['clientip'];
	}

	public static function getBaseconfigParent($machineuuid)
	{
		return false; // TODO
	}

	public static function baseconfigLocationResolver($machineuuid)
	{
		self::getRow($machineuuid);
		if (self::$row === false)
			return 0;
		return (int)self::$row['locationid'];
	}

}