From 4a08f7d710ced1c564e05471e1f873ecfb9ca161 Mon Sep 17 00:00:00 2001
From: kondou <kondou@ts.unde.re>
Date: Fri, 26 Jul 2013 12:20:11 +0200
Subject: [PATCH] Add basic avatars and gravatar

---
 config/config.sample.php        |   6 ++++
 core/img/defaultavatar.png      | Bin 0 -> 12444 bytes
 core/templates/layout.user.php  |   1 +
 lib/avatar.php                  |  59 ++++++++++++++++++++++++++++++++
 lib/public/avatar.php           |  15 ++++++++
 lib/templatelayout.php          |   5 +++
 settings/admin.php              |   1 +
 settings/ajax/setavatarmode.php |  12 +++++++
 settings/js/admin.js            |   6 ++++
 settings/personal.php           |   1 +
 settings/routes.php             |   2 ++
 settings/templates/admin.php    |  37 ++++++++++++++++++++
 settings/templates/personal.php |  13 +++++++
 13 files changed, 158 insertions(+)
 create mode 100644 core/img/defaultavatar.png
 create mode 100644 lib/avatar.php
 create mode 100644 lib/public/avatar.php
 create mode 100644 settings/ajax/setavatarmode.php

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 0000000000000000000000000000000000000000..e9572080bbf3fb403a8b07b11d9271546c89c78e
GIT binary patch
literal 12444
zcmeHt{XdlX_y4)Z7?PWGt5mE8?GjTeNin<KFcGOH6q#;SDnjW_bL}eH*wolW3EK_Z
zL{uxfb+wYF6m1*2MJY;YqL7&DdtR5``+k2u-ygnz!1q1-*y)<<dcDr;oaZ^``8uz2
z`FW0)n}OaiJpeF}xKE!8z{g8I=nC*3`3RdB{710V!)-dS<iE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bCXPf8OA87d?+t3F`PE5)dGn
zq#Nt`aBhP$zexbN?FPtk_~FKh$rX;nkC=S@bJ>1=9FD^E*^#sH_J45Azt{dp4Y%j^
z0Q;IRkx&iajuWqM6;b9m?W?9_Hq(FmSjrqP=>OCl1v5F5x^&=z3!!`S>mvQ2T!1rI
zd+o@SCz3$A86L`m-5*taoQogKouThpN^E6D@%a$;K?iu7b^lTE$`%m?(=R$wsC@E!
zLT<##K|qPK>^Whrt9WqJLBGV83)~BioSkUDyoDrFod9Qufj0b%7Y!dMF<y%`Xf*bj
z5!S1R0iHkMbS)R@%l#;Lj^u^edJEGDA;p+f%TQU=7$<txBFp;p#^k4mxQBDfyOKbP
zuLY#LovkE3pOYuz(cTo8-$bDcvFH#3CSeCAVbia^I6CeHOLJiMV`}AyGJ4FM#s?J4
zH7HSE8U*ICwJa7{JF#|xah!fcLRTZ68AIjNp!Zoy=1NW?-U7)Cuj!|Mkp1+30ByMs
A-v9sr

literal 0
HcmV?d00001

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 @@
 			<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
 			<ul id="settings" class="svg">
 				<span id="expand" tabindex="0" role="link">
+					<?php if (isset($_['avatar'])) { print_unescaped($_['avatar']); } ?>
 					<span id="expandDisplayName"><?php  p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span>
 					<img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" />
 				</span>
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 @@
+<?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");
+	}
+}
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 @@
+<?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.
+ */
+
+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', '<img src="'.OC_Avatar::get(OC_User::getUser(), 32).'">');
+			}
+
 			// 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 @@
+<?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.
+ */
+
+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']) {
 	</p>
 </fieldset>
 
+<fieldset class="personalblock" id="avatar">
+	<legend><strong><?php p($l->t('Avatars')); ?></strong></legend>
+	<table class="nostyle">
+		<tr>
+			<td>
+				<input type="radio" name="avatarmode" value="gravatar"
+					id="avatar_gravatar" <?php if ($_['avatar'] === "gravatar") {
+						print_unescaped('checked="checked"');
+					} ?>>
+				<label for="avatar_gravatar">Gravatar</label><br>
+				<em><?php print_unescaped($l->t('Use <a href="http://gravatar.com/">gravatar</a> for avatars')); ?></em><br>
+				<em><?php p($l->t('This sends data to gravatar')); ?></em>
+			</td>
+		</tr>
+		<tr>
+			<td>
+				<input type="radio" name="avatarmode" value="local"
+					id="avatar_local" <?php if ($_['avatar'] === "local") {
+						print_unescaped('checked="checked"');
+					} ?>>
+				<label for="avatar_local"><?php p($l->t('Local avatars')); ?></label><br>
+				<em><?php p($l->t('Use local avatars, which each user has to upload themselves')); ?></em>
+			</td>
+		</tr>
+		<tr>
+			<td>
+				<input type="radio" name="avatarmode" value="none"
+					id="avatar_none" <?php if ($_['avatar'] === "none") {
+						print_unescaped('checked="checked"');
+					} ?>>
+				<label for="avatar_none"><?php p($l->t('No avatars')); ?></label><br>
+				<em><?php print_unescaped($l->t('Do not provide avatars')); ?></em>
+			</td>
+		</tr>
+	</table>
+</fieldset>
+
 <fieldset class="personalblock" id="shareAPI">
 	<legend><strong><?php p($l->t('Sharing'));?></strong></legend>
 	<table class="shareAPI nostyle">
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index bad88142da..55f626aa57 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -74,12 +74,25 @@ if($_['passwordChangeSupported']) {
 		<input type="text" name="email" id="email" value="<?php p($_['email']); ?>"
 			placeholder="<?php p($l->t('Your email address'));?>" /><span class="msg"></span><br />
 		<em><?php p($l->t('Fill in an email address to enable password recovery'));?></em>
+		<?php if($_['avatar'] === "gravatar") {
+			print_unescaped($l->t('<br><em>Your Email will be used for your gravatar<em>'));
+		} ?>
 	</fieldset>
 </form>
 <?php
 }
 ?>
 
+<?php if ($_['avatar'] === "local"): ?>
+<form id="avatar">
+	<fieldset class="personalblock">
+		<legend><strong><?php p($l->t('Avatar')); ?></strong></legend>
+		<img src="<?php print_unescaped(\OC_Avatar::get(\OC_User::getUser())); ?>"><br>
+		<button><?php p($l->t('Upload a new avatar')); ?></button>
+	</fieldset>
+</form>
+<?php endif; ?>
+
 <form>
 	<fieldset class="personalblock">
 		<legend><strong><?php p($l->t('Language'));?></strong></legend>
-- 
GitLab