88 */
99namespace OCA \DAV \CalDAV ;
1010
11+ use OCA \DAV \Db \Property ;
12+ use OCA \DAV \Db \PropertyMapper ;
1113use OCP \Calendar \ICalendarProvider ;
1214use OCP \IConfig ;
1315use OCP \IL10N ;
@@ -27,11 +29,15 @@ class CalendarProvider implements ICalendarProvider {
2729 /** @var LoggerInterface */
2830 private $ logger ;
2931
30- public function __construct (CalDavBackend $ calDavBackend , IL10N $ l10n , IConfig $ config , LoggerInterface $ logger ) {
32+ /** @var PropertyMapper */
33+ private $ propertyMapper ;
34+
35+ public function __construct (CalDavBackend $ calDavBackend , IL10N $ l10n , IConfig $ config , LoggerInterface $ logger , PropertyMapper $ propertyMapper ) {
3136 $ this ->calDavBackend = $ calDavBackend ;
3237 $ this ->l10n = $ l10n ;
3338 $ this ->config = $ config ;
3439 $ this ->logger = $ logger ;
40+ $ this ->propertyMapper = $ propertyMapper ;
3541 }
3642
3743 public function getCalendars (string $ principalUri , array $ calendarUris = []): array {
@@ -48,6 +54,7 @@ public function getCalendars(string $principalUri, array $calendarUris = []): ar
4854
4955 $ iCalendars = [];
5056 foreach ($ calendarInfos as $ calendarInfo ) {
57+ $ calendarInfo = array_merge ($ calendarInfo , $ this ->getAdditionalProperties ($ calendarInfo ['principaluri ' ], $ calendarInfo ['uri ' ]));
5158 $ calendar = new Calendar ($ this ->calDavBackend , $ calendarInfo , $ this ->l10n , $ this ->config , $ this ->logger );
5259 $ iCalendars [] = new CalendarImpl (
5360 $ calendar ,
@@ -57,4 +64,23 @@ public function getCalendars(string $principalUri, array $calendarUris = []): ar
5764 }
5865 return $ iCalendars ;
5966 }
67+
68+ public function getAdditionalProperties (string $ principalUri , string $ calendarUri ): array {
69+ $ user = str_replace ('principals/users/ ' , '' , $ principalUri );
70+ $ path = 'calendars/ ' . $ user . '/ ' . $ calendarUri ;
71+
72+ $ properties = $ this ->propertyMapper ->findPropertiesByPath ($ user , $ path );
73+
74+ $ list = [];
75+ foreach ($ properties as $ property ) {
76+ if ($ property instanceof Property) {
77+ $ list [$ property ->getPropertyname ()] = match ($ property ->getPropertyname ()) {
78+ '{http://owncloud.org/ns}calendar-enabled ' => (bool ) $ property ->getPropertyvalue (),
79+ default => $ property ->getPropertyvalue ()
80+ };
81+ }
82+ }
83+
84+ return $ list ;
85+ }
6086}
0 commit comments