summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-02-09 17:06:24 +0100
committerVincent Petry <pvince81@owncloud.com>2015-02-09 17:06:24 +0100
commit5d8f1a1de3f542a94501c45c500fde2f5fa997c4 (patch)
treed528e67ca281443d1324011cd3a97d21eedfbc5c
parentdc475ab3e0fad65208e64fd53b7bfbb275a97c3a (diff)
parentc644ed89a77387b7430e192b45fd5226703b8b3c (diff)
downloadnextcloud-server-5d8f1a1de3f542a94501c45c500fde2f5fa997c4.tar.gz
nextcloud-server-5d8f1a1de3f542a94501c45c500fde2f5fa997c4.zip
Merge pull request #13854 from owncloud/avatar-exists
Add a better way to check if an avatar exists for the user
-rw-r--r--lib/private/avatar.php9
-rw-r--r--lib/private/helper.php7
-rw-r--r--lib/public/iavatar.php7
3 files changed, 17 insertions, 6 deletions
diff --git a/lib/private/avatar.php b/lib/private/avatar.php
index a9d9346d50a..5e234d77bb2 100644
--- a/lib/private/avatar.php
+++ b/lib/private/avatar.php
@@ -43,6 +43,15 @@ class OC_Avatar implements \OCP\IAvatar {
}
/**
+ * Check if an avatar exists for the user
+ *
+ * @return bool
+ */
+ public function exists() {
+ return $this->view->file_exists('avatar.jpg') || $this->view->file_exists('avatar.png');
+ }
+
+ /**
* sets the users avatar
* @param \OC_Image|resource|string $data OC_Image, imagedata or path to set a new avatar
* @throws Exception if the provided file is not a jpg or png image
diff --git a/lib/private/helper.php b/lib/private/helper.php
index c87eb63b662..887c3f33402 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -289,12 +289,7 @@ class OC_Helper {
**/
public static function userAvatarSet($user) {
$avatar = new \OC_Avatar($user);
- $image = $avatar->get(1);
- if ($image instanceof \OC_Image) {
- return true;
- } else {
- return false;
- }
+ return $avatar->exists();
}
/**
diff --git a/lib/public/iavatar.php b/lib/public/iavatar.php
index 213d2e6cef5..fdb044f9e5c 100644
--- a/lib/public/iavatar.php
+++ b/lib/public/iavatar.php
@@ -21,6 +21,13 @@ interface IAvatar {
function get($size = 64);
/**
+ * Check if an avatar exists for the user
+ *
+ * @return bool
+ */
+ public function exists();
+
+ /**
* sets the users avatar
* @param Image $data mixed imagedata or path to set a new avatar
* @throws \Exception if the provided file is not a jpg or png image