IUser.php 6.6 KB

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