Prevent deletion of birthday calendar

This commit is contained in:
Thomas Müller 2016-02-08 12:46:09 +01:00
parent c9187cc820
commit 981c73000c
3 changed files with 8 additions and 8 deletions

View file

@ -140,16 +140,10 @@ class BirthdayService {
$date
);
$vEvent->DTEND['VALUE'] = 'DATE';
// $lm = new \DateTime('@' . $this->lastModified());
// $lm->setTimeZone(new \DateTimeZone('UTC'));
// $vEvent->DTSTAMP->setDateTime($lm);
$vEvent->{'UID'} = $doc->UID;
$vEvent->{'RRULE'} = 'FREQ=YEARLY';
$vEvent->{'SUMMARY'} = $title . ' (' . $date->format('Y') . ')';
$vEvent->{'TRANSP'} = 'TRANSPARENT';
// $appInfo = \OCP\App::getAppInfo('contacts');
// $appVersion = \OCP\App::getAppVersion('contacts');
// $vCal->PRODID = '-//ownCloud//NONSGML ' . $appInfo['name'] . ' ' . $appVersion . '//EN';
$vCal->add($vEvent);
return $vCal;
}

View file

@ -80,6 +80,10 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
}
function delete() {
if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {
throw new Forbidden();
}
if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
$principal = 'principal:' . parent::getOwner();
$shares = $this->getShares();

View file

@ -37,7 +37,8 @@ class CalendarTest extends TestCase {
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
'principaluri' => 'user2',
'id' => 666
'id' => 666,
'uri' => 'cal',
];
$c = new Calendar($backend, $calendarInfo);
$c->delete();
@ -56,7 +57,8 @@ class CalendarTest extends TestCase {
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
'principaluri' => 'user2',
'id' => 666
'id' => 666,
'uri' => 'cal',
];
$c = new Calendar($backend, $calendarInfo);
$c->delete();