<?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";
}
}