summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-08-01 16:44:28 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 11:55:39 +0200
commit691b3ab448907664a7fac29d1e8e795e1c6cd012 (patch)
tree5fd4a86122f1dcf0526ee35b0964c652b68ef562 /apps
parentdd248caa0984c6d932855aa39fd3025d6f553f82 (diff)
downloadnextcloud-server-691b3ab448907664a7fac29d1e8e795e1c6cd012.tar.gz
nextcloud-server-691b3ab448907664a7fac29d1e8e795e1c6cd012.zip
Add publicuri to oc_dav_shares table and start working with it
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/appinfo/database.xml8
-rw-r--r--apps/dav/appinfo/info.xml2
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php67
-rw-r--r--apps/dav/lib/CalDAV/PublicCalendarRoot.php3
4 files changed, 67 insertions, 13 deletions
diff --git a/apps/dav/appinfo/database.xml b/apps/dav/appinfo/database.xml
index 9578526a705..eb8f70e7c95 100644
--- a/apps/dav/appinfo/database.xml
+++ b/apps/dav/appinfo/database.xml
@@ -703,6 +703,11 @@ CREATE TABLE calendarobjects (
<notnull>true</notnull>
<unsigned>true</unsigned>
</field>
+ <field>
+ <name>publicuri</name>
+ <type>text</type>
+ <length>255</length>
+ </field>
<index>
<name>dav_shares_index</name>
<unique>true</unique>
@@ -715,6 +720,9 @@ CREATE TABLE calendarobjects (
<field>
<name>type</name>
</field>
+ <field>
+ <name>publicuri</name>
+ </field>
</index>
</declaration>
</table>
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml
index 19b65d84327..33621ce70aa 100644
--- a/apps/dav/appinfo/info.xml
+++ b/apps/dav/appinfo/info.xml
@@ -5,7 +5,7 @@
<description>WebDAV endpoint</description>
<licence>AGPL</licence>
<author>owncloud.org</author>
- <version>1.1.0</version>
+ <version>1.1.1</version>
<default_enable/>
<types>
<filesystem/>
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 1be8db160cb..2daecc72496 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -316,6 +316,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$fields[] = 'a.principaluri';
$fields[] = 'a.transparent';
$fields[] = 's.access';
+ $fields[] = 's.publicuri';
$calendars = [];
$query = $this->db->getQueryBuilder();
$result = $query->select($fields)
@@ -332,10 +333,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
if ($row['components']) {
$components = explode(',',$row['components']);
}
- $uri = md5($this->config->getSystemValue('secret', '') . $row['id']);
$calendar = [
'id' => $row['id'],
- 'uri' => $uri,
+ 'uri' => $row['publicuri'],
'principaluri' => $row['principaluri'],
'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
@@ -361,18 +361,62 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
/**
* @param string $uri
- * @return Calendar
+ * @return array
* @throws NotFound
*/
public function getPublicCalendar($uri) {
- $l10n = \OC::$server->getL10N('dav');
- foreach ($this->getPublicCalendars() as $calendar) {
- if ($calendar['uri'] === $uri) {
- // TODO: maybe implement a new class PublicCalendar ???
- return new Calendar($this, $calendar, $l10n);
- }
+ $fields = array_values($this->propertyMap);
+ $fields[] = 'a.id';
+ $fields[] = 'a.uri';
+ $fields[] = 'a.synctoken';
+ $fields[] = 'a.components';
+ $fields[] = 'a.principaluri';
+ $fields[] = 'a.transparent';
+ $fields[] = 's.access';
+ $fields[] = 's.publicuri';
+ $query = $this->db->getQueryBuilder();
+ $result = $query->select($fields)
+ ->from('dav_shares', 's')
+ ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
+ ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
+ ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
+ ->andWhere($query->expr()->eq('s.publicuri', $query->createNamedParameter($uri)))
+ ->execute();
+
+ $row = $result->fetch(\PDO::FETCH_ASSOC);
+
+ $result->closeCursor();
+
+ if ($row === false) {
+ throw new NotFound('Node with name \'' . $uri . '\' could not be found');
}
- throw new NotFound('Node with name \'' . $uri . '\' could not be found');
+
+ list(, $name) = URLUtil::splitPath($row['principaluri']);
+ $row['displayname'] = $row['displayname'] . "($name)";
+ $components = [];
+ if ($row['components']) {
+ $components = explode(',',$row['components']);
+ }
+ $uri = md5($this->config->getSystemValue('secret', '') . $row['id']);
+ $calendar = [
+ 'id' => $row['id'],
+ 'uri' => $uri,
+ 'principaluri' => $row['principaluri'],
+ '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
+ '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
+ '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
+ '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
+ '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
+ '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
+ '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
+ ];
+
+ foreach($this->propertyMap as $xmlName=>$dbName) {
+ $calendar[$xmlName] = $row[$dbName];
+ }
+
+ return array_values($calendar);
+
}
/**
@@ -1563,7 +1607,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'principaluri' => $query->createNamedParameter($calendar->getPrincipalURI()),
'type' => $query->createNamedParameter('calendar'),
'access' => $query->createNamedParameter(self::ACCESS_PUBLIC),
- 'resourceid' => $query->createNamedParameter($calendar->getResourceId())
+ 'resourceid' => $query->createNamedParameter($calendar->getResourceId()),
+ 'publicuri' => $query->createNamedParameter(md5($this->config->getSystemValue('secret', '') . $calendar->getResourceId()))
]);
} else {
$query->delete('dav_shares')
diff --git a/apps/dav/lib/CalDAV/PublicCalendarRoot.php b/apps/dav/lib/CalDAV/PublicCalendarRoot.php
index b8d209d7073..6d74b97f96e 100644
--- a/apps/dav/lib/CalDAV/PublicCalendarRoot.php
+++ b/apps/dav/lib/CalDAV/PublicCalendarRoot.php
@@ -47,7 +47,8 @@ class PublicCalendarRoot extends Collection {
* @inheritdoc
*/
function getChild($name) {
- return $this->caldavBackend->getPublicCalendar($name);
+ $calendar = $this->caldavBackend->getPublicCalendar($name);
+ return new Calendar($this->caldavBackend, $calendar, $this->l10n);
}
/**