-
-
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
Closed
viniciuscb
wants to merge
9
commits into
nextcloud:master
from
coletivoEITA:add_circle_to_caldav_and_filepanel
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9357b99
Provide calendars shared w/ current user's circles
viniciuscb 253b263
Created infrastructure to show circles' shared files
viniciuscb fff74e1
Merge branch 'add_circle_to_caldav_and_filepanel' of github.com:colet…
viniciuscb 87c60b6
Changes to comply to https://github.com/coletivoEITA/circles/pull/2
viniciuscb 3e623e1
Polishing: get files shared to circles in caldav
viniciuscb e840dc5
fixing
ArtificialOwl 70069e2
Merge branch 'master' into add_circle_to_caldav_and_filepanel
ArtificialOwl 7063683
using CIRCLE__PROPERTYNAME
ArtificialOwl 38bfba8
Merge branch 'add_circle_to_caldav_and_filepanel-15' into add_circle_…
ArtificialOwl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Provide calendars shared w/ current user's circles
This commit allows the user to view the calendars that are shared with any circle s/he belongs to. Signed-off-by: Vinicius Cubas Brand <[email protected]>
- Loading branch information
commit 9357b997f795cebda4ebcda42a074ce695068d03
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ | |
| * @author Thomas Citharel <[email protected]> | ||
| * @author Thomas Müller <[email protected]> | ||
| * @author Georg Ehrke <[email protected]> | ||
| * @author Vinicius Cubas Brand <[email protected]> | ||
| * @author Daniel Tygel <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
| * | ||
|
|
@@ -280,6 +282,8 @@ function getCalendarsForUser($principalUri) { | |
|
|
||
| // query for shared calendars | ||
| $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true); | ||
| $principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal)); | ||
|
|
||
| $principals = array_map(function($principal) { | ||
| return urldecode($principal); | ||
| }, $principals); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
| * @author Thomas Müller <[email protected]> | ||
| * @author Thomas Tanghus <[email protected]> | ||
| * @author Vincent Petry <[email protected]> | ||
| * @author Vinicius Cubas Brand <[email protected]> | ||
| * @author Daniel Tygel <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
| * | ||
|
|
@@ -52,6 +54,9 @@ class Principal implements BackendInterface { | |
| /** @var bool */ | ||
| private $hasGroups; | ||
|
|
||
| /** @var bool */ | ||
| private $hasCircles; | ||
|
|
||
| /** | ||
| * @param IUserManager $userManager | ||
| * @param IGroupManager $groupManager | ||
|
|
@@ -63,7 +68,7 @@ public function __construct(IUserManager $userManager, | |
| $this->userManager = $userManager; | ||
| $this->groupManager = $groupManager; | ||
| $this->principalPrefix = trim($principalPrefix, '/'); | ||
| $this->hasGroups = ($principalPrefix === 'principals/users/'); | ||
| $this->hasGroups = $this->hasCircles = ($principalPrefix === 'principals/users/'); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -108,6 +113,8 @@ public function getPrincipalByPath($path) { | |
| if (!is_null($user)) { | ||
| return $this->userToPrincipal($user); | ||
| } | ||
| } else if ($prefix === 'principals/circles') { | ||
| return $this->circleToPrincipal($name); | ||
| } | ||
| return null; | ||
| } | ||
|
|
@@ -232,4 +239,66 @@ public function getPrincipalPrefix() { | |
| return $this->principalPrefix; | ||
| } | ||
|
|
||
| /** | ||
| * @param string $circleUniqueId | ||
| * @return array|null | ||
| */ | ||
| protected function circleToPrincipal($circleUniqueId) { | ||
| if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) { | ||
| return null; | ||
| } | ||
|
|
||
| $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($circleUniqueId); | ||
|
|
||
| if (!$circle) { | ||
| return null; | ||
| } | ||
|
|
||
| $principal = [ | ||
| 'uri' => 'principals/circles/' . $circleUniqueId, | ||
| '{DAV:}displayname' => $circle->getName(), | ||
| ]; | ||
|
|
||
| return $principal; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the list of circles a principal is a member of | ||
| * | ||
| * @param string $principal | ||
| * @param bool $needGroups | ||
| * @return array | ||
| * @throws Exception | ||
| */ | ||
| public function getCircleMembership($principal) { | ||
| if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) { | ||
| return []; | ||
| } | ||
|
|
||
| list($prefix, $name) = URLUtil::splitPath($principal); | ||
|
|
||
| if ($this->hasCircles && $prefix === $this->principalPrefix) { | ||
| $user = $this->userManager->get($name); | ||
| if (!$user) { | ||
| throw new Exception('Principal not found'); | ||
| } | ||
|
|
||
| $userSession = \OC::$server->getUserSession(); | ||
| $currentUser = $userSession->getUser(); | ||
|
|
||
| $userSession->setUser($user); | ||
| $circles = \OCA\Circles\Api\v1\Circles::joinedCircles(); | ||
| $userSession->setUser($currentUser); | ||
|
|
||
| $circles = array_map(function($circle) { | ||
| /** @var \OCA\Circles\Model\Circle $group */ | ||
| return 'principals/circles/' . urlencode($circle->getUniqueId()); | ||
| }, $circles); | ||
|
|
||
| return $circles; | ||
|
|
||
| } | ||
| return []; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we inject the current user in the constructor instead?