summaryrefslogtreecommitdiffstats
path: root/lib/avatar.php
diff options
context:
space:
mode:
authorkondou <kondou@ts.unde.re>2013-07-26 12:20:11 +0200
committerkondou <kondou@ts.unde.re>2013-08-25 21:02:43 +0200
commit4a08f7d710ced1c564e05471e1f873ecfb9ca161 (patch)
tree3286d872ac9ad55d037e897a3da5e7425c6ca52b /lib/avatar.php
parentb8965c6107a908db705fde55e0606998ccbf02e4 (diff)
downloadnextcloud-server-4a08f7d710ced1c564e05471e1f873ecfb9ca161.tar.gz
nextcloud-server-4a08f7d710ced1c564e05471e1f873ecfb9ca161.zip
Add basic avatars and gravatar
Diffstat (limited to 'lib/avatar.php')
-rw-r--r--lib/avatar.php59
1 files changed, 59 insertions, 0 deletions
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 @@
+<?php
+/**
+ * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
+ * 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");
+ }
+}