summaryrefslogtreecommitdiffstats
path: root/modules-available/remoteaccess/baseconfig/getconfig.inc.php
blob: 182daef1c2d7e9c94c1f569a285adb72fab07778 (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
<?php

/** @var ?string $uuid */
/** @var ?string $ip */

if ($uuid !== null) {
	// Leave clients in any runmode alone
	$res = Database::queryFirst('SELECT machineuuid FROM runmode WHERE machineuuid = :uuid',
		['uuid' => $uuid], true);
	if (is_array($res))
		return;

	// Locations from closest to furthest (order)
	$locationId = ConfigHolder::get('SLX_LOCATIONS');
	if ($locationId === null)
		return;
	$locationId = (int)$locationId;
	$ret = Database::queryFirst("SELECT l.locationid FROM remoteaccess_x_location l
		INNER JOIN remoteaccess_group g USING (groupid)
		WHERE locationid = :lid AND g.active = 1",
		['lid' => $locationId], true); // TODO Remove true after next point release (2020-05-12)
	if ($ret === false)
		return;
	// Special case – location admin can limit accessibility of this machine to never, or only when room is closed
	$opts = Scheduler::getLocationOptions($locationId);
	if ($opts['ra-mode'] === Scheduler::RA_NEVER)
		return; // Completely disallowed
	if ($opts['ra-mode'] === Scheduler::RA_SELECTIVE) {
		// Only when room is closed
		if (OpeningTimes::isRoomOpen($locationId, $opts['wol-offset'], $opts['sd-offset']))
			return; // Open, do not interfere with ongoing lectures etc., do nothing
	}
	// TODO Properly merge
	if (Property::get(RemoteAccess::PROP_TRY_VIRT_HANDOVER)) {
		ConfigHolder::add("SLX_REMOTE_VNC", 'vmware virtualbox');
	} else {
		ConfigHolder::add("SLX_REMOTE_VNC", 'x11vnc');
	}
	ConfigHolder::add("SLX_REMOTE_HOST_ACCESS", Property::get(RemoteAccess::PROP_ALLOWED_VNC_NET));
	ConfigHolder::add('SLX_REMOTE_VNC_PORT', Property::get(RemoteAccess::PROP_VNC_PORT, 5900));
	ConfigHolder::add('SLX_RUNMODE_MODULE', 'remoteaccess');
	// No saver
	$saverTimeout = ConfigHolder::get('SLX_SCREEN_SAVER_TIMEOUT');
	if (!is_numeric($saverTimeout) || $saverTimeout < 1800) {
		ConfigHolder::add('SLX_SCREEN_SAVER_TIMEOUT', '1800', 1000);
	}
	ConfigHolder::add('SLX_SCREEN_SAVER_GRACE_TIME', '86400', 1000);
	// Autologin will never work as the machine is immediately in use and will never get assigned
	ConfigHolder::add('SLX_AUTOLOGIN', 'OFF', 10000);
}