1
0

IProfileManager.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. ];
  50. /**
  51. * Default visibility
  52. *
  53. * @since 28.0.0
  54. */
  55. public const DEFAULT_VISIBILITY = self::VISIBILITY_SHOW_USERS_ONLY;
  56. /**
  57. * If no user is passed as an argument return whether profile is enabled globally in `config.php`
  58. *
  59. * @since 28.0.0
  60. */
  61. public function isProfileEnabled(?IUser $user = null): bool;
  62. /**
  63. * Return whether the profile parameter of the target user
  64. * is visible to the visiting user
  65. *
  66. * @since 28.0.0
  67. */
  68. public function isProfileFieldVisible(string $profileField, IUser $targetUser, ?IUser $visitingUser): bool;
  69. /**
  70. * Return the profile parameters of the target user that are visible to the visiting user
  71. * in an associative array
  72. *
  73. * @return array{userId: string, address?: ?string, biography?: ?string, displayname?: ?string, headline?: ?string, isUserAvatarVisible?: bool, organisation?: ?string, role?: ?string, actions: list<array{id: string, icon: string, title: string, target: ?string}>}
  74. * @since 28.0.0
  75. */
  76. public function getProfileFields(IUser $targetUser, ?IUser $visitingUser): array;
  77. }