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.php22
-rw-r--r--lib/public/Profile/IProfileManager.php93
-rw-r--r--lib/public/Profile/ParameterDoesNotExistException.php22
4 files changed, 133 insertions, 40 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
index 67e69a73d9c..21fea701a2b 100644
--- a/lib/public/Profile/ILinkAction.php
+++ b/lib/public/Profile/ILinkAction.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2021 Christopher Ng <chrng8@gmail.com>
- *
- * @author Christopher Ng <chrng8@gmail.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Profile;
@@ -32,7 +15,6 @@ use OCP\IUser;
* @since 23.0.0
*/
interface ILinkAction {
-
/**
* Preload the user specific value required by the action
*
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
index 543a8edc17a..a2979489a30 100644
--- a/lib/public/Profile/ParameterDoesNotExistException.php
+++ b/lib/public/Profile/ParameterDoesNotExistException.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2021 Christopher Ng <chrng8@gmail.com>
- *
- * @author Christopher Ng <chrng8@gmail.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Profile;
@@ -30,7 +13,6 @@ namespace OCP\Profile;
* @since 23.0.0
*/
class ParameterDoesNotExistException extends \Exception {
-
/**
* @since 23.0.0
*/