2013-11-21 18:43:23 -05:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2013-11-21 18:43:23 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2013-11-21 18:43:23 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCP;
|
2018-05-07 02:48:38 -04:00
|
|
|
|
2015-12-16 14:26:00 -05:00
|
|
|
use OCP\Files\NotFoundException;
|
2022-03-02 23:41:34 -05:00
|
|
|
use OCP\Files\SimpleFS\ISimpleFile;
|
2013-11-21 18:43:23 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class provides avatar functionality
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-11-21 18:43:23 -05:00
|
|
|
*/
|
|
|
|
|
interface IAvatar {
|
2018-06-13 16:07:40 -04:00
|
|
|
/**
|
2022-06-22 06:05:26 -04:00
|
|
|
* Get the users avatar
|
|
|
|
|
*
|
2018-06-13 16:07:40 -04:00
|
|
|
* @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image
|
2022-08-30 07:27:21 -04:00
|
|
|
* @param bool $darkTheme Should the generated avatar be dark themed
|
2022-05-13 06:59:51 -04:00
|
|
|
* @return false|\OCP\IImage containing the avatar or false if there's no image
|
2018-06-13 16:07:40 -04:00
|
|
|
* @since 6.0.0 - size of -1 was added in 9.0.0
|
|
|
|
|
*/
|
2022-08-30 07:27:21 -04:00
|
|
|
public function get(int $size = 64, bool $darkTheme = false);
|
2013-11-21 18:43:23 -05:00
|
|
|
|
2018-06-13 16:07:40 -04:00
|
|
|
/**
|
|
|
|
|
* Check if an avatar exists for the user
|
|
|
|
|
*
|
|
|
|
|
* @since 8.1.0
|
|
|
|
|
*/
|
2022-06-22 06:05:26 -04:00
|
|
|
public function exists(): bool;
|
2015-02-03 08:54:06 -05:00
|
|
|
|
2018-08-01 04:56:22 -04:00
|
|
|
/**
|
|
|
|
|
* Check if the avatar of a user is a custom uploaded one
|
|
|
|
|
*
|
|
|
|
|
* @since 14.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function isCustomAvatar(): bool;
|
|
|
|
|
|
2018-06-13 16:07:40 -04:00
|
|
|
/**
|
2022-06-22 06:05:26 -04:00
|
|
|
* Sets the users avatar
|
|
|
|
|
*
|
2018-06-13 16:07:40 -04:00
|
|
|
* @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar
|
|
|
|
|
* @throws \Exception if the provided file is not a jpg or png image
|
|
|
|
|
* @throws \Exception if the provided image is not valid
|
|
|
|
|
* @throws \OC\NotSquareException if the image is not square
|
|
|
|
|
* @since 6.0.0
|
|
|
|
|
*/
|
2022-06-22 06:05:26 -04:00
|
|
|
public function set($data): void;
|
2013-11-21 18:43:23 -05:00
|
|
|
|
2018-06-13 16:07:40 -04:00
|
|
|
/**
|
2022-06-22 06:05:26 -04:00
|
|
|
* Remove the user's avatar
|
|
|
|
|
*
|
|
|
|
|
* @param bool $silent Whether removing the avatar should trigger a change
|
2018-06-13 16:07:40 -04:00
|
|
|
* @since 6.0.0
|
|
|
|
|
*/
|
2022-06-22 06:05:26 -04:00
|
|
|
public function remove(bool $silent = false): void;
|
2015-12-16 14:26:00 -05:00
|
|
|
|
2018-06-13 16:07:40 -04:00
|
|
|
/**
|
|
|
|
|
* Get the file of the avatar
|
2022-06-22 06:05:26 -04:00
|
|
|
*
|
|
|
|
|
* @param int $size The desired image size. -1 can be used to not scale the image
|
2022-08-30 07:27:21 -04:00
|
|
|
* @param bool $darkTheme Should the generated avatar be dark themed
|
2018-06-13 16:07:40 -04:00
|
|
|
* @throws NotFoundException
|
|
|
|
|
* @since 9.0.0
|
|
|
|
|
*/
|
2022-08-30 07:27:21 -04:00
|
|
|
public function getFile(int $size, bool $darkTheme = false): ISimpleFile;
|
2018-05-07 02:48:38 -04:00
|
|
|
|
2017-12-13 14:21:00 -05:00
|
|
|
/**
|
2022-06-22 06:05:26 -04:00
|
|
|
* Get the avatar background color
|
|
|
|
|
*
|
2018-06-13 16:07:40 -04:00
|
|
|
* @since 14.0.0
|
2017-12-13 14:21:00 -05:00
|
|
|
*/
|
2022-06-23 05:42:14 -04:00
|
|
|
public function avatarBackgroundColor(string $hash): Color;
|
2018-05-07 02:48:38 -04:00
|
|
|
|
2018-06-13 16:07:40 -04:00
|
|
|
/**
|
2022-06-22 06:05:26 -04:00
|
|
|
* Updates the display name if changed.
|
|
|
|
|
*
|
|
|
|
|
* @param string $feature The changed feature
|
|
|
|
|
* @param mixed $oldValue The previous value
|
|
|
|
|
* @param mixed $newValue The new value
|
2018-06-13 16:07:40 -04:00
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
2022-06-22 06:05:26 -04:00
|
|
|
public function userChanged(string $feature, $oldValue, $newValue): void;
|
2013-11-21 18:43:23 -05:00
|
|
|
}
|