diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
index 3e85615638b5c..694650c97bf9b 100644
--- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
@@ -46,6 +46,7 @@ class FilesReportPlugin extends ServerPlugin {
const NS_OWNCLOUD = 'http://owncloud.org/ns';
const REPORT_NAME = '{http://owncloud.org/ns}filter-files';
const SYSTEMTAG_PROPERTYNAME = '{http://owncloud.org/ns}systemtag';
+ const CIRCLE_PROPERTYNAME = '{http://owncloud.org/ns}circle';
/**
* Reference to main server object
@@ -256,14 +257,19 @@ protected function processFilterRules($filterRules) {
$ns = '{' . $this::NS_OWNCLOUD . '}';
$resultFileIds = null;
$systemTagIds = [];
+ $circlesIds = [];
$favoriteFilter = null;
foreach ($filterRules as $filterRule) {
if ($filterRule['name'] === $ns . 'systemtag') {
$systemTagIds[] = $filterRule['value'];
}
+ if ($filterRule['name'] === $ns . 'circle') {
+ $circlesIds[] = $filterRule['value'];
+ }
if ($filterRule['name'] === $ns . 'favorite') {
$favoriteFilter = true;
}
+
}
if ($favoriteFilter !== null) {
@@ -282,6 +288,15 @@ protected function processFilterRules($filterRules) {
}
}
+ if (!empty($circlesIds)) {
+ $fileIds = $this->getCirclesFileIds($circlesIds);
+ if (empty($resultFileIds)) {
+ $resultFileIds = $fileIds;
+ } else {
+ $resultFileIds = array_intersect($fileIds, $resultFileIds);
+ }
+ }
+
return $resultFileIds;
}
@@ -328,6 +343,29 @@ private function getSystemTagFileIds($systemTagIds) {
return $resultFileIds;
}
+ private function getCirclesFileIds($circlesIds) {
+
+ // check user permissions, if applicable
+ /*
+ if (!$this->isAdmin()) {
+ // check visibility/permission
+ $tags = $this->tagManager->getTagsByIds($circlesIds);
+ $unknownTagIds = [];
+ foreach ($tags as $tag) {
+ if (!$tag->isUserVisible()) {
+ $unknownTagIds[] = $tag->getId();
+ }
+ }
+
+ if (!empty($unknownTagIds)) {
+ throw new TagNotFoundException('Tag with ids ' . implode(', ', $unknownTagIds) . ' not found');
+ }
+ }
+ */
+
+ return \OCA\Circles\Api\v1\Circles::getObjectIdsForCircles($circlesIds);
+ }
+
/**
* Prepare propfind response for the given nodes
*
diff --git a/core/js/files/client.js b/core/js/files/client.js
index 2017becf87c66..98874d165bf35 100644
--- a/core/js/files/client.js
+++ b/core/js/files/client.js
@@ -503,7 +503,7 @@
/**
* Fetches a flat list of files filtered by a given filter criteria.
- * (currently only system tags is supported)
+ * (currently system tags and circles are supported)
*
* @param {Object} filter filter criteria
* @param {Object} [filter.systemTagIds] list of system tag ids to filter by
@@ -525,7 +525,8 @@
properties = options.properties;
}
- if (!filter || (!filter.systemTagIds && _.isUndefined(filter.favorite))) {
+ if (!filter ||
+ (!filter.systemTagIds && _.isUndefined(filter.favorite) && !filter.circlesIds) ) {
throw 'Missing filter argument';
}
@@ -551,6 +552,9 @@
_.each(filter.systemTagIds, function(systemTagIds) {
body += ' ' + escapeHTML(systemTagIds) + '\n';
});
+ _.each(filter.circlesIds, function(circlesIds) {
+ body += ' ' + escapeHTML(circlesIds) + '\n';
+ });
if (filter.favorite) {
body += ' ' + (filter.favorite ? '1': '0') + '\n';
}