-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Create infrastructure to allow files to be shared with circles #6959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9357b99
253b263
fff74e1
87c60b6
3e623e1
e840dc5
70069e2
7063683
38bfba8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There is a proposal to allow users to filter files shared to circles. This commit is needed to provide the infrastucture for it. Issue: nextcloud/circles#137 Signed-off-by: Vinicius Cubas Brand <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,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 | ||
|
|
@@ -255,14 +256,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) { | ||
|
|
@@ -281,6 +287,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; | ||
| } | ||
|
|
||
|
|
@@ -327,6 +342,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 | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -454,7 +454,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 | ||
|
|
@@ -476,7 +476,8 @@ | |
| properties = options.properties; | ||
| } | ||
|
|
||
| if (!filter || (!filter.systemTagIds && _.isUndefined(filter.favorite))) { | ||
| if (!filter || | ||
| (!filter.systemTagIds && _.isUndefined(filter.favorite) && !filter.circlesIds) ) { | ||
| throw 'Missing filter argument'; | ||
| } | ||
|
|
||
|
|
@@ -502,6 +503,9 @@ | |
| _.each(filter.systemTagIds, function(systemTagIds) { | ||
| body += ' <oc:systemtag>' + escapeHTML(systemTagIds) + '</oc:systemtag>\n'; | ||
| }); | ||
| _.each(filter.circlesIds, function(circlesIds) { | ||
| body += ' <oc:circle>' + escapeHTML(circlesIds) + '</oc:circle>\n'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nc? |
||
| }); | ||
| if (filter.favorite) { | ||
| body += ' <oc:favorite>' + (filter.favorite ? '1': '0') + '</oc:favorite>\n'; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
{http:/nextcloud.com/ns}circleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, adding hooks in dav app would be more elegant. But since system tags are already core factored in dav, we thought a first approach would be to have both system tags and circles working similarly.
We would be happy to collaborate to implement hooks in dav in the future, and then migrate both circles and system tags to the hooks approach.
Maybe, for NC13, we could start the way we've implemented now... What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another difference ;)
systemtags are shipped (therefor the code is not missing etc) while circles are totally optional