IUser.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP;
  8. use InvalidArgumentException;
  9. /**
  10. * Interface IUser
  11. *
  12. * @since 8.0.0
  13. */
  14. interface IUser {
  15. /**
  16. * get the user id
  17. *
  18. * @return string
  19. * @since 8.0.0
  20. */
  21. public function getUID();
  22. /**
  23. * get the display name for the user, if no specific display name is set it will fallback to the user id
  24. *
  25. * @return string
  26. * @since 8.0.0
  27. */
  28. public function getDisplayName();
  29. /**
  30. * set the display name for the user
  31. *
  32. * @param string $displayName
  33. * @return bool
  34. * @since 8.0.0
  35. *
  36. * @since 25.0.0 Throw InvalidArgumentException
  37. * @throws \InvalidArgumentException
  38. */
  39. public function setDisplayName($displayName);
  40. /**
  41. * returns the timestamp of the user's last login or 0 if the user did never
  42. * login
  43. *
  44. * @return int
  45. * @since 8.0.0
  46. */
  47. public function getLastLogin();
  48. /**
  49. * updates the timestamp of the most recent login of this user
  50. * @since 8.0.0
  51. */
  52. public function updateLastLoginTimestamp();
  53. /**
  54. * Delete the user
  55. *
  56. * @return bool
  57. * @since 8.0.0
  58. */
  59. public function delete();
  60. /**
  61. * Set the password of the user
  62. *
  63. * @param string $password
  64. * @param string $recoveryPassword for the encryption app to reset encryption keys
  65. * @return bool
  66. * @since 8.0.0
  67. */
  68. public function setPassword($password, $recoveryPassword = null);
  69. /**
  70. * get the users home folder to mount
  71. *
  72. * @return string
  73. * @since 8.0.0
  74. */
  75. public function getHome();
  76. /**
  77. * Get the name of the backend class the user is connected with
  78. *
  79. * @return string
  80. * @since 8.0.0
  81. */
  82. public function getBackendClassName();
  83. /**
  84. * Get the backend for the current user object
  85. * @return ?UserInterface
  86. * @since 15.0.0
  87. */
  88. public function getBackend();
  89. /**
  90. * check if the backend allows the user to change his avatar on Personal page
  91. *
  92. * @return bool
  93. * @since 8.0.0
  94. */
  95. public function canChangeAvatar();
  96. /**
  97. * check if the backend supports changing passwords
  98. *
  99. * @return bool
  100. * @since 8.0.0
  101. */
  102. public function canChangePassword();
  103. /**
  104. * check if the backend supports changing display names
  105. *
  106. * @return bool
  107. * @since 8.0.0
  108. */
  109. public function canChangeDisplayName();
  110. /**
  111. * check if the user is enabled
  112. *
  113. * @return bool
  114. * @since 8.0.0
  115. */
  116. public function isEnabled();
  117. /**
  118. * set the enabled status for the user
  119. *
  120. * @param bool $enabled
  121. * @since 8.0.0
  122. */
  123. public function setEnabled(bool $enabled = true);
  124. /**
  125. * get the user's email address
  126. *
  127. * @return string|null
  128. * @since 9.0.0
  129. */
  130. public function getEMailAddress();
  131. /**
  132. * get the user's system email address
  133. *
  134. * The system mail address may be read only and may be set from different
  135. * sources like LDAP, SAML or simply the admin.
  136. *
  137. * Use this getter only when the system address is needed. For picking the
  138. * proper address to e.g. send a mail to, use getEMailAddress().
  139. *
  140. * @return string|null
  141. * @since 23.0.0
  142. */
  143. public function getSystemEMailAddress(): ?string;
  144. /**
  145. * get the user's preferred email address
  146. *
  147. * The primary mail address may be set be the user to specify a different
  148. * email address where mails by Nextcloud are sent to. It is not necessarily
  149. * set.
  150. *
  151. * Use this getter only when the primary address is needed. For picking the
  152. * proper address to e.g. send a mail to, use getEMailAddress().
  153. *
  154. * @return string|null
  155. * @since 23.0.0
  156. */
  157. public function getPrimaryEMailAddress(): ?string;
  158. /**
  159. * get the avatar image if it exists
  160. *
  161. * @param int $size
  162. * @return IImage|null
  163. * @since 9.0.0
  164. */
  165. public function getAvatarImage($size);
  166. /**
  167. * get the federation cloud id
  168. *
  169. * @return string
  170. * @since 9.0.0
  171. */
  172. public function getCloudId();
  173. /**
  174. * set the email address of the user
  175. *
  176. * It is an alias to setSystemEMailAddress()
  177. *
  178. * @param string|null $mailAddress
  179. * @return void
  180. * @since 9.0.0
  181. * @deprecated 23.0.0 use setSystemEMailAddress() or setPrimaryEMailAddress()
  182. */
  183. public function setEMailAddress($mailAddress);
  184. /**
  185. * Set the system email address of the user
  186. *
  187. * This is supposed to be used when the email is set from different sources
  188. * (i.e. other user backends, admin).
  189. *
  190. * @since 23.0.0
  191. */
  192. public function setSystemEMailAddress(string $mailAddress): void;
  193. /**
  194. * Set the primary email address of the user.
  195. *
  196. * This method should be typically called when the user is changing their
  197. * own primary address and is not allowed to change their system email.
  198. *
  199. * The mail address provided here must be already registered as an
  200. * additional mail in the user account and also be verified locally. Also
  201. * an empty string is allowed to delete this preference.
  202. *
  203. * @throws InvalidArgumentException when the provided email address does not
  204. * satisfy constraints.
  205. *
  206. * @since 23.0.0
  207. */
  208. public function setPrimaryEMailAddress(string $mailAddress): void;
  209. /**
  210. * get the users' quota in human readable form. If a specific quota is not
  211. * set for the user, the default value is returned. If a default setting
  212. * was not set otherwise, it is return as 'none', i.e. quota is not limited.
  213. *
  214. * @return string
  215. * @since 9.0.0
  216. */
  217. public function getQuota();
  218. /**
  219. * set the users' quota
  220. *
  221. * @param string $quota
  222. * @return void
  223. * @since 9.0.0
  224. */
  225. public function setQuota($quota);
  226. /**
  227. * Get the user's manager UIDs
  228. *
  229. * @since 27.0.0
  230. * @return string[]
  231. */
  232. public function getManagerUids(): array;
  233. /**
  234. * Set the user's manager UIDs
  235. *
  236. * @param string[] $uids UIDs of all managers
  237. * @return void
  238. * @since 27.0.0
  239. */
  240. public function setManagerUids(array $uids): void;
  241. }