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 form 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-9A-ZÄÖÜ]{3,9}-[A-Za-z0-9/_ÄÖÜäöüß.-]{4,30}\s+#u', '', $title); } public function checkConnection(): bool { if (!$this->isOK()) return false; // Unfortunately HisInOne returns an internal server error if you pass an invalid roomId. // So we just try a bunch and see if anything works. Even if this fails, using // the backend should work, given the URL is actually correct. foreach ([60, 100, 5, 10, 50, 110, 200, 210, 250, 300, 333, 500, 1000, 2000] as $roomId) { if ($this->downloadIcal($roomId) !== null) return true; } return false; } public function getCacheTime(): int { return 30 * 60; } public function getRefreshTime(): int { return 60 * 60; } public function getDisplayName(): string { return "HisInOne"; } }