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
This commit is contained in:
parent
d7e6c77e20
commit
9c12da6a94
7 changed files with 49 additions and 48 deletions
|
@ -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();
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue