summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/locationinfohooks.inc.php
blob: 094890155b50678f172b476c3c10e6e1209897a9 (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
49
50
51
52
53
<?php

class LocationInfoHooks
{

	/**
	 * @param string $uuid panel uuid
	 * @return bool|string panel name if exists, false otherwise
	 */
	public static function getPanelName($uuid)
	{
		$ret = Database::queryFirst('SELECT panelname FROM locationinfo_panel WHERE paneluuid = :uuid', compact('uuid'));
		if ($ret === false)
			return false;
		return $ret['panelname'];
	}

	/**
	 * Hook called by runmode module where we should modify the client config according to our
	 * needs. Disable standby/logout timeouts, enable autologin, set URL.
	 *
	 * @param $machineUuid
	 * @param $panelUuid
	 */
	public static function configHook($machineUuid, $panelUuid)
	{
		$type = InfoPanel::getConfig($panelUuid, $data);
		if ($type === false)
			return; // TODO: Invalid panel - what should we do?
		if ($type === 'URL') {
			// Check if we should set the insecure SSL mode (accept invalid/self signed certs etc.)
			if ($data['insecure-ssl'] !== 0) {
				ConfigHolder::add('SLX_BROWSER_INSECURE', '1');
			}
			if ($data['reload-minutes'] > 0) {
				ConfigHolder::add('SLX_BROWSER_RELOAD_SECS', $data['reload-minutes'] * 60);
			}
			ConfigHolder::add('SLX_BROWSER_URL', $data['url']);
			ConfigHolder::add('SLX_BROWSER_URLLIST', $data['urllist']);
			ConfigHolder::add('SLX_BROWSER_IS_WHITELIST', $data['iswhitelist']);
		} else {
			// Not URL panel
			ConfigHolder::add('SLX_BROWSER_URL', 'http://' . $_SERVER['SERVER_ADDR'] . '/panel/' . $panelUuid);
			ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); // TODO: Sat server might redirect to HTTPS, which in turn could have a self-signed cert - push to client
		}
		ConfigHolder::add('SLX_ADDONS', '', 1000);
		ConfigHolder::add('SLX_LOGOUT_TIMEOUT', '', 1000);
		ConfigHolder::add('SLX_SCREEN_STANDBY_TIMEOUT', '', 1000);
		ConfigHolder::add('SLX_SYSTEM_STANDBY_TIMEOUT', '', 1000);
		ConfigHolder::add('SLX_AUTOLOGIN', '1', 1000);
	}

}