summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-14 15:38:00 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-14 16:58:45 +0200
commit55735e1450a1670b63bf94869a3f9152d9d06c1a (patch)
tree027193fce23e376092e592bef47b08fe7a43148d /apps/dav
parent068e73cc47f4a35ce0b4374ad1b69df4b6a3265b (diff)
downloadnextcloud-server-55735e1450a1670b63bf94869a3f9152d9d06c1a.tar.gz
nextcloud-server-55735e1450a1670b63bf94869a3f9152d9d06c1a.zip
Translate contacts birthday - fixes #23982
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/caldav/calendar.php4
-rw-r--r--apps/dav/lib/caldav/calendarhome.php27
-rw-r--r--apps/dav/tests/unit/caldav/caldavbackendtest.php13
-rw-r--r--apps/dav/tests/unit/caldav/calendartest.php24
4 files changed, 52 insertions, 16 deletions
diff --git a/apps/dav/lib/caldav/calendar.php b/apps/dav/lib/caldav/calendar.php
index 5072d96107e..6d6c0b5d7a4 100644
--- a/apps/dav/lib/caldav/calendar.php
+++ b/apps/dav/lib/caldav/calendar.php
@@ -22,17 +22,19 @@
namespace OCA\DAV\CalDAV;
use OCA\DAV\DAV\Sharing\IShareable;
+use OCP\IL10N;
use Sabre\CalDAV\Backend\BackendInterface;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\PropPatch;
class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
- public function __construct(BackendInterface $caldavBackend, $calendarInfo) {
+ public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n) {
parent::__construct($caldavBackend, $calendarInfo);
if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {
$this->calendarInfo['{http://sabredav.org/ns}read-only'] = true;
+ $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Contact birthdays');
}
}
diff --git a/apps/dav/lib/caldav/calendarhome.php b/apps/dav/lib/caldav/calendarhome.php
index 87b8d4bb320..a4c485a8983 100644
--- a/apps/dav/lib/caldav/calendarhome.php
+++ b/apps/dav/lib/caldav/calendarhome.php
@@ -21,6 +21,7 @@
*/
namespace OCA\DAV\CalDAV;
+use Sabre\CalDAV\Backend\BackendInterface;
use Sabre\CalDAV\Backend\NotificationSupport;
use Sabre\CalDAV\Backend\SchedulingSupport;
use Sabre\CalDAV\Backend\SubscriptionSupport;
@@ -31,34 +32,42 @@ use Sabre\DAV\Exception\NotFound;
class CalendarHome extends \Sabre\CalDAV\CalendarHome {
+ /** @var \OCP\IL10N */
+ private $l10n;
+
+ public function __construct(BackendInterface $caldavBackend, $principalInfo) {
+ parent::__construct($caldavBackend, $principalInfo);
+ $this->l10n = \OC::$server->getL10N('dav');
+ }
+
/**
* @inheritdoc
*/
function getChildren() {
$calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
- $objs = [];
+ $objects = [];
foreach ($calendars as $calendar) {
- $objs[] = new Calendar($this->caldavBackend, $calendar);
+ $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n);
}
if ($this->caldavBackend instanceof SchedulingSupport) {
- $objs[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
- $objs[] = new Outbox($this->principalInfo['uri']);
+ $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
+ $objects[] = new Outbox($this->principalInfo['uri']);
}
// We're adding a notifications node, if it's supported by the backend.
if ($this->caldavBackend instanceof NotificationSupport) {
- $objs[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
+ $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
}
// If the backend supports subscriptions, we'll add those as well,
if ($this->caldavBackend instanceof SubscriptionSupport) {
foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
- $objs[] = new Subscription($this->caldavBackend, $subscription);
+ $objects[] = new Subscription($this->caldavBackend, $subscription);
}
}
- return $objs;
+ return $objects;
}
/**
@@ -79,7 +88,7 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
// Calendars
foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
if ($calendar['uri'] === $name) {
- return new Calendar($this->caldavBackend, $calendar);
+ return new Calendar($this->caldavBackend, $calendar, $this->l10n);
}
}
@@ -94,4 +103,4 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
throw new NotFound('Node with name \'' . $name . '\' could not be found');
}
-} \ No newline at end of file
+}
diff --git a/apps/dav/tests/unit/caldav/caldavbackendtest.php b/apps/dav/tests/unit/caldav/caldavbackendtest.php
index 87a700a473d..a4a19f5bd3e 100644
--- a/apps/dav/tests/unit/caldav/caldavbackendtest.php
+++ b/apps/dav/tests/unit/caldav/caldavbackendtest.php
@@ -136,14 +136,23 @@ class CalDavBackendTest extends TestCase {
*/
public function testCalendarSharing($userCanRead, $userCanWrite, $groupCanRead, $groupCanWrite, $add) {
+ $l10n = $this->getMockBuilder('\OCP\IL10N')
+ ->disableOriginalConstructor()->getMock();
+ $l10n
+ ->expects($this->any())
+ ->method('t')
+ ->will($this->returnCallback(function ($text, $parameters = array()) {
+ return vsprintf($text, $parameters);
+ }));
+
$calendarId = $this->createTestCalendar();
$books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertEquals(1, count($books));
- $calendar = new Calendar($this->backend, $books[0]);
+ $calendar = new Calendar($this->backend, $books[0], $l10n);
$this->backend->updateShares($calendar, $add, []);
$books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER1);
$this->assertEquals(1, count($books));
- $calendar = new Calendar($this->backend, $books[0]);
+ $calendar = new Calendar($this->backend, $books[0], $l10n);
$acl = $calendar->getACL();
$this->assertAcl(self::UNIT_TEST_USER, '{DAV:}read', $acl);
$this->assertAcl(self::UNIT_TEST_USER, '{DAV:}write', $acl);
diff --git a/apps/dav/tests/unit/caldav/calendartest.php b/apps/dav/tests/unit/caldav/calendartest.php
index 9e0c3c6c7e4..812e0074d15 100644
--- a/apps/dav/tests/unit/caldav/calendartest.php
+++ b/apps/dav/tests/unit/caldav/calendartest.php
@@ -23,11 +23,27 @@ namespace OCA\DAV\Tests\Unit\CalDAV;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
+use OCP\IL10N;
use Sabre\DAV\PropPatch;
use Test\TestCase;
class CalendarTest extends TestCase {
+ /** @var IL10N */
+ private $l10n;
+
+ public function setUp() {
+ parent::setUp();
+ $this->l10n = $this->getMockBuilder('\OCP\IL10N')
+ ->disableOriginalConstructor()->getMock();
+ $this->l10n
+ ->expects($this->any())
+ ->method('t')
+ ->will($this->returnCallback(function ($text, $parameters = array()) {
+ return vsprintf($text, $parameters);
+ }));
+ }
+
public function testDelete() {
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
$backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
@@ -41,7 +57,7 @@ class CalendarTest extends TestCase {
'id' => 666,
'uri' => 'cal',
];
- $c = new Calendar($backend, $calendarInfo);
+ $c = new Calendar($backend, $calendarInfo, $this->l10n);
$c->delete();
}
@@ -61,7 +77,7 @@ class CalendarTest extends TestCase {
'id' => 666,
'uri' => 'cal',
];
- $c = new Calendar($backend, $calendarInfo);
+ $c = new Calendar($backend, $calendarInfo, $this->l10n);
$c->delete();
}
@@ -93,7 +109,7 @@ class CalendarTest extends TestCase {
'id' => 666,
'uri' => 'default'
];
- $c = new Calendar($backend, $calendarInfo);
+ $c = new Calendar($backend, $calendarInfo, $this->l10n);
if ($throws) {
$this->setExpectedException('\Sabre\DAV\Exception\Forbidden');
@@ -122,7 +138,7 @@ class CalendarTest extends TestCase {
if ($hasOwnerSet) {
$calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1';
}
- $c = new Calendar($backend, $calendarInfo);
+ $c = new Calendar($backend, $calendarInfo, $this->l10n);
$acl = $c->getACL();
$childAcl = $c->getChildACL();