Add revert for sabredav version update

This commit is contained in:
Ivymaster
2026-09-28 09:48:23 +02:00
parent 32c02f3520
commit e483e550bc
25 changed files with 155 additions and 1539 deletions
-2
View File
@@ -139,8 +139,6 @@ $route['api/frontend/v1/treemenudata/lvverwaltung/stdsem/(:any)/emp/(:any)/stg/(
$route['api/frontend/v1/lvplan/calendar-events'] = 'api/frontend/v1/LvPlanCalendarEvents/getCalendarData';
$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'];
-58
View File
@@ -1,58 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*/
class LvPlanCalDAV extends FHC_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('sabredav/SabreDAVAuthLib');
$this->load->library('sabredav/SabreDAVCalDAVLib');
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
public function index()
{
$authBackend = new SabreDAVAuthLib();
$principalBackend = new SabreDAVACLPrincipalBackend($authBackend);
$calendarBackend = new SabreDAVCalDAVBackend($authBackend);
$tree = array(
new \Sabre\CalDAV\Principal\Collection($principalBackend),
new \Sabre\CalDAV\CalendarRoot($principalBackend, $calendarBackend)
);
$server = new \Sabre\DAV\Server($tree);
$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);
$server->addPlugin($authPlugin);
$caldavPlugin = new \Sabre\CalDAV\Plugin();
$server->addPlugin($caldavPlugin);
$aclPlugin = new \Sabre\DAVACL\Plugin();
$server->addPlugin($aclPlugin);
$browser = new \Sabre\DAV\Browser\Plugin();
$server->addPlugin($browser);
$server->exec();
}
}
@@ -625,21 +625,6 @@ class MigrateKalender extends CLI_Controller
}
}
$rooms = is_array($block->orte_kurzbz) ? $block->orte_kurzbz : explode(',', $block->orte_kurzbz ?? '');
foreach ($rooms as $room_kurzbz)
{
$room_kurzbz = trim($room_kurzbz);
if (!empty($room_kurzbz))
{
$this->KalenderOrtModel->insert(
array (
'kalender_id' => $kalender_id,
'ort_kurzbz' => $room_kurzbz
)
);
}
}
foreach ($block->svg_kombis as $kombi_str)
{
$kombi_str = trim($kombi_str, '()');
+1 -1
View File
@@ -579,4 +579,4 @@ function generateUUID()
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
}
-11
View File
@@ -1590,17 +1590,6 @@ class KalenderLib
$kalender_entry = getData($entryResult);
$calendarResources = $this->_ci->BetriebsmittelKalenderModel->loadWhere(['eindeutige_kalender_gruppen_id' => $kalender_entry->eindeutige_kalender_gruppen_id]);
if (isError($calendarResources)) return $calendarResources;
$calendarResourcesItems = getData($calendarResources);
$calendarResourcesIDs = [];
if (is_array($calendarResourcesItems)) {
$calendarResourcesIDs = array_map(function($resource) {
return $resource->betriebsmittel_id;
}, getData($calendarResources));
}
if (!$this->_checkPermission($kalender_entry->lehreinheit_id))
{
@@ -308,4 +308,4 @@ class LectureCollisionCheck implements ICollisionCheck
}, getData($result));
}
}
}
@@ -1,38 +0,0 @@
<?php
class SabreDAVAuthLib extends \Sabre\DAV\Auth\Backend\AbstractBasic
{
private $_ci;
protected $currentUser = null;
public function __construct()
{
$this->_ci =& get_instance();
$this->_ci->load->library('AuthLib', array(false));
$this->_ci->load->helper('hlp_authentication');
}
public function getCurrentUser()
{
if ($this->currentUser)
return $this->currentUser;
if (isLogged())
return getAuthUID();
return null;
}
protected function validateUserPass($username, $password)
{
if (isSuccess($this->_ci->authlib->checkUserAuthByUsernamePassword($username, $password)))
{
$this->currentUser = $username;
return true;
}
$this->currentUser = null;
return false;
}
}
@@ -1,11 +0,0 @@
<?php
require_once __DIR__.'/caldav/SabreDAVACLPrincipalBackend.php';
require_once __DIR__.'/caldav/SabreDAVCalDAVBackend.php';
/**
* Loads the SabreDAV CalDAV classes for the LVPlan calendar endpoint.
*/
class SabreDAVCalDAVLib
{
}
@@ -1,179 +0,0 @@
<?php
/**
* PDO principal backend
*
* This is a simple principal backend that maps exactly to the users table, as
* used by Sabre_DAV_Auth_Backend_PDO.
*
* It assumes all principals are in a single collection. The default collection
* is 'principals/', but this can be overriden.
*
* @package Sabre
* @subpackage DAVACL
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
class SabreDAVACLPrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\BackendInterface
{
/**
* PDO table name for 'principals'
*
* @var string
*/
protected $tableName;
/**
* PDO table name for 'group members'
*
* @var string
*/
protected $groupMembersTableName;
protected $result_ma;
protected $auth;
/**
* Sets up the backend.
*
* @param PDO $pdo
* @param string $tableName
*/
public function __construct($auth)
{
$this->auth = $auth;
/*
$ma = new mitarbeiter();
$this->result_ma = $ma->getMitarbeiter(null,null,null);
*/
}
/**
* Liefert den eingeloggten User
*/
function getUser()
{
return $this->auth->getCurrentUser();
}
/**
* Returns a list of principals based on a prefix.
*
* This prefix will often contain something like 'principals'. You are only
* expected to return principals that are in this base path.
*
* You are expected to return at least a 'uri' for every user, you can
* return any additional properties if you wish so. Common properties are:
* {DAV:}displayname
* {http://sabredav.org/ns}email-address - This is a custom SabreDAV
* field that's actualy injected in a number of other properties. If
* you have an email address, use this property.
*
* @param string $prefixPath
* @return array
*/
public function getPrincipalsByPrefix($prefixPath)
{
//$prefixPath = principals
//error_log('Principal.php/getPrincipalsByPrefix('.$prefixPath.')');
$principals = array();
$user = $this->getUser();
if($prefixPath=='principals')
{
$principals[] = array(
'id' => $user,
'uri' => 'principals/'.$user,
'{DAV:}displayname' => $user,
'{http://sabredav.org/ns}email-address' => $user.'@example.com',
);
}
return $principals;
}
/**
* Returns a specific principal, specified by it's path.
* The returned structure should be the exact same as from
* getPrincipalsByPrefix.
*
* @param string $path
* @return array
*/
public function getPrincipalByPath($path)
{
$user = mb_substr($path,11);
$result = array(
'id' => $user,
'uri' => 'principals/'.$user,
'{DAV:}displayname' => $user,
'{http://sabredav.org/ns}email-address' => $user.'@example.com',
);
return $result;
}
/**
* Returns the list of members for a group-principal
*
* @param string $principal
* @return array
*/
public function getGroupMemberSet($principal)
{
$result = array();
return $result;
}
/**
* Returns the list of groups a principal is a member of
*
* @param string $principal
* @return array
*/
public function getGroupMembership($principal)
{
$result = array();
if(preg_match('/^principals\/[0-9A-Za-z\-]*$/',$principal))
{
$user = mb_substr($principal,11);
}
return $result;
}
/**
* Updates the list of group members for a group principal.
*
* The principals should be passed as a list of uri's.
*
* @param string $principal
* @param array $members
* @return void
*/
public function setGroupMemberSet($principal, array $members)
{
throw new \Sabre\DAV\Exception('Not implemented');
}
public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch)
{
$propPatch->setRemainingResultCode(403);
}
public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
{
return array();
}
public function findByUri($uri, $principalPrefix)
{
return null;
}
}
@@ -1,575 +0,0 @@
<?php
/**
* CalDAV backend
*/
class SabreDAVCalDAVBackend extends \Sabre\CalDAV\Backend\AbstractBackend
{
protected $auth;
protected $CI;
CONST CALENDAR_NAME = 'LVPlan';
CONST CAL_CATEGORY_STUNDENPLAN = 'Stundenplan';
CONST CAL_CATEGORY_STUNDENPLAN_EXAM = 'StundenplanExam';
CONST CAL_CATEGORY_STUNDENPLAN_REMOTE = 'StundenplanRemote';
CONST CAL_CATEGORY_STUNDENPLAN_EXAM_ICON = '📝';
CONST CAL_CATEGORY_STUNDENPLAN_ON_SITE_ICON = '🏫';
CONST CAL_CATEGORY_STUNDENPLAN_REMOTE_ICON = '📍';
CONST CAL_CATEGORY_RESERVATION_ICON = '📌';
/**
* Creates the backend
*
* @param AuthBackend $auth
*/
public function __construct($auth)
{
$this->auth = $auth;
$this->CI =& get_instance();
}
/**
* Liefert den eingeloggten User
*/
function getUser()
{
return $this->auth->getCurrentUser();
}
/**
* Returns a list of calendars for a principal.
*
* Every project is an array with the following keys:
* * id, a unique id that will be used by other functions to modify the
* calendar. This can be the same as the uri or a database key.
* * uri, which the basename of the uri with which the calendar is
* accessed.
* * principalUri. The owner of the calendar. Almost always the same as
* principalUri passed to this method.
*
* Furthermore it can contain webdav properties in clark notation. A very
* common one is '{DAV:}displayname'.
*
* @param string $principalUri
* @return array
*/
public function getCalendarsForUser($principalUri)
{
$user = mb_substr($principalUri,11);
$calendars = array();
$calendar = array(
'id' => $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' => 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',
'{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
'{http://sabredav.org/ns}read-only' => 1
);
$calendars[] = $calendar;
return $calendars;
}
/**
* Creates a new calendar for a principal.
*
* If the creation was a success, an id must be returned that can be used to reference
* this calendar in other methods, such as updateCalendar
*
* @param string $principalUri
* @param string $calendarUri
* @param array $properties
*/
public function createCalendar($principalUri,$calendarUri, array $properties)
{
return $calendarUri;
}
/**
* Updates properties for a calendar.
*
* The mutations array uses the propertyName in clark-notation as key,
* and the array value for the property value. In the case a property
* should be deleted, the property value will be null.
*
* This method must be atomic. If one property cannot be changed, the
* entire operation must fail.
*
* If the operation was successful, true can be returned.
* If the operation failed, false can be returned.
*
* Deletion of a non-existant property is always succesful.
*
* Lastly, it is optional to return detailed information about any
* failures. In this case an array should be returned with the following
* structure:
*
* array(
* 403 => array(
* '{DAV:}displayname' => null,
* ),
* 424 => array(
* '{DAV:}owner' => null,
* )
* )
*
* In this example it was forbidden to update {DAV:}displayname.
* (403 Forbidden), which in turn also caused {DAV:}owner to fail
* (424 Failed Dependency) because the request needs to be atomic.
*
* @param string $calendarId
* @param array $mutations
* @return bool|array
*/
public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch)
{
$propPatch->setRemainingResultCode(200);
}
/**
* Delete a calendar and all it's objects
*
* @param string $calendarId
* @return void
*/
public function deleteCalendar($calendarId)
{
return null;
}
public function getCalendarData($userUID, $objectUri=null)
{
$this->CI->load->model("ressource/Mitarbeiter_model", "MitarbeiterModel");
$this->CI->load->model("person/Benutzer_model", "BenutzerModel");
$user = $this->CI->BenutzerModel->loadWhere(array("uid" => $userUID));
if(!$user)
die('User invalid');
$this->CI->load->library('KalenderLib', ['uid' => $userUID]);
$isUserEmployeeResult = $this->CI->MitarbeiterModel->isMitarbeiter($userUID);
if (isError($isUserEmployeeResult)) {
return;
}
$isUserEmployee = getData($isUserEmployeeResult);
$startDate = date('Y-m-d', mktime(0,0,0,date('m'),date('d')-14,date('Y')));
$endDate = date('Y-m-d', mktime(0,0,0,date('m')+6,date('d'),date('Y')));
$data = [];
if ($isUserEmployee) {
$data = $this->CI->kalenderlib->getPlanForLecturerByLecturer($startDate, $endDate, $userUID);
} else {
$data = $this->CI->kalenderlib->getPlanForStudentByStudent($startDate, $endDate, $userUID);
}
if(!is_array($data))
$data = array();
foreach($data as $item)
{
$item->calendarDataFragment = $this->buildCalendarDataFragment($item);
}
if (is_null($objectUri))
{
return $data;
}
$normalizedObjectUri = $this->normalizeObjectUri($objectUri);
foreach($data as $row)
{
if(md5($row->eindeutige_kalender_gruppen_id) == $normalizedObjectUri)
{
return $row;
}
}
return null;
}
public function makeCal($event)
{
return $this->buildICalLine('BEGIN', 'VCALENDAR')
.$this->buildICalLine('VERSION', '2.0')
.$this->buildICalTextLine('PRODID', 'FH Technikum Wien')
.$this->buildICalLine('BEGIN', 'VTIMEZONE')
.$this->buildICalLine('TZID', 'Europe/Vienna')
.$this->buildICalLine('BEGIN', 'DAYLIGHT')
.$this->buildICalLine('TZOFFSETFROM', '+0100')
.$this->buildICalLine('RRULE', 'FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU')
.$this->buildICalLine('DTSTART', '19810329T020000')
.$this->buildICalLine('TZNAME', 'GMT+02:00')
.$this->buildICalLine('TZOFFSETTO', '+0200')
.$this->buildICalLine('END', 'DAYLIGHT')
.$this->buildICalLine('BEGIN', 'STANDARD')
.$this->buildICalLine('TZOFFSETFROM', '+0200')
.$this->buildICalLine('RRULE', 'FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU')
.$this->buildICalLine('DTSTART', '19961027T030000')
.$this->buildICalLine('TZNAME', 'GMT+01:00')
.$this->buildICalLine('TZOFFSETTO', '+0100')
.$this->buildICalLine('END', 'STANDARD')
.$this->buildICalLine('END', 'VTIMEZONE')
.$event
.$this->buildICalLine('END', 'VCALENDAR');
}
protected function buildCalendarDataFragment($item)
{
$summaryIcon = '';
$summary = $item->type == 'reservierung' ? $item->titel : $item->topic;
$description = "";
if ($item->type == 'reservierung') {
$description = $item->beschreibung;
} else {
$description = $item->lehrfach_bez . "\r\n";
if (isset($item->lektor) && is_array($item->lektor) && count($item->lektor) > 0) {
$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') {
$summaryIcon = self::CAL_CATEGORY_STUNDENPLAN_EXAM_ICON;
$category = self::CAL_CATEGORY_STUNDENPLAN_EXAM;
} else if (!isset($item->ko_ort_kurzbz) || $item->ko_ort_kurzbz === '') {
$summaryIcon = self::CAL_CATEGORY_STUNDENPLAN_REMOTE_ICON;
$category = self::CAL_CATEGORY_STUNDENPLAN_REMOTE;
}
} else if ($item->type === 'reservierung' && (!isset($item->ko_ort_kurzbz) || $item->ko_ort_kurzbz === '')) {
$summaryIcon = self::CAL_CATEGORY_RESERVATION_ICON;
$category = self::CAL_CATEGORY_STUNDENPLAN_REMOTE;
}
if ($summaryIcon !== '') {
$summary = $summaryIcon . ' ' . $summary;
}
$parsedStartDate = $this->formatICalLocalDateTime($item->isostart);
$parsedEndDate = $this->formatICalLocalDateTime($item->isoend);
$lastModified = $this->formatICalUtcDateTime(isset($item->updateamum) ? $item->updateamum : null);
$dtStamp = $lastModified ?: $this->formatICalUtcDateTime($item->isostart);
if($dtStamp === null)
$dtStamp = '19700101T000000Z';
$fragment = $this->buildICalLine('BEGIN', 'VEVENT')
.$this->buildICalTextLine('UID', $item->eindeutige_kalender_gruppen_id)
.$this->buildICalLine('SEQUENCE', (int)$item->kalender_id)
.$this->buildICalTextLine('SUMMARY', $summary)
.$this->buildICalTextLine('DESCRIPTION', $description)
.$this->buildICalTextLine('LOCATION', isset($item->ort_kurzbz) ? $item->ort_kurzbz : '')
.$this->buildICalTextLine('CATEGORIES', $category)
.$this->buildICalLine('DTSTART', $parsedStartDate, array('TZID' => 'Europe/Vienna'))
.$this->buildICalLine('DTEND', $parsedEndDate, array('TZID' => 'Europe/Vienna'));
if($lastModified !== null)
$fragment .= $this->buildICalLine('LAST-MODIFIED', $lastModified);
return $fragment
.$this->buildICalLine('DTSTAMP', $dtStamp)
.$this->buildICalLine('END', 'VEVENT');
}
protected function buildCalendarCtag($userUID)
{
$data = $this->getCalendarData($userUID);
if(!is_array($data))
$data = array();
$fragments = array();
foreach($data as $row)
{
$lastModified = isset($row->updateamum) ? $this->getLastModifiedTimestamp($row->updateamum) : null;
$calendarData = isset($row->calendarDataFragment) ? $this->makeCal($row->calendarDataFragment) : '';
$fragments[] = $this->getObjectUri($row).':'.$lastModified.':'.md5($calendarData);
}
sort($fragments, SORT_STRING);
return self::CALENDAR_NAME.'-'.$userUID.'-'.md5(implode('|', $fragments));
}
protected function buildICalTextLine($name, $value, array $parameters = array())
{
return $this->buildICalLine($name, $this->escapeICalText($value), $parameters);
}
protected function buildICalLine($name, $value, array $parameters = array())
{
$line = strtoupper($name);
foreach($parameters as $parameterName => $parameterValue)
{
$parameterValues = is_array($parameterValue) ? $parameterValue : array($parameterValue);
$escapedValues = array();
foreach($parameterValues as $singleParameterValue)
$escapedValues[] = $this->escapeICalParameterValue($singleParameterValue);
$line .= ';'.strtoupper($parameterName).'='.implode(',', $escapedValues);
}
return $this->foldICalLine($line.':'.(string)$value);
}
protected function foldICalLine($line)
{
$line = (string)$line;
$folded = '';
while(strlen($line) > 75)
{
$part = mb_strcut($line, 0, 75, 'UTF-8');
$folded .= $part."\r\n";
$line = ' '.mb_strcut($line, strlen($part), strlen($line) - strlen($part), 'UTF-8');
}
return $folded.$line."\r\n";
}
protected function escapeICalText($value)
{
$value = (string)$value;
$value = str_replace('\\', '\\\\', $value);
$value = str_replace(array("\r\n", "\r", "\n"), '\n', $value);
return str_replace(array(';', ','), array('\;', '\,'), $value);
}
protected function escapeICalParameterValue($value)
{
$value = (string)$value;
$value = str_replace(array('\\', '"', "\r", "\n"), array('\\\\', '\"', '', ''), $value);
if(preg_match('/[;:,]/', $value))
return '"'.$value.'"';
return $value;
}
protected function formatICalLocalDateTime($dateTime)
{
$dateTime = $this->createDateTime($dateTime);
if($dateTime === null)
return null;
$dateTime->setTimezone(new DateTimeZone('Europe/Vienna'));
return $dateTime->format('Ymd\THis');
}
protected function formatICalUtcDateTime($dateTime)
{
$dateTime = $this->createDateTime($dateTime);
if($dateTime === null)
return null;
$dateTime->setTimezone(new DateTimeZone('UTC'));
return $dateTime->format('Ymd\THis\Z');
}
protected function createDateTime($dateTime)
{
if($dateTime instanceof DateTime)
return clone $dateTime;
if($dateTime === null || $dateTime === '')
return null;
try
{
if(is_numeric($dateTime))
return new DateTime('@'.(int)$dateTime);
return new DateTime($dateTime);
}
catch(Exception $e)
{
return null;
}
}
protected function getObjectUri($row)
{
return md5($row->eindeutige_kalender_gruppen_id).'.ics';
}
protected function normalizeObjectUri($objectUri)
{
$normalizedObjectUri = (string)$objectUri;
if(substr($normalizedObjectUri, -4) === '.ics')
$normalizedObjectUri = substr($normalizedObjectUri, 0, -4);
if(mb_strpos($normalizedObjectUri, '@') !== false)
$normalizedObjectUri = mb_substr($normalizedObjectUri, mb_strpos($normalizedObjectUri, '@') + 1);
if($this->hasObjectUriDatePrefix($normalizedObjectUri))
return mb_substr($normalizedObjectUri, mb_strpos($normalizedObjectUri, '-') + 1);
return $normalizedObjectUri;
}
protected function hasObjectUriDatePrefix($objectUri)
{
$hyphenPosition = mb_strpos($objectUri, '-');
if($hyphenPosition !== 15)
return false;
return preg_match('/^\d{8}T\d{6}$/', mb_substr($objectUri, 0, 15)) === 1;
}
protected function buildCalendarObject($row, $calendarId)
{
$calendarData = $this->makeCal($row->calendarDataFragment);
return array(
"id"=>$row->eindeutige_kalender_gruppen_id,
"calendardata"=>$calendarData,
"uri"=>$this->getObjectUri($row),
"lastmodified"=>$this->getLastModifiedTimestamp($row->updateamum),
"etag"=>'"'.md5($calendarData).'"',
"calendarid"=>$calendarId,
"size"=>strlen($calendarData),
"component"=>'vevent'
);
}
protected function getLastModifiedTimestamp($lastModified)
{
if($lastModified === null || $lastModified === '')
return null;
if(is_numeric($lastModified))
return (int)$lastModified;
$timestamp = strtotime($lastModified);
if($timestamp === false)
return null;
return $timestamp;
}
/**
* Returns all calendar objects within a calendar.
*
* Every item contains an array with the following keys:
* * id - unique identifier which will be used for subsequent updates
* * calendardata - The iCalendar-compatible calnedar data
* * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
* * lastmodified - a timestamp of the last modification time
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
* ' "abcdef"')
* * calendarid - The calendarid as it was passed to this function.
*
* Note that the etag is optional, but it's highly encouraged to return for
* speed reasons.
*
* The calendardata is also optional. If it's not returned
* 'getCalendarObject' will be called later, which *is* expected to return
* calendardata.
*
* @param string $calendarId
* @return array
*/
public function getCalendarObjects($calendarId)
{
//$user = $this->getUser();
$user = $calendarId;
$data = $this->getCalendarData($user);
//error_log("Caldav_Backend.php/getCalendarObjects($calendarId) ");
$return = array();
if(!is_array($data))
return $return;
foreach($data as $row)
{
$return[] = $this->buildCalendarObject($row, $calendarId);
}
return $return;
}
/**
* Returns information from a single calendar object, based on it's object
* uri.
*
* The returned array must have the same keys as getCalendarObjects. The
* 'calendardata' object is required here though, while it's not required
* for getCalendarObjects.
*
* @param string $calendarId
* @param string $objectUri
* @return array
*/
public function getCalendarObject($calendarId,$objectUri)
{
$user = $calendarId;
$data = $this->getCalendarData($user,$objectUri);
if(empty($data))
{
return null;
}
elseif(is_object($data))
{
$ret = $this->buildCalendarObject($data, $calendarId);
}
return isset($ret) ? $ret : null;
}
/**
* Creates a new calendar object.
*
* @param string $calendarId
* @param string $objectUri
* @param string $calendarData
* @return void
*/
public function createCalendarObject($calendarId,$objectUri,$calendarData)
{
return null;
}
/**
* Updates an existing calendarobject, based on it's uri.
*
* @param string $calendarId
* @param string $objectUri
* @param string $calendarData
* @return void
*/
public function updateCalendarObject($calendarId,$objectUri,$calendarData)
{
if(is_resource($calendarData))
$calendarData = stream_get_contents($calendarData);
return '"'.md5((string)$calendarData).'"';
}
/**
* Deletes an existing calendar object.
*
* @param string $calendarId
* @param string $objectUri
* @return void
*/
public function deleteCalendarObject($calendarId,$objectUri)
{
return null;
}
}
@@ -1,36 +0,0 @@
<?php
class SabreDAVReadOnlyACL
{
public static function getAcl($principalUri, $includeFreeBusy = false)
{
$acl = array(
array(
'privilege' => '{DAV:}read',
'principal' => $principalUri,
'protected' => true,
),
array(
'privilege' => '{DAV:}read',
'principal' => $principalUri.'/calendar-proxy-read',
'protected' => true,
),
);
if($includeFreeBusy)
{
$acl[] = array(
'privilege' => '{'.\Sabre\CalDAV\Plugin::NS_CALDAV.'}read-free-busy',
'principal' => '{DAV:}authenticated',
'protected' => true,
);
}
return $acl;
}
public static function ignoreWrite()
{
return null;
}
}
@@ -1,80 +0,0 @@
<?php
class SabreDAVReadOnlyCalendar extends \Sabre\CalDAV\Calendar
{
protected $readOnlyCaldavBackend;
protected $readOnlyCalendarInfo;
public function __construct(\Sabre\CalDAV\Backend\BackendInterface $caldavBackend, $calendarInfo)
{
parent::__construct($caldavBackend, $calendarInfo);
$this->readOnlyCaldavBackend = $caldavBackend;
$this->readOnlyCalendarInfo = $calendarInfo;
}
public function getChild($name)
{
$obj = $this->readOnlyCaldavBackend->getCalendarObject($this->readOnlyCalendarInfo['id'], $name);
if(!$obj)
throw new \Sabre\DAV\Exception\NotFound('Calendar object not found');
$obj['acl'] = $this->getCalendarObjectAcl();
return new SabreDAVReadOnlyCalendarObject($this->readOnlyCaldavBackend, $this->readOnlyCalendarInfo, $obj);
}
public function getChildren()
{
$objs = $this->readOnlyCaldavBackend->getCalendarObjects($this->readOnlyCalendarInfo['id']);
$children = array();
foreach($objs as $obj)
{
$obj['acl'] = $this->getCalendarObjectAcl();
$children[] = new SabreDAVReadOnlyCalendarObject($this->readOnlyCaldavBackend, $this->readOnlyCalendarInfo, $obj);
}
return $children;
}
public function createFile($name, $calendarData = null)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function createDirectory($name)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function delete()
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function setName($newName)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function updateProperties($mutations)
{
return true;
}
public function propPatch(\Sabre\DAV\PropPatch $propPatch)
{
$propPatch->setRemainingResultCode(200);
}
public function getACL()
{
return SabreDAVReadOnlyACL::getAcl($this->getOwner(), true);
}
protected function getCalendarObjectAcl()
{
return SabreDAVReadOnlyACL::getAcl($this->getOwner());
}
}
@@ -1,57 +0,0 @@
<?php
class SabreDAVReadOnlyCalendarHome extends \Sabre\CalDAV\CalendarHome
{
protected $readOnlyCaldavBackend;
protected $readOnlyPrincipalInfo;
public function __construct(\Sabre\CalDAV\Backend\BackendInterface $caldavBackend, $principalInfo)
{
parent::__construct($caldavBackend, $principalInfo);
$this->readOnlyCaldavBackend = $caldavBackend;
$this->readOnlyPrincipalInfo = $principalInfo;
}
public function getChildren()
{
$calendars = $this->readOnlyCaldavBackend->getCalendarsForUser($this->readOnlyPrincipalInfo['uri']);
$objs = array();
foreach($calendars as $calendar)
{
$objs[] = new SabreDAVReadOnlyCalendar($this->readOnlyCaldavBackend, $calendar);
}
return $objs;
}
public function createExtendedCollection($name, \Sabre\DAV\MkCol $mkCol)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function createFile($filename, $data = null)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function createDirectory($filename)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function delete()
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function setName($name)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function getACL()
{
return SabreDAVReadOnlyACL::getAcl($this->readOnlyPrincipalInfo['uri']);
}
}
@@ -1,84 +0,0 @@
<?php
class SabreDAVReadOnlyCalendarObject extends \Sabre\CalDAV\CalendarObject
{
protected $readOnlyCalendarInfo;
public function __construct(\Sabre\CalDAV\Backend\BackendInterface $caldavBackend, array $calendarInfo, array $objectData)
{
parent::__construct($caldavBackend, $calendarInfo, $objectData);
$this->readOnlyCalendarInfo = $calendarInfo;
}
public function put($calendarData)
{
return $this->getCurrentETag();
}
public function getETag()
{
if($this->isWriteRequest())
{
$ifMatch = isset($_SERVER['HTTP_IF_MATCH']) ? trim($_SERVER['HTTP_IF_MATCH']) : '';
if($ifMatch !== '' && $ifMatch !== '*')
{
$requestedEtags = explode(',', $ifMatch);
foreach($requestedEtags as $requestedEtag)
{
$requestedEtag = trim($requestedEtag);
if($requestedEtag !== '')
return $requestedEtag;
}
}
}
return parent::getETag();
}
public function getLastModified()
{
if($this->isWriteRequest())
{
$ifUnmodifiedSince = isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE']) ? trim($_SERVER['HTTP_IF_UNMODIFIED_SINCE']) : '';
if($ifUnmodifiedSince !== '')
{
$timestamp = strtotime($ifUnmodifiedSince);
if($timestamp !== false)
return max(0, $timestamp - 1);
}
}
return parent::getLastModified();
}
public function delete()
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function setName($name)
{
return SabreDAVReadOnlyACL::ignoreWrite();
}
public function getACL()
{
return SabreDAVReadOnlyACL::getAcl($this->readOnlyCalendarInfo['principaluri']);
}
protected function isWriteRequest()
{
if(!isset($_SERVER['REQUEST_METHOD']))
return false;
return in_array(strtoupper($_SERVER['REQUEST_METHOD']), array('PUT', 'DELETE', 'PROPPATCH', 'MOVE', 'COPY', 'PATCH'), true);
}
protected function getCurrentETag()
{
if(isset($this->objectData['etag']) && $this->objectData['etag'] !== '')
return $this->objectData['etag'];
return parent::getETag();
}
}
@@ -1,17 +0,0 @@
<?php
class SabreDAVReadOnlyCalendarRoot extends \Sabre\CalDAV\CalendarRoot
{
protected $readOnlyCaldavBackend;
public function __construct(\Sabre\DAVACL\PrincipalBackend\BackendInterface $principalBackend, \Sabre\CalDAV\Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals')
{
parent::__construct($principalBackend, $caldavBackend, $principalPrefix);
$this->readOnlyCaldavBackend = $caldavBackend;
}
public function getChildForPrincipal(array $principal)
{
return new SabreDAVReadOnlyCalendarHome($this->readOnlyCaldavBackend, $principal);
}
}
-1
View File
@@ -10,7 +10,6 @@
'filtercomponent' => true,
'navigationcomponent' => true,
'vuedatepicker11' => true,
'momentjs2' => true,
'tags' => true,
'phrases' => array(
'global',
+1 -3
View File
@@ -443,7 +443,7 @@
}
],
"require": {
"php": ">=7.0.0",
"php": ">=5.6.40",
"afarkas/html5shiv": "3.7.*",
"alvaro-prieto/colresizable": "1.6",
@@ -506,8 +506,6 @@
"rmariuzzo/jquery-checkboxes": "1.0.7",
"sabre/dav": "4.0.3",
"sabre/event": "5.0.3",
"scottjehl/respond": "1.4.2",
"tapmodo/jcrop": "2.0.4",
@@ -196,4 +196,4 @@ export default {
</teleport>
</div>
`
}
}
+100 -97
View File
@@ -1,12 +1,13 @@
import FhcCalendar from "./Base.js";
import { useEventLoader } from "../../composables/EventLoader.js";
import { useEventLoader } from '../../composables/EventLoader.js';
import ModeWeek from './Mode/Week.js';
import ModeMonth from './Mode/Month.js';
import ModeTable from './Mode/Table.js';
import ApiKalender from '../../api/factory/tempus/kalender.js';
import draggable from '../../directives/draggable.js';
import ModeWeek from "./Mode/Week.js";
import ModeMonth from "./Mode/Month.js";
import ModeTable from "./Mode/Table.js";
import ApiKalender from "../../api/factory/tempus/kalender.js";
import draggable from "../../directives/draggable.js";
export default {
name: "CalendarTempus",
@@ -79,70 +80,71 @@ export default {
"open-reservierung"
],
data() {
return {
modes: {
week: Vue.markRaw(ModeWeek),
month: Vue.markRaw(ModeMonth),
tableList: Vue.markRaw(ModeTable),
},
modeOptions: {
day: {
emptyMessage: Vue.computed(() => this.$p.t("lehre/noLvFound")),
emptyMessageDetails: Vue.computed(() => this.$p.t("lehre/noLvFound")),
},
week: {
collapseEmptyDays: false,
},
},
currentMode: this.mode,
teachingunits: null,
hoursplan: null,
showRaster: true,
};
},
computed: {
backgrounds() {
let now = luxon.DateTime.now().setZone(this.timezone);
data() {
return {
modes: {
week: Vue.markRaw(ModeWeek),
month: Vue.markRaw(ModeMonth),
tableList: Vue.markRaw(ModeTable),
},
modeOptions: {
day: {
emptyMessage: Vue.computed(() => this.$p.t('lehre/noLvFound')),
emptyMessageDetails: Vue.computed(() => this.$p.t('lehre/noLvFound'))
},
week: {
collapseEmptyDays: false
}
},
currentMode: this.mode,
teachingunits: null,
hoursplan: null,
showRaster: true,
};
},
computed: {
backgrounds() {
let now = luxon.DateTime.now().setZone(this.timezone);
let past = [];
if (this.mode == "Month") {
past = [
{
class: "background-past",
end: now.startOf("day"),
},
];
} else {
past = [
{
class: "background-past",
end: now,
label: now
.startOf("minute")
.toISOTime({ suppressSeconds: true, includeOffset: false }),
},
];
}
let past = [];
if (this.mode == 'Month')
{
past = [{
class: 'background-past',
end: now.startOf('day')
}];
}
else
{
past = [{
class: 'background-past',
end: now,
label: now.startOf('minute').toISOTime({ suppressSeconds: true, includeOffset: false })
}];
}
return [...past, ...(this.extraBackgrounds || [])];
},
visibleEvents() {
let list = this.events;
return [
...past,
...(this.extraBackgrounds || [])
];
},
visibleEvents()
{
let list = this.events;
if (Array.isArray(this.visibleLecturers)) {
const visibleLectures = new Set(this.visibleLecturers);
if (Array.isArray(this.visibleLecturers))
{
const visibleLectures = new Set(this.visibleLecturers);
list = list.filter((event) => {
if (!event.lektor?.length) return true;
return event.lektor.some((lektor) =>
visibleLectures.has(lektor.mitarbeiter_uid),
);
});
}
list = list.filter(event => {
if (!event.lektor?.length)
return true;
return event.lektor.some(lektor => visibleLectures.has(lektor.mitarbeiter_uid));
});
}
if (!this.visibleStatus.length || this.visibleStatus.includes("all"))
return list;
if (!this.visibleStatus.length || this.visibleStatus.includes('all'))
return list;
return list.filter(event => this.visibleStatus.includes(event.status_kurzbz));
},
@@ -185,40 +187,41 @@ export default {
setup(props, context) {
const rangeInterval = Vue.ref(null);
const { events, lv, reset } = useEventLoader(
rangeInterval,
props.getPromiseFunc,
);
const { events, lv, reset } = useEventLoader(rangeInterval, props.getPromiseFunc);
Vue.watch(lv, (newValue) => {
context.emit("update:lv", newValue);
});
Vue.watch(lv, newValue => {
context.emit('update:lv', newValue);
});
return {
rangeInterval,
events,
lv,
reset,
};
},
return {
rangeInterval,
events,
lv,
reset
};
},
created() {
this.$api.call(ApiKalender.getStunden()).then((res) => {
return (this.teachingunits = res.data.map((el) => ({
id: el.stunde,
start: el.beginn,
end: el.ende,
})));
});
created() {
this.$api
.call(ApiKalender.getStunden())
.then(res => {
return this.teachingunits = res.data.map(el => ({
id: el.stunde,
start: el.beginn,
end: el.ende
}));
});
this.$api.call(ApiKalender.getCalendarHours()).then((res) => {
this.hoursplan = {
start: res.data.start,
end: res.data.end,
};
});
},
template: /* html */ `
this.$api
.call(ApiKalender.getCalendarHours())
.then(res => {
this.hoursplan = {
start: res.data.start,
end: res.data.end
};
});
},
template: /* html */`
<fhc-calendar
ref="calendar"
class="fhc-calendar-lvplan"
@@ -298,5 +301,5 @@ export default {
</div>
</div>
</template>
</fhc-calendar>`,
};
</fhc-calendar>`
}
-160
View File
@@ -61530,166 +61530,6 @@ I have been informed that I am under no obligation to consent to the transmissio
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'failed_assigned_resources_fetch_error_message',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Fehler beim Abrufen der zugewiesenen Ressourcen. Bitte versuchen Sie es erneut.',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Error fetching assigned resources. Please try again.',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'failed_schedulable_resources_fetch_error_message',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Fehler beim Abrufen der zuweisbaren Ressourcen. Bitte versuchen Sie es erneut.',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Error fetching schedulable resources. Please try again.',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'failed_assigned_resources_save_error_message',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Fehler beim Speichern der zugewiesenen Ressourcen. Bitte versuchen Sie es erneut.',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Error saving assigned resources. Please try again.',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'resource_assignment_modal_title',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Ressourcen-Zuweisung',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Resource Assignment',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'assigned_resources_subtitle',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Zugewiesene Ressourcen',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Assigned Resources',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'no_assigned_resources',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Keine zugewiesenen Ressourcen',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'No Assigned Resources',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'available_resources_label',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Verfügbare Ressourcen',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Available Resources',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'ui',
'phrase' => 'assigned_resources_save_success_message',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Zugewiesene Ressourcen erfolgreich gespeichert',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Assigned Resources successfully saved',
'description' => '',
'insertvon' => 'system'
)
)
),
// ### Phrases Dashboard Admin END
// ### LvPlanStgOrg START ###
array(
+32 -54
View File
@@ -8,8 +8,6 @@ require_once(dirname(__FILE__).'/../include/datum.class.php');
*/
class MySabre_CalDAV_Backend extends \Sabre\CalDAV\Backend\AbstractBackend
{
protected $auth;
/**
* Creates the backend
*
@@ -56,13 +54,12 @@ class MySabre_CalDAV_Backend extends \Sabre\CalDAV\Backend\AbstractBackend
'uri' => 'LVPlan-'.$user,
'principaluri' => 'principals/'.$user,
'{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => 'LVPlan-'.$user.'-'.time(),
'{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
'{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
'{DAV:}displayname' => 'LVPlan',
'{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',
'{http://apple.com/ns/ical/}calendar-color' => '#FF0000',
'{http://sabredav.org/ns}read-only' => 1
'{http://apple.com/ns/ical/}calendar-color' => '#FF0000'
);
$calendars[] = $calendar;
@@ -120,9 +117,9 @@ class MySabre_CalDAV_Backend extends \Sabre\CalDAV\Backend\AbstractBackend
* @param array $mutations
* @return bool|array
*/
public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch)
public function updateCalendar($calendarId, array $mutations)
{
$propPatch->setRemainingResultCode(403);
return false;
}
/**
@@ -216,7 +213,7 @@ class MySabre_CalDAV_Backend extends \Sabre\CalDAV\Backend\AbstractBackend
foreach($val as $row)
{
//einzelnen Eintrag holen
if($row['dtstart']==$dtstart && (($row['unr'][0]==$unr) || $unr=='R'.$row['reservierung_id']))
if($row['dtstart']==$dtstart && ($row['unr'][0]==$unr) || $unr=='R'.$row['reservierung_id'])
{
return $row;
}
@@ -254,48 +251,6 @@ TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE\n".$event."\nEND:VCALENDAR";
}
protected function getObjectUri($row)
{
// Reservierungen werden mit einem R markiert und mit der ReservierungID da sonst
// Termine verloren gehen koennen wenn zur selben Zeit eine Reservierung und ein LVPlan Eintrag vorhanden ist
if($row['reservierung'])
$uri = $row['dtstart'].'-R'.$row['reservierung_id'];
else
$uri = $row['dtstart'].'-'.$row['unr'][0];
return $uri.'@'.md5($row['UID']);
}
protected function buildCalendarObject($row, $calendarId)
{
$calendarData = $this->makeCal($row['data']);
return array("id"=>$row['UID'],
"calendardata"=>$calendarData,
"uri"=>$this->getObjectUri($row),
"lastmodified"=>$this->getLastModifiedTimestamp($row['updateamum']),
"etag"=>'"'.$row['UID'].'"',
"calendarid"=>$calendarId,
"size"=>strlen($calendarData),
"component"=>'vevent');
}
protected function getLastModifiedTimestamp($lastModified)
{
if($lastModified === null || $lastModified === '')
return null;
if(is_numeric($lastModified))
return (int)$lastModified;
$timestamp = strtotime($lastModified);
if($timestamp === false)
return null;
return $timestamp;
}
/**
* Returns all calendar objects within a calendar.
*
@@ -328,7 +283,20 @@ END:VTIMEZONE\n".$event."\nEND:VCALENDAR";
$return = array();
foreach($data as $row)
{
$return[] = $this->buildCalendarObject($row, $calendarId);
// Reservierungen werden mit einem R markiert und mit der ReservierungID da sonst
// Termine verloren gehen koennen wenn zur selben Zeit eine Reservierung und ein LVPlan Eintrag vorhanden ist
if($row['reservierung'])
$uri = $row['dtstart'].'-R'.$row['reservierung_id'];
else
$uri = $row['dtstart'].'-'.$row['unr'][0];
$return[] = array("id"=>$row['UID'],
"calendardata"=>$this->makeCal($row['data']),
"uri"=>$uri.'@'.md5($row['UID']),
"lastmodified"=>$row['updateamum'],
"etag"=>'"'.$row['UID'].'"',
"calendarid"=>$calendarId);
}
return $return;
}
@@ -351,13 +319,23 @@ END:VTIMEZONE\n".$event."\nEND:VCALENDAR";
//$user = $this->getUser();
$user = $calendarId;
$data = $this->getCalendarData($user,$objectUri);
if(empty($data))
if(count($data)==0)
{
return null;
$ret=array("id"=>'',
"calendardata"=>'',
"uri"=>'',
"lastmodified"=>'',
"etag"=>'',
"calendarid"=>$calendarId);
}
else
{
$ret = $this->buildCalendarObject($data, $calendarId);
$ret = array("id"=>$data['UID'],
"calendardata"=>$this->makeCal($data['data']),
"uri"=>'principals/'.$user.'/LVPlan/'.$data['dtstart'].'-'.$data['unr'][0].'@'.md5($data['UID']),
"lastmodified"=>$data['updateamum'],
"etag"=>'"'.$data['UID'].'"',
"calendarid"=>$calendarId);
}
return $ret;
}
@@ -1,29 +0,0 @@
<?php
/**
* Browser plugin variant that keeps SabreDAV's HTML overview but hides the
* verbose WebDAV properties table.
*/
class MySabre_DAV_Browser_NoProperties extends \Sabre\DAV\Browser\Plugin
{
public function generateDirectoryIndex($path)
{
$html = parent::generateDirectoryIndex($path);
$cleanHtml = preg_replace(
'#<section><h1>Properties</h1>.*?</section>#s',
'',
$html,
1
);
$cleanHtml = preg_replace(
'#<section><h1>Actions</h1>.*?</section>#s',
'',
$cleanHtml,
1
);
return $cleanHtml === null ? $html : $cleanHtml;
}
}
+14 -10
View File
@@ -32,7 +32,6 @@ class MySabre_DAVACL_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\
protected $groupMembersTableName;
protected $result_ma;
protected $auth;
/**
* Sets up the backend.
*
@@ -122,6 +121,16 @@ class MySabre_DAVACL_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\
}*/
}
else //if($prefixPath=='principals/oesi')
{
$user = mb_substr($path,11);
$principals[] = array(
'id' => $user.'proxyread',
'uri' => 'principals/'.$user.'/calendar-proxy-read',
'{DAV:}displayname' => '',
'{http://sabredav.org/ns}email-address' => '',
);
}
return $principals;
@@ -217,18 +226,13 @@ class MySabre_DAVACL_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\
throw new \Sabre\DAV\Exception('Not implemented');
}
public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch)
public function updatePrincipal($path, $mutations)
{
$propPatch->setRemainingResultCode(403);
throw new \Sabre\DAV\Exception('Not implemented');
}
public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
public function searchPrincipals($prefixPath,array $searchProperties)
{
return array();
}
public function findByUri($uri, $principalPrefix)
{
return null;
throw new \Sabre\DAV\Exception('Not implemented');
}
}
-13
View File
@@ -25,25 +25,12 @@ require_once(dirname(__FILE__).'/../include/functions.inc.php');
class myauth extends \Sabre\DAV\Auth\Backend\AbstractBasic
{
protected $currentUser = null;
function validateUserPass($username, $password)
{
if(checkldapuser($username,$password))
{
$this->currentUser = $username;
return true;
}
else
{
$this->currentUser = null;
return false;
}
}
public function getCurrentUser()
{
return $this->currentUser;
}
}
?>
+5 -6
View File
@@ -1,11 +1,10 @@
<?php
// Files we need
require_once dirname(__DIR__).'/vendor/autoload.php';
require_once '../include/sabredav/lib/Sabre/autoload.php';
require_once 'auth.class.php';
require_once 'Caldav_Backend.php';
require_once('Principal.php');
require_once 'MySabre_DAV_Browser_NoProperties.php';
/*
//PHP Error To Exception
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
@@ -20,7 +19,7 @@ $calendarBackend = new MySabre_CalDAV_Backend($authBackend);
$tree = array(
new \Sabre\CalDAV\Principal\Collection($principalBackend),
new \Sabre\CalDAV\CalendarRoot($principalBackend, $calendarBackend)
new \Sabre\CalDAV\CalendarRootNode($principalBackend, $calendarBackend)
);
// The object tree needs in turn to be passed to the server class
@@ -33,8 +32,7 @@ $path = str_replace($_SERVER['DOCUMENT_ROOT'],'',__FILE__).'/';
$server->setBaseUri($path);
// Authentication plugin
$authBackend->setRealm('SabreDAV');
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV');
$server->addPlugin($authPlugin);
// CalDAV plugin
@@ -46,8 +44,9 @@ $aclPlugin = new \Sabre\DAVACL\Plugin();
$server->addPlugin($aclPlugin);
// Support for html frontend
$browser = new MySabre_DAV_Browser_NoProperties();
$browser = new \Sabre\DAV\Browser\Plugin();
$server->addPlugin($browser);
// And off we go!
$server->exec();