aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkondou <kondou@ts.unde.re>2013-08-17 11:01:47 +0200
committerkondou <kondou@ts.unde.re>2013-08-25 21:05:40 +0200
commit9c12da6a94578002aef016d7196a78acf2623eb7 (patch)
tree603c0a43ba7374eb8951272d879edc8df0774f55
parentd7e6c77e208f561f994ce7b9f2274fb30b75049f (diff)
downloadnextcloud-server-9c12da6a94578002aef016d7196a78acf2623eb7.tar.gz
nextcloud-server-9c12da6a94578002aef016d7196a78acf2623eb7.zip
Several improvements
- Don't use gravatars default avatars - Use "profile image" instead of "avatar" - Use <p> instead of tables - Ease updateAvatar() - Actually return something in \OCP\Avatar
-rw-r--r--avatar.php4
-rw-r--r--lib/avatar.php15
-rw-r--r--lib/public/avatar.php4
-rw-r--r--settings/js/personal.js2
-rw-r--r--settings/templates/admin.php56
-rw-r--r--settings/templates/personal.php14
-rw-r--r--settings/templates/users.php2
7 files changed, 49 insertions, 48 deletions
diff --git a/avatar.php b/avatar.php
index 1134dc2e710..17417a470eb 100644
--- a/avatar.php
+++ b/avatar.php
@@ -1,5 +1,9 @@
<?php
+/**
+ * * @todo work on hashing userstrings, so one can't guess usernames
+ */
+
require_once 'lib/base.php';
$mode = \OC_Avatar::getMode();
diff --git a/lib/avatar.php b/lib/avatar.php
index 49c82709154..f503d01304d 100644
--- a/lib/avatar.php
+++ b/lib/avatar.php
@@ -86,16 +86,19 @@ class OC_Avatar {
* @param $user string which user to get the gravatar for
* @param size integer size in px of the avatar, defaults to 64
* @return string link to the gravatar, or \OC_Image with the default avatar
+ * @todo work on hashing userstrings, so one can't guess usernames
*/
public static function getGravatar ($user, $size = 64) {
$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 self::getDefaultAvatar($size);
+ $url = "http://secure.gravatar.com/avatar/".$emailhash."?d=404&s=".$size;
+ $headers = get_headers($url, 1);
+ if (strpos($headers[0], "404 Not Found") === false) {
+ return $url;
+ }
}
+ return self::getDefaultAvatar($size);
}
/**
@@ -121,7 +124,7 @@ class OC_Avatar {
}
/**
- *
+ * @todo todo
*/
public static function getCustomAvatar($user, $size) {
// TODO
@@ -129,8 +132,10 @@ class OC_Avatar {
/**
* @brief gets the default avatar
+ * @todo when custom default images arive @param $user string which user to get the avatar for
* @param $size integer size of the avatar in px, defaults to 64
* @return \OC_Image containing the default avatar
+ * @todo use custom default images, when they arive
*/
public static function getDefaultAvatar ($size = 64) {
$default = new OC_Image(OC::$SERVERROOT."/core/img/defaultavatar.png");
diff --git a/lib/public/avatar.php b/lib/public/avatar.php
index 5d432f07cce..768d292346f 100644
--- a/lib/public/avatar.php
+++ b/lib/public/avatar.php
@@ -10,10 +10,10 @@ namespace OCP;
class Avatar {
public static function get ($user, $size = 64) {
- \OC_Avatar::get($user, $size);
+ return \OC_Avatar::get($user, $size);
}
public static function getMode () {
- \OC_Avatar::getMode();
+ return \OC_Avatar::getMode();
}
}
diff --git a/settings/js/personal.js b/settings/js/personal.js
index 8336e9c8362..74ea7f26ebf 100644
--- a/settings/js/personal.js
+++ b/settings/js/personal.js
@@ -55,7 +55,7 @@ function selectAvatar (path) {
}
function updateAvatar () {
- $('#avatar img').attr('src', OC.filePath('', '', 'avatar.php?user='+OC.currentUser+'&size=128'));
+ $('#avatar img').attr('src', $('#avatar img').attr('src') + '#');
}
$(document).ready(function(){
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index f7d6a576d9e..64c1b1112ce 100644
--- a/settings/templates/admin.php
+++ b/settings/templates/admin.php
@@ -117,38 +117,30 @@ if (!$_['internetconnectionworking']) {
</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") { p('checked'); } ?>
- <?php if (!$_['internetconnectionworking']) { p('disabled'); } ?>>
- <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>
- <?php if (!$_['internetconnectionworking']): ?>
- <br><em><?php p($l->t('Gravatar needs an internet connection!')); ?></em>
- <?php endif; ?>
- </td>
- </tr>
- <tr>
- <td>
- <input type="radio" name="avatarmode" value="local" id="avatar_local"
- <?php if ($_['avatar'] === "local") { p('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") { p('checked'); } ?>>
- <label for="avatar_none"><?php p($l->t('No avatars')); ?></label><br>
- <em><?php p($l->t('Do not provide avatars')); ?></em>
- </td>
- </tr>
- </table>
+ <legend><strong><?php p($l->t('Profile images')); ?></strong></legend>
+ <p>
+ <input type="radio" name="avatarmode" value="gravatar" id="avatar_gravatar"
+ <?php if ($_['avatar'] === "gravatar") { p('checked'); } ?>
+ <?php if (!$_['internetconnectionworking']) { p('disabled'); } ?>>
+ <label for="avatar_gravatar">Gravatar</label><br>
+ <em><?php print_unescaped($l->t('Use <a href="http://gravatar.com/">gravatar</a> for profile images')); ?></em><br>
+ <em><?php p($l->t('This sends data to gravatar and may slow down loading')); ?></em>
+ <?php if (!$_['internetconnectionworking']): ?>
+ <br><em><?php p($l->t('Gravatar needs an internet connection!')); ?></em>
+ <?php endif; ?>
+ </p>
+ <p>
+ <input type="radio" name="avatarmode" value="local" id="avatar_local"
+ <?php if ($_['avatar'] === "local") { p('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>
+ </p>
+ <p>
+ <input type="radio" name="avatarmode" value="none" id="avatar_none"
+ <?php if ($_['avatar'] === "none") { p('checked'); } ?>>
+ <label for="avatar_none"><?php p($l->t('No avatars')); ?></label><br>
+ <em><?php p($l->t('Do not provide avatars')); ?></em>
+ </p>
</fieldset>
<fieldset class="personalblock" id="shareAPI">
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index 93aaa5ac1e7..e047ff9dcc9 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -86,18 +86,18 @@ if($_['passwordChangeSupported']) {
<?php if ($_['avatar'] !== "none"): ?>
<form id="avatar" method="post" action="<?php p(\OC_Helper::linkToRoute('settings_ajax_newavatar')); ?>">
<fieldset class="personalblock">
- <legend><strong><?php p($l->t('Avatar')); ?></strong></legend>
+ <legend><strong><?php p($l->t('Profile Image')); ?></strong></legend>
<img src="<?php print_unescaped(link_to('', 'avatar.php').'?user='.OC_User::getUser().'&size=128'); ?>"><br>
<?php if ($_['avatar'] === "local"): ?>
- <em><?php p($l->t('Your avatar has to be a square and either a PNG or JPG image')); ?></em><br>
- <div class="inlineblock button" id="uploadavatarbutton"><?php p($l->t('Upload a new avatar')); ?></div>
+ <em><?php p($l->t('Your profile image has to be a square and either a PNG or JPG image')); ?></em><br>
+ <div class="inlineblock button" id="uploadavatarbutton"><?php p($l->t('Upload a new image')); ?></div>
<input type="file" class="hidden" name="files[]" id="uploadavatar">
- <div class="inlineblock button" id="selectavatar"><?php p($l->t('Select a new avatar from your files')); ?></div>
- <div class="inlineblock button" id="removeavatar"><?php p($l->t('Remove my avatar')); ?></div>
+ <div class="inlineblock button" id="selectavatar"><?php p($l->t('Select a new image from your files')); ?></div>
+ <div class="inlineblock button" id="removeavatar"><?php p($l->t('Remove my image')); ?></div>
<?php elseif ($_['avatar'] === "gravatar"): ?>
- <em><?php p($l->t('Your avatar is provided by gravatar, which is based on your Email.')); ?></em>
+ <em><?php p($l->t('Your profile image is provided by gravatar, which is based on your Email.')); ?></em>
<?php else: ?>
- <em><?php p($l->t('Your avatar is provided by a custom service, ask your administrator, on how to change your avatar.')); ?></em>
+ <em><?php p($l->t('Your profile image is provided by a custom service, ask your administrator, on how to change your image.')); ?></em>
<?php endif; ?>
</fieldset>
</form>
diff --git a/settings/templates/users.php b/settings/templates/users.php
index 32840233d14..78bdbcd8c43 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -82,7 +82,7 @@ $_['subadmingroups'] = array_flip($items);
<thead>
<tr>
<?php if(\OC_Avatar::getMode() !== "none"): ?>
- <th id='headerAvatar'><?php p($l->t('Avatar')); ?></th>
+ <th id='headerAvatar'></th>
<?php endif; ?>
<th id='headerName'><?php p($l->t('Username'))?></th>
<th id="headerDisplayName"><?php p($l->t( 'Display Name' )); ?></th>