add version migration of sabredav from 1.8.1 to 4.0.3 and updated files where it is used

This commit is contained in:
Ivymaster
2026-06-30 13:59:36 +02:00
parent ac5478f176
commit 5499c522cb
5 changed files with 83 additions and 50 deletions
+3 -2
View File
@@ -431,7 +431,7 @@
}
],
"require": {
"php": ">=5.6.40",
"php": ">=7.0.0",
"afarkas/html5shiv": "3.7.*",
"alvaro-prieto/colresizable": "1.6",
@@ -492,7 +492,8 @@
"rmariuzzo/jquery-checkboxes": "1.0.7",
"sabre/dav": "1.8.10",
"sabre/dav": "4.0.3",
"sabre/event": "5.0.3",
"scottjehl/respond": "1.4.2",
"tapmodo/jcrop": "2.0.4",
+54 -32
View File
@@ -8,6 +8,8 @@ require_once(dirname(__FILE__).'/../include/datum.class.php');
*/
class MySabre_CalDAV_Backend extends \Sabre\CalDAV\Backend\AbstractBackend
{
protected $auth;
/**
* Creates the backend
*
@@ -54,12 +56,13 @@ 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\Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')),
'{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Xml\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://apple.com/ns/ical/}calendar-color' => '#FF0000',
'{http://sabredav.org/ns}read-only' => 1
);
$calendars[] = $calendar;
@@ -117,9 +120,9 @@ class MySabre_CalDAV_Backend extends \Sabre\CalDAV\Backend\AbstractBackend
* @param array $mutations
* @return bool|array
*/
public function updateCalendar($calendarId, array $mutations)
public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch)
{
return false;
$propPatch->setRemainingResultCode(403);
}
/**
@@ -213,7 +216,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;
}
@@ -251,6 +254,48 @@ 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.
*
@@ -283,20 +328,7 @@ END:VTIMEZONE\n".$event."\nEND:VCALENDAR";
$return = array();
foreach($data as $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[] = array("id"=>$row['UID'],
"calendardata"=>$this->makeCal($row['data']),
"uri"=>$uri.'@'.md5($row['UID']),
"lastmodified"=>$row['updateamum'],
"etag"=>'"'.$row['UID'].'"',
"calendarid"=>$calendarId);
$return[] = $this->buildCalendarObject($row, $calendarId);
}
return $return;
}
@@ -319,23 +351,13 @@ END:VTIMEZONE\n".$event."\nEND:VCALENDAR";
//$user = $this->getUser();
$user = $calendarId;
$data = $this->getCalendarData($user,$objectUri);
if(count($data)==0)
if(empty($data))
{
$ret=array("id"=>'',
"calendardata"=>'',
"uri"=>'',
"lastmodified"=>'',
"etag"=>'',
"calendarid"=>$calendarId);
return null;
}
else
{
$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);
$ret = $this->buildCalendarObject($data, $calendarId);
}
return $ret;
}
+10 -14
View File
@@ -32,6 +32,7 @@ class MySabre_DAVACL_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\
protected $groupMembersTableName;
protected $result_ma;
protected $auth;
/**
* Sets up the backend.
*
@@ -121,16 +122,6 @@ 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;
@@ -226,13 +217,18 @@ class MySabre_DAVACL_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend\
throw new \Sabre\DAV\Exception('Not implemented');
}
public function updatePrincipal($path, $mutations)
public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch)
{
throw new \Sabre\DAV\Exception('Not implemented');
$propPatch->setRemainingResultCode(403);
}
public function searchPrincipals($prefixPath,array $searchProperties)
public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
{
throw new \Sabre\DAV\Exception('Not implemented');
return array();
}
public function findByUri($uri, $principalPrefix)
{
return null;
}
}
+13
View File
@@ -25,12 +25,25 @@ 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;
}
}
?>
+3 -2
View File
@@ -19,7 +19,7 @@ $calendarBackend = new MySabre_CalDAV_Backend($authBackend);
$tree = array(
new \Sabre\CalDAV\Principal\Collection($principalBackend),
new \Sabre\CalDAV\CalendarRootNode($principalBackend, $calendarBackend)
new \Sabre\CalDAV\CalendarRoot($principalBackend, $calendarBackend)
);
// The object tree needs in turn to be passed to the server class
@@ -32,7 +32,8 @@ $path = str_replace($_SERVER['DOCUMENT_ROOT'],'',__FILE__).'/';
$server->setBaseUri($path);
// Authentication plugin
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV');
$authBackend->setRealm('SabreDAV');
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
$server->addPlugin($authPlugin);
// CalDAV plugin