From decd1961627986db094de4bf9b83589b9ccdb41e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 1 Aug 2018 10:56:22 +0200 Subject: Make the info available if the avatar was uploaded or generated Signed-off-by: Joas Schilling --- lib/private/Avatar.php | 11 ++++++++++- lib/public/IAvatar.php | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php index 9dbeb4ac745..116f8368e71 100644 --- a/lib/private/Avatar.php +++ b/lib/private/Avatar.php @@ -119,6 +119,15 @@ class Avatar implements IAvatar { return $this->folder->fileExists('avatar.jpg') || $this->folder->fileExists('avatar.png'); } + /** + * Check if the avatar of a user is a custom uploaded one + * + * @return bool + */ + public function isCustomAvatar(): bool { + return !$this->folder->fileExists('generated'); + } + /** * sets the users avatar * @param IImage|resource|string $data An image object, imagedata or path to set a new avatar @@ -362,7 +371,7 @@ class Avatar implements IAvatar { * @param string $font font path * @param int $size font size * @param int $angle - * @return Array + * @return array */ protected function imageTTFCenter($image, string $text, string $font, int $size, $angle = 0): array { // Image width & height diff --git a/lib/public/IAvatar.php b/lib/public/IAvatar.php index 85863357069..448d5dfc02f 100644 --- a/lib/public/IAvatar.php +++ b/lib/public/IAvatar.php @@ -53,6 +53,14 @@ interface IAvatar { */ public function exists(); + /** + * Check if the avatar of a user is a custom uploaded one + * + * @return bool + * @since 14.0.0 + */ + public function isCustomAvatar(): bool; + /** * sets the users avatar * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar -- cgit v1.2.3