IAccountManager.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Thomas Citharel <nextcloud@tcit.fr>
  10. * @author Vincent Petry <vincent@nextcloud.com>
  11. * @author Kate Döen <kate.doeen@nextcloud.com>
  12. *
  13. * @license GNU AGPL version 3 or any later version
  14. *
  15. * This program is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License as
  17. * published by the Free Software Foundation, either version 3 of the
  18. * License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. *
  28. */
  29. namespace OCP\Accounts;
  30. use OCP\IUser;
  31. /**
  32. * Access user profile information
  33. *
  34. * @since 15.0.0
  35. *
  36. */
  37. interface IAccountManager {
  38. /**
  39. * Contact details visible locally only
  40. *
  41. * @since 21.0.1
  42. */
  43. public const SCOPE_PRIVATE = 'v2-private';
  44. /**
  45. * Contact details visible locally and through public link access on local instance
  46. *
  47. * @since 21.0.1
  48. */
  49. public const SCOPE_LOCAL = 'v2-local';
  50. /**
  51. * Contact details visible locally, through public link access and on trusted federated servers.
  52. *
  53. * @since 21.0.1
  54. */
  55. public const SCOPE_FEDERATED = 'v2-federated';
  56. /**
  57. * Contact details visible locally, through public link access, on trusted federated servers
  58. * and published to the public lookup server.
  59. *
  60. * @since 21.0.1
  61. */
  62. public const SCOPE_PUBLISHED = 'v2-published';
  63. /**
  64. * Contact details only visible locally
  65. *
  66. * @deprecated 21.0.1
  67. */
  68. public const VISIBILITY_PRIVATE = 'private';
  69. /**
  70. * Contact details visible on trusted federated servers.
  71. *
  72. * @deprecated 21.0.1
  73. */
  74. public const VISIBILITY_CONTACTS_ONLY = 'contacts';
  75. /**
  76. * Contact details visible on trusted federated servers and in the public lookup server.
  77. *
  78. * @deprecated 21.0.1
  79. */
  80. public const VISIBILITY_PUBLIC = 'public';
  81. /**
  82. * The list of allowed scopes
  83. *
  84. * @since 25.0.0
  85. */
  86. public const ALLOWED_SCOPES = [
  87. self::SCOPE_PRIVATE,
  88. self::SCOPE_LOCAL,
  89. self::SCOPE_FEDERATED,
  90. self::SCOPE_PUBLISHED,
  91. self::VISIBILITY_PRIVATE,
  92. self::VISIBILITY_CONTACTS_ONLY,
  93. self::VISIBILITY_PUBLIC,
  94. ];
  95. public const PROPERTY_AVATAR = 'avatar';
  96. public const PROPERTY_DISPLAYNAME = 'displayname';
  97. public const PROPERTY_DISPLAYNAME_LEGACY = 'display-name';
  98. public const PROPERTY_PHONE = 'phone';
  99. public const PROPERTY_EMAIL = 'email';
  100. public const PROPERTY_WEBSITE = 'website';
  101. public const PROPERTY_ADDRESS = 'address';
  102. public const PROPERTY_TWITTER = 'twitter';
  103. public const PROPERTY_FEDIVERSE = 'fediverse';
  104. /**
  105. * @since 23.0.0
  106. */
  107. public const PROPERTY_ORGANISATION = 'organisation';
  108. /**
  109. * @since 23.0.0
  110. */
  111. public const PROPERTY_ROLE = 'role';
  112. /**
  113. * @since 23.0.0
  114. */
  115. public const PROPERTY_HEADLINE = 'headline';
  116. /**
  117. * @since 23.0.0
  118. */
  119. public const PROPERTY_BIOGRAPHY = 'biography';
  120. /**
  121. * @since 23.0.0
  122. */
  123. public const PROPERTY_PROFILE_ENABLED = 'profile_enabled';
  124. /**
  125. * The list of allowed properties
  126. *
  127. * @since 25.0.0
  128. */
  129. public const ALLOWED_PROPERTIES = [
  130. self::PROPERTY_AVATAR,
  131. self::PROPERTY_DISPLAYNAME,
  132. self::PROPERTY_PHONE,
  133. self::PROPERTY_EMAIL,
  134. self::PROPERTY_WEBSITE,
  135. self::PROPERTY_ADDRESS,
  136. self::PROPERTY_TWITTER,
  137. self::PROPERTY_FEDIVERSE,
  138. self::PROPERTY_ORGANISATION,
  139. self::PROPERTY_ROLE,
  140. self::PROPERTY_HEADLINE,
  141. self::PROPERTY_BIOGRAPHY,
  142. self::PROPERTY_PROFILE_ENABLED,
  143. ];
  144. public const COLLECTION_EMAIL = 'additional_mail';
  145. public const NOT_VERIFIED = '0';
  146. public const VERIFICATION_IN_PROGRESS = '1';
  147. public const VERIFIED = '2';
  148. /**
  149. * Get the account data for a given user
  150. *
  151. * @since 15.0.0
  152. *
  153. * @param IUser $user
  154. * @return IAccount
  155. */
  156. public function getAccount(IUser $user): IAccount;
  157. /**
  158. * Update the account data with for the user
  159. *
  160. * @since 21.0.1
  161. *
  162. * @param IAccount $account
  163. * @throws \InvalidArgumentException Message is the property that was invalid
  164. */
  165. public function updateAccount(IAccount $account): void;
  166. /**
  167. * Search for users based on account data
  168. *
  169. * @param string $property - property or property collection name – since
  170. * NC 22 the implementation MAY add a fitting property collection into the
  171. * search even if a property name was given e.g. email property and email
  172. * collection)
  173. * @param string[] $values
  174. * @return array
  175. *
  176. * @since 21.0.0
  177. */
  178. public function searchUsers(string $property, array $values): array;
  179. }