add clearing of unused classes in lvplan caldav export lib

This commit is contained in:
Ivymaster
2026-07-07 13:42:54 +02:00
parent 280df46d6d
commit 4c1d88a054
11 changed files with 38 additions and 17 deletions
+2 -2
View File
@@ -120,8 +120,8 @@ $route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/prestudent/(:num)'] = 'a
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/person/(:num)'] = 'api/frontend/v1/stv/Students/getPerson/$1/$2';
$route['test'] = 'Test';
$route['test/.*'] = 'Test';
$route['lvplan/caldav'] = 'LvPlanCalDAV';
$route['lvplan/caldav/.*'] = 'LvPlanCalDAV';
// load routes from extensions, also look for environment-specific configs
$subdirs = ['application/config/extensions', 'application/config/' . ENVIRONMENT . '/extensions'];
@@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*/
class Test extends FHC_Controller
class LvPlanCalDAV extends FHC_Controller
{
/**
* Constructor
@@ -27,13 +27,18 @@ class Test extends FHC_Controller
$tree = array(
new \Sabre\CalDAV\Principal\Collection($principalBackend),
new SabreDAVReadOnlyCalendarRoot($principalBackend, $calendarBackend)
new \Sabre\CalDAV\CalendarRoot($principalBackend, $calendarBackend)
);
$server = new \Sabre\DAV\Server($tree);
$path = "/ma1433/core/FHC-Core/index.ci.php/test";
$server->setBaseUri($path);
$baseUri = '/' . implode('/', array_filter([
trim(BASE_LOCATION, '/'),
trim($this->config->item('index_page'), '/'),
'lvplan',
'caldav'
]));
$server->setBaseUri($baseUri);
$authBackend->setRealm('SabreDAV');
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
+1 -1
View File
@@ -13,7 +13,7 @@ class TempusJob extends JOB_Controller
$this->_ci =& get_instance();
$this->_ci->load->helper('hlp_sancho_helper');
$this->_ci->load->library('KalenderLib');
$this->_ci->load->library('KalenderLib', ["uid" => null]);
}
+4
View File
@@ -46,6 +46,8 @@ class KalenderLib
tbl_kalender.von,
tbl_kalender.bis,
tbl_kalender_ort.ort_kurzbz,
tbl_kalender_ort.ort_kurzbz as ko_ort_kurzbz,
tbl_kalender_ort.location as ko_location,
tbl_lehreinheit.lehreinheit_id,
tbl_lehreinheit.lehrveranstaltung_id,
tbl_lehreinheit.lehrfach_id,
@@ -173,6 +175,8 @@ class KalenderLib
'tooltip' => 'tip',
'status_kurzbz' => $row->status_kurzbz,
'ort_kurzbz' => isset($row->ort_kurzbz) ? $row->ort_kurzbz : '',
'ko_ort_kurzbz' => isset($row->ko_ort_kurzbz) ? $row->ko_ort_kurzbz : '',
'ko_location' => isset($row->ko_location) ? $row->ko_location : '',
'lehrform' => isset($row->lehrform_kurzbz) ? $row->lehrform_kurzbz : '',
'lehrfach' => isset($row->lehrfach_kurzbz) ? $row->lehrfach_kurzbz : '',
'lehrfach_bez' => isset($row->lehrfach_bezeichnung) ? $row->lehrfach_bezeichnung : '',
@@ -2,11 +2,6 @@
require_once __DIR__.'/caldav/SabreDAVACLPrincipalBackend.php';
require_once __DIR__.'/caldav/SabreDAVCalDAVBackend.php';
require_once __DIR__.'/caldav/SabreDAVReadOnlyACL.php';
require_once __DIR__.'/caldav/SabreDAVReadOnlyCalendarRoot.php';
require_once __DIR__.'/caldav/SabreDAVReadOnlyCalendarHome.php';
require_once __DIR__.'/caldav/SabreDAVReadOnlyCalendar.php';
require_once __DIR__.'/caldav/SabreDAVReadOnlyCalendarObject.php';
/**
* Loads the SabreDAV CalDAV classes for the LVPlan calendar endpoint.
@@ -9,6 +9,10 @@ class SabreDAVCalDAVBackend extends \Sabre\CalDAV\Backend\AbstractBackend
protected $CI;
CONST CALENDAR_NAME = 'LVPlan';
CONST CAL_CATEGORY_STUNDENPLAN = 'Stundenplan';
CONST CAL_CATEGORY_STUNDENPLAN_EXAM = 'StundenplanExam';
CONST CAL_CATEGORY_STUNDENPLAN_ONLINE = 'StundenplanOnline';
/**
* Creates the backend
*
@@ -52,11 +56,11 @@ class SabreDAVCalDAVBackend extends \Sabre\CalDAV\Backend\AbstractBackend
$calendars = array();
$calendar = array(
'id' => $user,
'uri' => 'LVPlan-'.$user,
'uri' => self::CALENDAR_NAME.'-'.$user,
'principaluri' => 'principals/'.$user,
'{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $this->buildCalendarCtag($user),
'{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet(array('VEVENT')),
'{DAV:}displayname' => 'LVPlan',
'{DAV:}displayname' => self::CALENDAR_NAME,
'{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description comes here',
'{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'Europe/Vienna',
'{http://apple.com/ns/ical/}calendar-order' => '1',
@@ -226,10 +230,23 @@ class SabreDAVCalDAVBackend extends \Sabre\CalDAV\Backend\AbstractBackend
$description = $item->lehrfach_bez . "\r\n";
if (isset($item->lektor) && is_array($item->lektor) && count($item->lektor) > 0) {
$description .= "Lehrer: " . join(", ", array_map(function($teacher) { return $teacher["kurzbz"]; }, $item->lektor)) . "\r\n";
$description .= "Lektor*in: " . join(", ", array_map(function($teacher) { return $teacher["kurzbz"]; }, $item->lektor)) . "\r\n";
}
}
$category = self::CAL_CATEGORY_STUNDENPLAN;
if ($item->type === 'lehreinheit') {
if ($item->lehrform === 'EXAM') {
$category = self::CAL_CATEGORY_STUNDENPLAN_EXAM;
} else if (!isset($item->ko_ort_kurzbz) || $item->ko_ort_kurzbz === '') {
$category = self::CAL_CATEGORY_STUNDENPLAN_ONLINE;
}
} else if ($item->type === 'reservierung' && (!isset($item->ko_ort_kurzbz) || $item->ko_ort_kurzbz === '')) {
$category = self::CAL_CATEGORY_STUNDENPLAN_ONLINE;
}
$parsedStartDate = $this->formatICalLocalDateTime($item->isostart);
$parsedEndDate = $this->formatICalLocalDateTime($item->isoend);
$lastModified = $this->formatICalUtcDateTime(isset($item->updateamum) ? $item->updateamum : null);
@@ -244,7 +261,7 @@ class SabreDAVCalDAVBackend extends \Sabre\CalDAV\Backend\AbstractBackend
.$this->buildICalTextLine('SUMMARY', $summary)
.$this->buildICalTextLine('DESCRIPTION', $description)
.$this->buildICalTextLine('LOCATION', isset($item->ort_kurzbz) ? $item->ort_kurzbz : '')
.$this->buildICalTextLine('CATEGORIES', 'Stundenplans')
.$this->buildICalTextLine('CATEGORIES', $category)
.$this->buildICalLine('DTSTART', $parsedStartDate, array('TZID' => 'Europe/Vienna'))
.$this->buildICalLine('DTEND', $parsedEndDate, array('TZID' => 'Europe/Vienna'));
@@ -271,7 +288,7 @@ class SabreDAVCalDAVBackend extends \Sabre\CalDAV\Backend\AbstractBackend
}
sort($fragments, SORT_STRING);
return 'LVPlan-'.$userUID.'-'.md5(implode('|', $fragments));
return self::CALENDAR_NAME.'-'.$userUID.'-'.md5(implode('|', $fragments));
}
protected function buildICalTextLine($name, $value, array $parameters = array())