]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add a better way to check if an avatar exists for the user
authorRobin Appelman <icewind@owncloud.com>
Tue, 3 Feb 2015 13:54:06 +0000 (14:54 +0100)
committerRobin Appelman <icewind@owncloud.com>
Tue, 3 Feb 2015 13:54:06 +0000 (14:54 +0100)
lib/private/avatar.php
lib/private/helper.php
lib/public/iavatar.php

index a9d9346d50a10f115dd7d8cdb6f21de93d6eddf7..5e234d77bb2de1141f75ce4134511f25eaf25cb8 100644 (file)
@@ -42,6 +42,15 @@ class OC_Avatar implements \OCP\IAvatar {
                return $avatar;
        }
 
+       /**
+        * 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
index 6268bd3d42ec7c00648081a5f1a6ea25a6f7df61..238eab502ad88313dd2e471eacd36f585568fb89 100644 (file)
@@ -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();
        }
 
        /**
index 213d2e6cef5f75031827c4a8fe34eb2fdca8a086..fdb044f9e5c4d330f49fd70fef9e2f717ce60d13 100644 (file)
@@ -20,6 +20,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