Skip to content

Commit

Permalink
Merge pull request #32024 from owncloud/stable10-aaee903c1f616d308d36…
Browse files Browse the repository at this point in the history
…d0de8f24e89d52c24b34

[stable10] fixes #32007 - store integer values in database for calend…
  • Loading branch information
DeepDiver1975 committed Jul 18, 2018
2 parents 179572b + b564a1c commit 48aac04
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 @@ -558,7 +558,7 @@ 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 @@ -603,7 +603,7 @@ 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 @@ -52,14 +53,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 48aac04

Please sign in to comment.