diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-02-03 14:54:06 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-02-03 14:54:06 +0100 |
commit | c644ed89a77387b7430e192b45fd5226703b8b3c (patch) | |
tree | 7a468faa1ba70806f59df2fc8daffdfc2972555e /lib | |
parent | 9e222ec841946d773514f790fcc567c634d27038 (diff) | |
download | nextcloud-server-c644ed89a77387b7430e192b45fd5226703b8b3c.tar.gz nextcloud-server-c644ed89a77387b7430e192b45fd5226703b8b3c.zip |
Add a better way to check if an avatar exists for the user
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/avatar.php | 9 | ||||
-rw-r--r-- | lib/private/helper.php | 7 | ||||
-rw-r--r-- | lib/public/iavatar.php | 7 |
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 6268bd3d42e..238eab502ad 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -288,12 +288,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 |