From 4a08f7d710ced1c564e05471e1f873ecfb9ca161 Mon Sep 17 00:00:00 2001 From: kondou Date: Fri, 26 Jul 2013 12:20:11 +0200 Subject: Add basic avatars and gravatar --- lib/avatar.php | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/avatar.php (limited to 'lib/avatar.php') diff --git a/lib/avatar.php b/lib/avatar.php new file mode 100644 index 00000000000..2b087c48b65 --- /dev/null +++ b/lib/avatar.php @@ -0,0 +1,59 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +class OC_Avatar { + /** + * @brief gets the users avatar + * @param $user string username + * @param $size integer size in px of the avatar, defaults to 64 + * @return mixed link to the avatar, false if avatars are disabled + */ + public static function get ($user, $size = 64) { + $mode = OC_Config::getValue("avatar", "local"); + if ($mode === "none") { + // avatars are disabled + return false; + } elseif ($mode === "gravatar") { + $email = OC_Preferences::getValue($user, 'settings', 'email'); + if ($email !== null) { + $emailhash = md5(strtolower(trim($email))); + $url = "http://www.gravatar.com/avatar/".$emailhash."?s=".$size; + return $url; + } else { + return \OC_Avatar::getDefaultAvatar($size); + } + } elseif ($mode === "local") { + if (false) { + // + } else { + return \OC_Avatar::getDefaultAvatar($size); + } + } + } + + + /** + * @brief sets the users local avatar + * @param $user string user to set the avatar for + * @param $path string path where the avatar is + * @return true on success + */ + public static function setLocalAvatar ($user, $path) { + if (OC_Config::getValue("avatar", "local") === "local") { + // + } + } + + /** + * @brief gets the default avatar + * @return link to the default avatar + */ + public static function getDefaultAvatar ($size) { + return OC_Helper::imagePath("core", "defaultavatar.png"); + } +} -- cgit v1.2.3