diff --git a/config/config.sample.php b/config/config.sample.php
index 24ba541ac5..fb2271339b 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -65,6 +65,12 @@ $CONFIG = array(
/* URL to the parent directory of the 3rdparty directory, as seen by the browser */
"3rdpartyurl" => "",
+/* What avatars to use.
+ * May be "none" for none, "local" for uploaded avatars, or "gravatar" for gravatars.
+ * Default is "local".
+ */
+"avatars" => "local",
+
/* Default app to load on login */
"defaultapp" => "files",
diff --git a/core/img/defaultavatar.png b/core/img/defaultavatar.png
new file mode 100644
index 0000000000..e9572080bb
Binary files /dev/null and b/core/img/defaultavatar.png differ
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 3c1114492c..038264bd06 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -47,6 +47,7 @@
getLogoClaim()); ?>
+
diff --git a/lib/avatar.php b/lib/avatar.php
new file mode 100644
index 0000000000..2b087c48b6
--- /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");
+ }
+}
diff --git a/lib/public/avatar.php b/lib/public/avatar.php
new file mode 100644
index 0000000000..65356b8a71
--- /dev/null
+++ b/lib/public/avatar.php
@@ -0,0 +1,15 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP;
+
+class Avatar {
+ public static function get ($user, $size = 64) {
+ \OC_Avatar::get($user, $size);
+ }
+}
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 0024c9d496..06cbacb692 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -18,6 +18,11 @@ class OC_TemplateLayout extends OC_Template {
$this->assign('bodyid', 'body-user');
}
+ // display avatars if they are enabled
+ if (OC_Config::getValue('avatar') === 'gravatar' || OC_Config::getValue('avatar') === 'local') {
+ $this->assign('avatar', '');
+ }
+
// Update notification
if(OC_Config::getValue('updatechecker', true) === true) {
$data=OC_Updater::check();
diff --git a/settings/admin.php b/settings/admin.php
index 869729a9e4..394d6b55d7 100755
--- a/settings/admin.php
+++ b/settings/admin.php
@@ -30,6 +30,7 @@ $tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking());
$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes'));
+$tmpl->assign('avatar', OC_Config::getValue("avatar", "local"));
// Check if connected using HTTPS
if (OC_Request::serverProtocol() === 'https') {
diff --git a/settings/ajax/setavatarmode.php b/settings/ajax/setavatarmode.php
new file mode 100644
index 0000000000..f6f19f50cc
--- /dev/null
+++ b/settings/ajax/setavatarmode.php
@@ -0,0 +1,12 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+OC_Util::checkAdminUser();
+OCP\JSON::callCheck();
+
+OC_Config::setValue('avatar', $_POST['mode']);
diff --git a/settings/js/admin.js b/settings/js/admin.js
index f2d6f37a51..6fa1c768ea 100644
--- a/settings/js/admin.js
+++ b/settings/js/admin.js
@@ -14,6 +14,12 @@ $(document).ready(function(){
}
});
+ $('#avatar input').change(function(){
+ if ($(this).attr('checked')) {
+ $.post(OC.filePath('settings', 'ajax', 'setavatarmode.php'), {mode: $(this).val()});
+ }
+ });
+
$('#shareAPIEnabled').change(function() {
$('.shareAPI td:not(#enable)').toggle();
});
diff --git a/settings/personal.php b/settings/personal.php
index e69898f6f8..4bec21d58c 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -84,6 +84,7 @@ $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User:
$tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
$tmpl->assign('displayName', OC_User::getDisplayName());
$tmpl->assign('enableDecryptAll' , $enableDecryptAll);
+$tmpl->assign('avatar', OC_Config::getValue('avatar', 'local'));
$forms=OC_App::getForms('personal');
$tmpl->assign('forms', array());
diff --git a/settings/routes.php b/settings/routes.php
index 73ee70d1d5..9a27c3e439 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -70,3 +70,5 @@ $this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
->actionInclude('settings/ajax/setsecurity.php');
$this->create('isadmin', '/settings/js/isadmin.js')
->actionInclude('settings/js/isadmin.php');
+$this->create('settings_ajax_setavatarmode', '/settings/ajax/setavatarmode.php')
+ ->actionInclude('settings/ajax/setavatarmode.php');
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index e54586b80d..a166aec777 100644
--- a/settings/templates/admin.php
+++ b/settings/templates/admin.php
@@ -116,6 +116,43 @@ if (!$_['internetconnectionworking']) {
+
+