1
0

IAccountManager.php 4.7 KB

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