IProfileManager.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Profile;
  8. use OCP\Accounts\IAccountManager;
  9. use OCP\IUser;
  10. /**
  11. * @since 28.0.0
  12. */
  13. interface IProfileManager {
  14. /**
  15. * Visible to users, guests, and public access
  16. *
  17. * @since 28.0.0
  18. */
  19. public const VISIBILITY_SHOW = 'show';
  20. /**
  21. * Visible to users and guests
  22. *
  23. * @since 28.0.0
  24. */
  25. public const VISIBILITY_SHOW_USERS_ONLY = 'show_users_only';
  26. /**
  27. * Visible to nobody
  28. *
  29. * @since 28.0.0
  30. */
  31. public const VISIBILITY_HIDE = 'hide';
  32. /**
  33. * Default account property visibility
  34. *
  35. * @since 28.0.0
  36. */
  37. public const DEFAULT_PROPERTY_VISIBILITY = [
  38. IAccountManager::PROPERTY_ADDRESS => self::VISIBILITY_SHOW_USERS_ONLY,
  39. IAccountManager::PROPERTY_AVATAR => self::VISIBILITY_SHOW,
  40. IAccountManager::PROPERTY_BIOGRAPHY => self::VISIBILITY_SHOW,
  41. IAccountManager::PROPERTY_DISPLAYNAME => self::VISIBILITY_SHOW,
  42. IAccountManager::PROPERTY_HEADLINE => self::VISIBILITY_SHOW,
  43. IAccountManager::PROPERTY_ORGANISATION => self::VISIBILITY_SHOW,
  44. IAccountManager::PROPERTY_ROLE => self::VISIBILITY_SHOW,
  45. IAccountManager::PROPERTY_EMAIL => self::VISIBILITY_SHOW_USERS_ONLY,
  46. IAccountManager::PROPERTY_PHONE => self::VISIBILITY_SHOW_USERS_ONLY,
  47. IAccountManager::PROPERTY_TWITTER => self::VISIBILITY_SHOW,
  48. IAccountManager::PROPERTY_WEBSITE => self::VISIBILITY_SHOW,
  49. IAccountManager::PROPERTY_PRONOUNS => self::VISIBILITY_SHOW,
  50. ];
  51. /**
  52. * Default visibility
  53. *
  54. * @since 28.0.0
  55. */
  56. public const DEFAULT_VISIBILITY = self::VISIBILITY_SHOW_USERS_ONLY;
  57. /**
  58. * If no user is passed as an argument return whether profile is enabled globally in `config.php`
  59. *
  60. * @since 28.0.0
  61. */
  62. public function isProfileEnabled(?IUser $user = null): bool;
  63. /**
  64. * Return whether the profile parameter of the target user
  65. * is visible to the visiting user
  66. *
  67. * @since 28.0.0
  68. */
  69. public function isProfileFieldVisible(string $profileField, IUser $targetUser, ?IUser $visitingUser): bool;
  70. /**
  71. * Return the profile parameters of the target user that are visible to the visiting user
  72. * in an associative array
  73. *
  74. * @return array{userId: string, address?: string|null, biography?: string|null, displayname?: string|null, headline?: string|null, isUserAvatarVisible?: bool, organisation?: string|null, pronouns?: string|null, role?: string|null, actions: list<array{id: string, icon: string, title: string, target: ?string}>}
  75. * @since 28.0.0
  76. */
  77. public function getProfileFields(IUser $targetUser, ?IUser $visitingUser): array;
  78. }