Skip to content

Commit

Permalink
fixes #32007 - store integer values in database for calendar property…
Browse files Browse the repository at this point in the history
… 'schedule-calendar-transp'
  • Loading branch information
DeepDiver1975 authored and gitmate-bot committed Jul 9, 2018
1 parent 6303095 commit aaee903
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ public function createCalendar($principalUri, $calendarUri, array $properties) {
}
$transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
if (isset($properties[$transp])) {
$values['transparent'] = $properties[$transp]->getValue()==='transparent';
$values['transparent'] = $properties[$transp]->getValue() === 'transparent' ? 1 : 0;
}

foreach ($this->propertyMap as $xmlName=>$dbName) {
Expand Down Expand Up @@ -599,7 +599,7 @@ public function updateCalendar($calendarId, PropPatch $propPatch) {
switch ($propertyName) {
case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
$fieldName = 'transparent';
$newValues[$fieldName] = $propertyValue->getValue() === 'transparent';
$newValues[$fieldName] = $propertyValue->getValue() === 'transparent' ? 1 : 0;
break;
default:
$fieldName = $this->propertyMap[$propertyName];
Expand Down
6 changes: 5 additions & 1 deletion apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OCA\DAV\DAV\GroupPrincipalBackend;
use OCP\IConfig;
use OCP\Security\ISecureRandom;
use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp;
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
use Test\TestCase;

Expand Down Expand Up @@ -104,7 +105,8 @@ public function tearDown() {
*/
protected function createTestCalendar() {
$this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', [
'{http://apple.com/ns/ical/}calendar-color' => '#1C4587FF'
'{http://apple.com/ns/ical/}calendar-color' => '#1C4587FF',
'{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new ScheduleCalendarTransp('opaque')
]);
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertCount(1, $calendars);
Expand All @@ -114,6 +116,8 @@ protected function createTestCalendar() {
$this->assertEquals(['VEVENT','VTODO'], $components->getValue());
$color = $calendars[0]['{http://apple.com/ns/ical/}calendar-color'];
$this->assertEquals('#1C4587FF', $color);
$transparent = $calendars[0]['{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp'];
self::assertEquals(new ScheduleCalendarTransp('opaque'), $transparent);
$this->assertEquals('Example', $calendars[0]['uri']);
$this->assertEquals('Example', $calendars[0]['{DAV:}displayname']);
return $calendars[0]['id'];
Expand Down
5 changes: 4 additions & 1 deletion apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
use OCP\IL10N;
use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp;
use Sabre\DAV\PropPatch;
use Sabre\DAV\Xml\Property\Href;
use Sabre\DAVACL\IACL;
Expand All @@ -51,14 +52,16 @@ public function testCalendarOperations() {
// update it's display name
$patch = new PropPatch([
'{DAV:}displayname' => 'Unit test',
'{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar used for unit testing'
'{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar used for unit testing',
'{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new ScheduleCalendarTransp('transparent')
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();
$books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertCount(1, $books);
$this->assertEquals('Unit test', $books[0]['{DAV:}displayname']);
$this->assertEquals('Calendar used for unit testing', $books[0]['{urn:ietf:params:xml:ns:caldav}calendar-description']);
$this->assertEquals(new ScheduleCalendarTransp('transparent'), $books[0]['{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp']);

// delete the address book
$this->backend->deleteCalendar($books[0]['id']);
Expand Down

0 comments on commit aaee903

Please sign in to comment.