aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Profile
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Profile')
-rw-r--r--lib/public/Profile/BeforeTemplateRenderedEvent.php36
-rw-r--r--lib/public/Profile/ILinkAction.php97
-rw-r--r--lib/public/Profile/IProfileManager.php93
-rw-r--r--lib/public/Profile/ParameterDoesNotExistException.php22
4 files changed, 248 insertions, 0 deletions
diff --git a/lib/public/Profile/BeforeTemplateRenderedEvent.php b/lib/public/Profile/BeforeTemplateRenderedEvent.php
new file mode 100644
index 00000000000..1fbeec28b0f
--- /dev/null
+++ b/lib/public/Profile/BeforeTemplateRenderedEvent.php
@@ -0,0 +1,36 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Profile;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * Emitted before the rendering step of the public profile page happens.
+ *
+ * @since 25.0.0
+ */
+class BeforeTemplateRenderedEvent extends Event {
+ private string $userId;
+
+ /**
+ * @since 25.0.0
+ */
+ public function __construct(string $userId) {
+ parent::__construct();
+
+ $this->userId = $userId;
+ }
+
+ /**
+ * @since 25.0.0
+ */
+ public function getUserId(): string {
+ return $this->userId;
+ }
+}
diff --git a/lib/public/Profile/ILinkAction.php b/lib/public/Profile/ILinkAction.php
new file mode 100644
index 00000000000..21fea701a2b
--- /dev/null
+++ b/lib/public/Profile/ILinkAction.php
@@ -0,0 +1,97 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Profile;
+
+use OCP\IUser;
+
+/**
+ * @since 23.0.0
+ */
+interface ILinkAction {
+ /**
+ * Preload the user specific value required by the action
+ *
+ * e.g. the email is loaded for the email action and the userId for the Talk action
+ *
+ * @since 23.0.0
+ */
+ public function preload(IUser $targetUser): void;
+
+ /**
+ * Returns the app ID of the action
+ *
+ * e.g. 'spreed'
+ *
+ * @since 23.0.0
+ */
+ public function getAppId(): string;
+
+ /**
+ * Returns the unique ID of the action
+ *
+ * *For account properties this is the constant defined in lib/public/Accounts/IAccountManager.php*
+ *
+ * e.g. 'email'
+ *
+ * @since 23.0.0
+ */
+ public function getId(): string;
+
+ /**
+ * Returns the translated unique display ID of the action
+ *
+ * Should be something short and descriptive of the action
+ * as this is seen by the end-user when configuring actions
+ *
+ * e.g. 'Email'
+ *
+ * @since 23.0.0
+ */
+ public function getDisplayId(): string;
+
+ /**
+ * Returns the translated title
+ *
+ * e.g. 'Mail user@domain.com'
+ *
+ * Use the L10N service to translate it
+ *
+ * @since 23.0.0
+ */
+ public function getTitle(): string;
+
+ /**
+ * Returns the priority
+ *
+ * *Actions are sorted in ascending order*
+ *
+ * e.g. 60
+ *
+ * @since 23.0.0
+ */
+ public function getPriority(): int;
+
+ /**
+ * Returns the URL link to the 16*16 SVG icon
+ *
+ * @since 23.0.0
+ */
+ public function getIcon(): string;
+
+ /**
+ * Returns the target of the action,
+ * if null is returned the action won't be registered
+ *
+ * e.g. 'mailto:user@domain.com'
+ *
+ * @since 23.0.0
+ */
+ public function getTarget(): ?string;
+}
diff --git a/lib/public/Profile/IProfileManager.php b/lib/public/Profile/IProfileManager.php
new file mode 100644
index 00000000000..aec06fb4c86
--- /dev/null
+++ b/lib/public/Profile/IProfileManager.php
@@ -0,0 +1,93 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Profile;
+
+use OC\Core\ResponseDefinitions;
+use OCP\Accounts\IAccountManager;
+use OCP\IUser;
+
+/**
+ * @psalm-import-type CoreProfileFields from ResponseDefinitions
+ * @since 28.0.0
+ */
+interface IProfileManager {
+ /**
+ * Visible to users, guests, and public access
+ *
+ * @since 28.0.0
+ */
+ public const VISIBILITY_SHOW = 'show';
+
+ /**
+ * Visible to users and guests
+ *
+ * @since 28.0.0
+ */
+ public const VISIBILITY_SHOW_USERS_ONLY = 'show_users_only';
+
+ /**
+ * Visible to nobody
+ *
+ * @since 28.0.0
+ */
+ public const VISIBILITY_HIDE = 'hide';
+
+ /**
+ * Default account property visibility
+ *
+ * @since 28.0.0
+ */
+ public const DEFAULT_PROPERTY_VISIBILITY = [
+ IAccountManager::PROPERTY_ADDRESS => self::VISIBILITY_SHOW_USERS_ONLY,
+ IAccountManager::PROPERTY_AVATAR => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_BIOGRAPHY => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_DISPLAYNAME => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_HEADLINE => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_ORGANISATION => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_ROLE => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_EMAIL => self::VISIBILITY_SHOW_USERS_ONLY,
+ IAccountManager::PROPERTY_PHONE => self::VISIBILITY_SHOW_USERS_ONLY,
+ IAccountManager::PROPERTY_TWITTER => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_BLUESKY => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_WEBSITE => self::VISIBILITY_SHOW,
+ IAccountManager::PROPERTY_PRONOUNS => self::VISIBILITY_SHOW,
+ ];
+
+ /**
+ * Default visibility
+ *
+ * @since 28.0.0
+ */
+ public const DEFAULT_VISIBILITY = self::VISIBILITY_SHOW_USERS_ONLY;
+
+ /**
+ * If no user is passed as an argument return whether profile is enabled globally in `config.php`
+ *
+ * @since 28.0.0
+ */
+ public function isProfileEnabled(?IUser $user = null): bool;
+
+ /**
+ * Return whether the profile parameter of the target user
+ * is visible to the visiting user
+ *
+ * @since 28.0.0
+ */
+ public function isProfileFieldVisible(string $profileField, IUser $targetUser, ?IUser $visitingUser): bool;
+
+ /**
+ * Return the profile parameters of the target user that are visible to the visiting user
+ * in an associative array
+ *
+ * @psalm-return CoreProfileFields
+ * @since 28.0.0
+ */
+ public function getProfileFields(IUser $targetUser, ?IUser $visitingUser): array;
+}
diff --git a/lib/public/Profile/ParameterDoesNotExistException.php b/lib/public/Profile/ParameterDoesNotExistException.php
new file mode 100644
index 00000000000..a2979489a30
--- /dev/null
+++ b/lib/public/Profile/ParameterDoesNotExistException.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Profile;
+
+/**
+ * @since 23.0.0
+ */
+class ParameterDoesNotExistException extends \Exception {
+ /**
+ * @since 23.0.0
+ */
+ public function __construct($parameter) {
+ parent::__construct("Parameter $parameter does not exist.");
+ }
+}