IProfileManager.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Joas Schilling <coding@schilljs.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\Profile;
  25. use OCP\Accounts\IAccountManager;
  26. use OCP\IUser;
  27. /**
  28. * @since 28.0.0
  29. */
  30. interface IProfileManager {
  31. /**
  32. * Visible to users, guests, and public access
  33. *
  34. * @since 28.0.0
  35. */
  36. public const VISIBILITY_SHOW = 'show';
  37. /**
  38. * Visible to users and guests
  39. *
  40. * @since 28.0.0
  41. */
  42. public const VISIBILITY_SHOW_USERS_ONLY = 'show_users_only';
  43. /**
  44. * Visible to nobody
  45. *
  46. * @since 28.0.0
  47. */
  48. public const VISIBILITY_HIDE = 'hide';
  49. /**
  50. * Default account property visibility
  51. *
  52. * @since 28.0.0
  53. */
  54. public const DEFAULT_PROPERTY_VISIBILITY = [
  55. IAccountManager::PROPERTY_ADDRESS => self::VISIBILITY_SHOW_USERS_ONLY,
  56. IAccountManager::PROPERTY_AVATAR => self::VISIBILITY_SHOW,
  57. IAccountManager::PROPERTY_BIOGRAPHY => self::VISIBILITY_SHOW,
  58. IAccountManager::PROPERTY_DISPLAYNAME => self::VISIBILITY_SHOW,
  59. IAccountManager::PROPERTY_HEADLINE => self::VISIBILITY_SHOW,
  60. IAccountManager::PROPERTY_ORGANISATION => self::VISIBILITY_SHOW,
  61. IAccountManager::PROPERTY_ROLE => self::VISIBILITY_SHOW,
  62. IAccountManager::PROPERTY_EMAIL => self::VISIBILITY_SHOW_USERS_ONLY,
  63. IAccountManager::PROPERTY_PHONE => self::VISIBILITY_SHOW_USERS_ONLY,
  64. IAccountManager::PROPERTY_TWITTER => self::VISIBILITY_SHOW,
  65. IAccountManager::PROPERTY_WEBSITE => self::VISIBILITY_SHOW,
  66. ];
  67. /**
  68. * Default visibility
  69. *
  70. * @since 28.0.0
  71. */
  72. public const DEFAULT_VISIBILITY = self::VISIBILITY_SHOW_USERS_ONLY;
  73. /**
  74. * If no user is passed as an argument return whether profile is enabled globally in `config.php`
  75. *
  76. * @since 28.0.0
  77. */
  78. public function isProfileEnabled(?IUser $user = null): bool;
  79. /**
  80. * Return whether the profile parameter of the target user
  81. * is visible to the visiting user
  82. *
  83. * @since 28.0.0
  84. */
  85. public function isProfileFieldVisible(string $profileField, IUser $targetUser, ?IUser $visitingUser): bool;
  86. /**
  87. * Return the profile parameters of the target user that are visible to the visiting user
  88. * in an associative array
  89. *
  90. * @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}>}
  91. * @since 28.0.0
  92. */
  93. public function getProfileFields(IUser $targetUser, ?IUser $visitingUser): array;
  94. }