You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IAvatar.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP;
  28. use OCP\Files\File;
  29. use OCP\Files\NotFoundException;
  30. /**
  31. * This class provides avatar functionality
  32. * @since 6.0.0
  33. */
  34. interface IAvatar {
  35. /**
  36. * get the users avatar
  37. * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image
  38. * @return boolean|\OCP\IImage containing the avatar or false if there's no image
  39. * @since 6.0.0 - size of -1 was added in 9.0.0
  40. */
  41. public function get($size = 64);
  42. /**
  43. * Check if an avatar exists for the user
  44. *
  45. * @return bool
  46. * @since 8.1.0
  47. */
  48. public function exists();
  49. /**
  50. * Check if the avatar of a user is a custom uploaded one
  51. *
  52. * @return bool
  53. * @since 14.0.0
  54. */
  55. public function isCustomAvatar(): bool;
  56. /**
  57. * sets the users avatar
  58. * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar
  59. * @throws \Exception if the provided file is not a jpg or png image
  60. * @throws \Exception if the provided image is not valid
  61. * @throws \OC\NotSquareException if the image is not square
  62. * @return void
  63. * @since 6.0.0
  64. */
  65. public function set($data);
  66. /**
  67. * remove the users avatar
  68. * @return void
  69. * @since 6.0.0
  70. */
  71. public function remove();
  72. /**
  73. * Get the file of the avatar
  74. * @param int $size -1 can be used to not scale the image
  75. * @return File
  76. * @throws NotFoundException
  77. * @since 9.0.0
  78. */
  79. public function getFile($size);
  80. /**
  81. * @param string $text
  82. * @return Color Object containting r g b int in the range [0, 255]
  83. * @since 14.0.0
  84. */
  85. public function avatarBackgroundColor(string $text);
  86. /**
  87. * Handle a changed user
  88. * @since 13.0.0
  89. */
  90. public function userChanged($feature, $oldValue, $newValue);
  91. }