1
0

IAvatar.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. * @author John Molakvoæ <skjnldsv@protonmail.com>
  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 OCP\Files\File;
  30. use OCP\Files\NotFoundException;
  31. /**
  32. * This class provides avatar functionality
  33. * @since 6.0.0
  34. */
  35. interface IAvatar {
  36. /**
  37. * get the users avatar
  38. * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image
  39. * @return boolean|\OCP\IImage containing the avatar or false if there's no image
  40. * @since 6.0.0 - size of -1 was added in 9.0.0
  41. */
  42. public function get($size = 64);
  43. /**
  44. * Check if an avatar exists for the user
  45. *
  46. * @return bool
  47. * @since 8.1.0
  48. */
  49. public function exists();
  50. /**
  51. * Check if the avatar of a user is a custom uploaded one
  52. *
  53. * @return bool
  54. * @since 14.0.0
  55. */
  56. public function isCustomAvatar(): bool;
  57. /**
  58. * sets the users avatar
  59. * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar
  60. * @throws \Exception if the provided file is not a jpg or png image
  61. * @throws \Exception if the provided image is not valid
  62. * @throws \OC\NotSquareException if the image is not square
  63. * @return void
  64. * @since 6.0.0
  65. */
  66. public function set($data);
  67. /**
  68. * remove the users avatar
  69. * @return void
  70. * @since 6.0.0
  71. */
  72. public function remove();
  73. /**
  74. * Get the file of the avatar
  75. * @param int $size -1 can be used to not scale the image
  76. * @return File
  77. * @throws NotFoundException
  78. * @since 9.0.0
  79. */
  80. public function getFile($size);
  81. /**
  82. * @param string $text
  83. * @return Color Object containting r g b int in the range [0, 255]
  84. * @since 14.0.0
  85. */
  86. public function avatarBackgroundColor(string $text);
  87. /**
  88. * Handle a changed user
  89. * @since 13.0.0
  90. */
  91. public function userChanged($feature, $oldValue, $newValue);
  92. }