summaryrefslogtreecommitdiffstats
path: root/lib/public/Accounts
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2021-06-08 14:25:18 +0200
committerGitHub <noreply@github.com>2021-06-08 14:25:18 +0200
commit662ab937e0d30947727be1462f8744681fdd2e49 (patch)
tree3b857453adb11fb00d23d68515b85f6f84cfad6c /lib/public/Accounts
parentb3cfa1859b14384ae8134e8eb88c171667f77799 (diff)
parentff2382e5a4a5c29e3e1c948a514c151cae71d402 (diff)
downloadnextcloud-server-662ab937e0d30947727be1462f8744681fdd2e49.tar.gz
nextcloud-server-662ab937e0d30947727be1462f8744681fdd2e49.zip
Merge pull request #27189 from nextcloud/feat/26866/account-collection-properties
Extend Accounts with multivalue properties (PropertyCollection)
Diffstat (limited to 'lib/public/Accounts')
-rw-r--r--lib/public/Accounts/IAccount.php37
-rw-r--r--lib/public/Accounts/IAccountManager.php7
-rw-r--r--lib/public/Accounts/IAccountPropertyCollection.php84
3 files changed, 125 insertions, 3 deletions
diff --git a/lib/public/Accounts/IAccount.php b/lib/public/Accounts/IAccount.php
index 02c50259b13..72c207537dc 100644
--- a/lib/public/Accounts/IAccount.php
+++ b/lib/public/Accounts/IAccount.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
*/
namespace OCP\Accounts;
+use Generator;
use OCP\IUser;
/**
@@ -62,16 +63,48 @@ interface IAccount extends \JsonSerializable {
/**
* Get all properties of an account. Array indices are property names.
+ * Values from IAccountPropertyCollections are not included in the return
+ * array.
*
* @since 15.0.0
- *
- * @return IAccountProperty[]
+ * @deprecated 22.0.0 use getAllProperties()
*/
public function getProperties(): array;
/**
+ * Get all properties of an account. Array indices are numeric. To get
+ * the property name, call getName() against the value.
+ *
+ * IAccountPropertyCollections are being flattened into an IAccountProperty
+ * for each value.
+ *
+ * @since 22.0.0
+ *
+ * @return Generator<int, IAccountProperty>
+ */
+ public function getAllProperties(): Generator;
+
+ /**
+ * Set a property collection (multi-value properties)
+ *
+ * @since 22.0.0
+ */
+ public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount;
+
+ /**
+ * Returns the requestes propery collection (multi-value properties)
+ *
+ * @since 22.0.0
+ */
+ public function getPropertyCollection(string $propertyCollection): IAccountPropertyCollection;
+
+ /**
* Get all properties that match the provided filters for scope and verification status
*
+ * Since 22.0.0 values from IAccountPropertyCollection are included, but also
+ * as IAccountProperty instances. They for properties of IAccountPropertyCollection are
+ * suffixed incrementally, i.e. #0, #1 ... #n – the numbers have no further meaning.
+ *
* @since 15.0.0
*
* @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager
diff --git a/lib/public/Accounts/IAccountManager.php b/lib/public/Accounts/IAccountManager.php
index dc085b44b84..9418e07ec97 100644
--- a/lib/public/Accounts/IAccountManager.php
+++ b/lib/public/Accounts/IAccountManager.php
@@ -96,6 +96,8 @@ interface IAccountManager {
public const PROPERTY_ADDRESS = 'address';
public const PROPERTY_TWITTER = 'twitter';
+ public const COLLECTION_EMAIL = 'additional_mail';
+
public const NOT_VERIFIED = '0';
public const VERIFICATION_IN_PROGRESS = '1';
public const VERIFIED = '2';
@@ -123,7 +125,10 @@ interface IAccountManager {
/**
* Search for users based on account data
*
- * @param string $property
+ * @param string $property - property or property collection name – since
+ * NC 22 the implementation MAY add a fitting property collection into the
+ * search even if a property name was given e.g. email property and email
+ * collection)
* @param string[] $values
* @return array
*
diff --git a/lib/public/Accounts/IAccountPropertyCollection.php b/lib/public/Accounts/IAccountPropertyCollection.php
new file mode 100644
index 00000000000..9e026f4ce5b
--- /dev/null
+++ b/lib/public/Accounts/IAccountPropertyCollection.php
@@ -0,0 +1,84 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @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 <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Accounts;
+
+use InvalidArgumentException;
+use JsonSerializable;
+
+/**
+ * Interface IAccountPropertyCollection
+ *
+ * @package OCP\Accounts
+ *
+ * @since 22.0.0
+ */
+interface IAccountPropertyCollection extends JsonSerializable {
+
+ /**
+ * retuns the collection name
+ *
+ * @since 22.0.0
+ */
+ public function getName(): string;
+
+ /**
+ * set properties of this collection
+ *
+ * @param IAccountProperty[] $properties
+ * @throws InvalidArgumentException
+ * @since 22.0.0
+ */
+ public function setProperties(array $properties): IAccountPropertyCollection;
+
+ /**
+ * @return IAccountProperty[]
+ * @since 22.0.0
+ */
+ public function getProperties(): array;
+
+ /**
+ * adds a property to this collection
+ *
+ * @throws InvalidArgumentException
+ * @since 22.0.0
+ */
+ public function addProperty(IAccountProperty $property): IAccountPropertyCollection;
+
+ /**
+ * removes a property of this collection
+ *
+ * @since 22.0.0
+ */
+ public function removeProperty(IAccountProperty $property): IAccountPropertyCollection;
+
+ /**
+ * removes a property identified by its value
+ *
+ * @since 22.0.0
+ */
+ public function removePropertyByValue(string $value): IAccountPropertyCollection;
+}