-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Public API to get user acocunt data #11740
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> | ||
| * | ||
| * @author Julius Härtl <jus@bitgrid.net> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Accounts; | ||
|
|
||
| use OCP\Accounts\IAccount; | ||
| use OCP\Accounts\IAccountProperty; | ||
| use OCP\Accounts\PropertyDoesNotExistException; | ||
| use OCP\IUser; | ||
|
|
||
| class Account implements IAccount { | ||
|
|
||
| /** @var IAccountProperty[] */ | ||
| private $properties = []; | ||
|
|
||
| /** @var IUser */ | ||
| private $user; | ||
|
|
||
| public function __construct(IUser $user) { | ||
| $this->user = $user; | ||
| } | ||
|
|
||
| public function setProperty(string $property, string $value, string $scope, string $verified): IAccount { | ||
| $this->properties[$property] = new AccountProperty($property, $value, $scope, $verified); | ||
| return $this; | ||
| } | ||
|
|
||
| public function getProperty(string $property): IAccountProperty { | ||
| if (!array_key_exists($property, $this->properties)) { | ||
juliusknorr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| throw new PropertyDoesNotExistException($property); | ||
| } | ||
| return $this->properties[$property]; | ||
juliusknorr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public function getProperties(): array { | ||
| return $this->properties; | ||
| } | ||
|
|
||
| public function getFilteredProperties(string $scope = null, string $verified = null): array { | ||
| return \array_filter($this->properties, function(IAccountProperty $obj) use ($scope, $verified){ | ||
| if ($scope !== null && $scope !== $obj->getScope()) { | ||
| return false; | ||
| } | ||
| if ($verified !== null && $verified !== $obj->getVerified()) { | ||
| return false; | ||
| } | ||
| return true; | ||
| }); | ||
| } | ||
|
|
||
| public function jsonSerialize() { | ||
| return $this->properties; | ||
juliusknorr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public function getUser(): IUser { | ||
| return $this->user; | ||
| } | ||
| } | ||
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
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 |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> | ||
| * | ||
| * @author Julius Härtl <jus@bitgrid.net> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Accounts; | ||
|
|
||
| use OCP\Accounts\IAccountProperty; | ||
|
|
||
| class AccountProperty implements IAccountProperty { | ||
|
|
||
| /** @var string */ | ||
| private $name; | ||
juliusknorr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** @var string */ | ||
| private $value; | ||
| /** @var string */ | ||
| private $scope; | ||
| /** @var string */ | ||
| private $verified; | ||
|
|
||
| public function __construct(string $name, string $value, string $scope, string $verified) { | ||
| $this->name = $name; | ||
| $this->value = $value; | ||
| $this->scope = $scope; | ||
| $this->verified = $verified; | ||
| } | ||
|
|
||
| public function jsonSerialize() { | ||
| return [ | ||
| 'name' => $this->getName(), | ||
| 'value' => $this->getValue(), | ||
| 'scope' => $this->getScope(), | ||
| 'verified' => $this->getVerified() | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Set the value of a property | ||
| * | ||
| * @since 15.0.0 | ||
| * | ||
| * @param string $value | ||
| * @return IAccountProperty | ||
| */ | ||
| public function setValue(string $value): IAccountProperty { | ||
| $this->value = $value; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Set the scope of a property | ||
| * | ||
| * @since 15.0.0 | ||
| * | ||
| * @param string $scope | ||
| * @return IAccountProperty | ||
| */ | ||
| public function setScope(string $scope): IAccountProperty { | ||
| $this->scope = $scope; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Set the verification status of a property | ||
| * | ||
| * @since 15.0.0 | ||
| * | ||
| * @param string $verified | ||
| * @return IAccountProperty | ||
| */ | ||
| public function setVerified(string $verified): IAccountProperty { | ||
| $this->verified = $verified; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Get the name of a property | ||
| * | ||
| * @since 15.0.0 | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getName(): string { | ||
| return $this->name; | ||
| } | ||
|
|
||
| /** | ||
| * Get the value of a property | ||
| * | ||
| * @since 15.0.0 | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getValue(): string { | ||
| return $this->value; | ||
| } | ||
|
|
||
| /** | ||
| * Get the scope of a property | ||
| * | ||
| * @since 15.0.0 | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getScope(): string { | ||
| return $this->scope; | ||
| } | ||
|
|
||
| /** | ||
| * Get the verification status of a property | ||
| * | ||
| * @since 15.0.0 | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getVerified(): string { | ||
| return $this->verified; | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.