Browse Source

Add a better way to check if an avatar exists for the user

tags/v8.1.0alpha1
Robin Appelman 9 years ago
parent
commit
c644ed89a7
3 changed files with 17 additions and 6 deletions
  1. 9
    0
      lib/private/avatar.php
  2. 1
    6
      lib/private/helper.php
  3. 7
    0
      lib/public/iavatar.php

+ 9
- 0
lib/private/avatar.php View 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

+ 1
- 6
lib/private/helper.php View 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();
}

/**

+ 7
- 0
lib/public/iavatar.php View 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

Loading…
Cancel
Save