summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend/coursebackend_ical.inc.php
blob: f1791c4ea318cc6635157b037347d8f47edd8cb8 (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
54
55
56
57
58
59
60
61
<?php

class CourseBackend_ICal extends ICalCourseBackend
{

	/** @var string room ID for testing connection */
	private $testId;

	public function setCredentialsInternal(array $data): bool
	{
		if (empty($data['baseUrl'])) {
			$this->addError("No url is given", true);
			return false;
		}

		$this->init($data['baseUrl'], $data['verifyCert'], $data['verifyHostname'], $data['authMethod'],
			$data['user'], $data['pass']);
		$this->testId = $data['testId'];

		return true;
	}

	public function getCredentialDefinitions(): array
	{
		return [
			new BackendProperty('baseUrl', 'string'),
			new BackendProperty('verifyCert', 'bool', true),
			new BackendProperty('verifyHostname', 'bool', true),
			new BackendProperty('testId', 'string'),
			new BackendProperty('authMethod', ['NONE', 'BASIC', 'DIGEST', 'GSSNEGOTIATE', 'NTLM'], 'NONE'),
			new BackendProperty('user', 'string'),
			new BackendProperty('pass', 'string'),
		];
	}

	public function checkConnection(): bool
	{
		if (!$this->isOK())
			return false;
		if (empty($this->testId))
			return true;
		return ($this->downloadIcal($this->testId) !== null);
	}

	public function getCacheTime(): int
	{
		return 30 * 60;
	}

	public function getRefreshTime(): int
	{
		return 60 * 60;
	}


	public function getDisplayName(): string
	{
		return "iCal";
	}

}