addError("No url is given", true); return false; } $this->init($this->mangleProperty('baseUrl', $data['baseUrl']), $data['verifyCert'], $data['verifyHostname']); return true; } public function getCredentialDefinitions(): array { return [ new BackendProperty('baseUrl', 'string'), new BackendProperty('verifyCert', 'bool', true), new BackendProperty('verifyHostname', 'bool', true) ]; } public function mangleProperty(string $prop, $value) { if ($prop === 'baseUrl') { // Update from SOAP to iCal url if (preg_match(',^(http.*?)/qisserver,', $value, $out)) { $value = $out[1] . '/qisserver/pages/cm/exa/timetable/roomScheduleCalendarExport.faces?roomId=%ID%'; } elseif (preg_match(',(.*[/=])\d*$', $value, $out)) { $value = $out[1] . '%ID%'; } elseif (substr_count($value, '/') <= 3) { if (substr($value, -1) !== '/') { $value .= '/'; } $value .= 'qisserver/pages/cm/exa/timetable/roomScheduleCalendarExport.faces?roomId=%ID%'; } } return $value; } protected function toTitle(ICalEvent $event): string { $title = parent::toTitle($event); // His in one seems to prefix *some* (but *not* all) of the lectures by their ID/("Nummer") // No clue what that format is supposed to be, this regex is some guesswork after observing this for a while return preg_replace('#^[0-9](?:[0-9]{3}[A-Z]|[0-9A-ZÄÖÜ]{3,9}-[A-Za-z0-9/_ÄÖÜäöüß.-]{4,30})\s+#u', '', $title); } public function checkConnection(): bool { if (!$this->isOK()) return false; // Older HisInOne versions returned an internal server error if you pass an invalid roomId. // Newer ones seem to return 200 OK with an empty ical file. Nevertheless, keep this attempt // with trying random room ids, in case the behavior changes again in the future. foreach ([60, 100, 5, 10, 11, 12, 13, 14, 15, 50, 110, 200, 210, 250, 300, 333, 500, 1000, 2000] as $roomId) { if ($this->downloadIcal((string)$roomId, time() + 60) !== null) return true; } return false; } public function getCacheTime(): int { return 40 * 60; } public function getRefreshTime(): int { return 20 * 60; } public function getDisplayName(): string { return "HisInOne"; } }