Commit 8a8358cf authored by Francois Marier's avatar Francois Marier Committed by Gerrit Code Review
Browse files

Merge "Fix remote avatars broken by 'profileiconbyid' commit (bug #924777)"

parents 40ab6d40 ab3b5a19
......@@ -200,7 +200,7 @@ $profileform = pieform(array(
function get_desired_fields(&$allfields, $desiredfields, $section) {
global $USER;
if ($section == 'about') {
$label = '<div id="profileicon"><a href="' . get_config('wwwroot') . 'artefact/file/profileicons.php"><img src="' . get_config('wwwroot') . 'thumb.php?type=profileiconbyid&maxsize=100&id=' . intval($USER->get('profileicon')) . '" alt=""></a></div>';
$label = '<div id="profileicon"><a href="' . get_config('wwwroot') . 'artefact/file/profileicons.php"><img src="' . profile_icon_url($USER, 100, 100) . '" alt=""></a></div>';
$descr = get_string('aboutdescription', 'artefact.internal');
}
else {
......
......@@ -3,7 +3,7 @@
{foreach from=$foruminfo item=postinfo}
<tr class="{cycle values='r0,r1'}">
<td><h4><a href="{$WWWROOT}interaction/forum/topic.php?id={$postinfo->topic|escape}#post{$postinfo->id}">{$postinfo->topicname}</a></h4><div class="s">{$postinfo->body|str_shorten_html:100:true|safe}</div></td>
<td class="valign s right"><a href="{$WWWROOT}user/view.php?id={$postinfo->poster}"><img src="{$WWWROOT}thumb.php?type=profileiconbyid&amp;maxsize=16&amp;id={$postinfo->author->profileicon}" alt=""> {$postinfo->author|display_name}</a>
<td class="valign s right"><a href="{$WWWROOT}user/view.php?id={$postinfo->poster}"><img src="{profile_icon_url user=$postinfo->author maxheight=16 maxwidth=16}" alt=""> {$postinfo->author|display_name}</a>
</td>
</tr>
{/foreach}
......
......@@ -8,7 +8,7 @@
{if $wallpost->deletable}
<a href="{$WWWROOT}blocktype/wall/deletepost.php?postid={$wallpost->postid}&return={if $wholewall}wall{else}profile{/if}" class="wallpostdelete">{str tag='delete' section='blocktype.wall'}</a>
{/if}
<div class="userinfo"><img src="{$WWWROOT}thumb.php?type=profileiconbyid&amp;maxwidth=25&amp;maxheight=25&amp;id={$wallpost->profileicon}" alt="Profile Picture"><a href="{$WWWROOT}user/view.php?id={$wallpost->userid}">{$wallpost->displayname}</a><span class="postedon"> - {$wallpost->postdate|format_date}</span></div>
<div class="userinfo"><img src="{profile_icon_url user=$wallpost maxheight=25 maxwidth=25}" alt="Profile Picture"><a href="{$WWWROOT}user/view.php?id={$wallpost->userid}">{$wallpost->displayname}</a><span class="postedon"> - {$wallpost->postdate|format_date}</span></div>
<div class="text">{$wallpost->text|parse_bbcode|safe}</div>
<div class="controls">
{* {if $ownwall}
......
......@@ -2384,7 +2384,6 @@ function profile_sideblock() {
'id' => $USER->get('id'),
'myname' => display_name($USER, null, true),
'username' => $USER->get('username'),
'profileicon' => $USER->get('profileicon') ? $USER->get('profileicon') : 0,
);
$authinstance = $SESSION->get('mnetuser') ? $SESSION->get('authinstance') : $USER->get('authinstance');
......@@ -2481,13 +2480,7 @@ function onlineusers_sideblock() {
$onlineusers = get_records_sql_array($sql, array(db_format_timestamp(time() - get_config('accessidletimeout'))), 0, $maxonlineusers);
if ($onlineusers) {
foreach ($onlineusers as &$user) {
if ($user->id == $USER->get('id')) {
// Use a shorter caching time for the current user, just in case they change their profile icon
$user->profileiconurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $user->profileicon . '&maxheight=20&maxwidth=20&earlyexpiry=1';
}
else {
$user->profileiconurl = profile_icon_url($user, 20, 20);
}
$user->profileiconurl = profile_icon_url($user, 20, 20);
// If the user is an MNET user, show where they've come from
$authobj = AuthFactory::create($user->authinstance);
......
......@@ -2208,8 +2208,10 @@ function profile_icon_url($user, $maxwidth=40, $maxheight=40) {
$user = get_record('usr', 'id', $user->id);
}
if ($maxwidth != $maxheight || ($maxwidth != 20 && $maxwidth != 40 && $maxwidth != 60)) {
log_warn('profile_icon_url should specify maxwidth, maxheight of 20x20, 40x40 or 60x60');
// Available sizes of the 'no_userphoto' image:
$allowedsizes = array(16, 20, 25, 40, 50, 60, 100);
if ($maxwidth != $maxheight || !in_array($maxwidth, $allowedsizes)) {
log_warn('profile_icon_url: maxwidth, maxheight should be equal and in (' . join(', ', $allowedsizes) . ')');
}
$thumb = get_config('wwwroot') . 'thumb.php';
......@@ -2221,7 +2223,8 @@ function profile_icon_url($user, $maxwidth=40, $maxheight=40) {
// Assume we have the right size available in docroot, so we don't
// have to call thumb.php
$notfound = $THEME->get_url('images/no_userphoto' . $maxwidth . '.png');
$notfoundwidth = $maxwidth == 100 ? '' : $maxwidth;
$notfound = $THEME->get_url('images/no_userphoto' . $notfoundwidth . '.png');
if (get_config('remoteavatars')) {
return remote_avatar($user->email, array('maxw' => $maxwidth, 'maxh' => $maxheight), $notfound);
......@@ -2357,13 +2360,7 @@ function get_onlineusers($limit=10, $offset=0, $orderby='firstname,lastname') {
$onlineusers = get_records_sql_array($sql, array($lastaccess), $offset, $limit);
if ($onlineusers) {
foreach ($onlineusers as &$user) {
if ($user->id == $USER->get('id')) {
// Use a shorter caching time for the current user, just in case they change their profile icon
$user->profileiconurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $user->profileicon . '&maxheight=20&maxwidth=20&earlyexpiry=1';
}
else {
$user->profileiconurl = profile_icon_url($user, 20, 20);
}
$user->profileiconurl = profile_icon_url($user, 20, 20);
// If the user is an MNET user, show where they've come from
$authobj = AuthFactory::create($user->authinstance);
......
......@@ -17,7 +17,7 @@
<table class="fullwidth" id="useraccountsettingsleft">
<tr><td class="center">
<div id="profilepict">
<a href="{$WWWROOT}user/view.php?id={$user->id}"><img src="{$WWWROOT}thumb.php?type=profileiconbyid&amp;maxwidth=100&amp;maxheight=100&amp;id={$user->profileicon}" alt=""></a>
<a href="{$WWWROOT}user/view.php?id={$user->id}"><img src="{profile_icon_url user=$user maxheight=100 maxwidth=100}" alt=""></a>
<div id="profilename"><a href="{$WWWROOT}user/view.php?id={$user->id}">{$user|display_name}</a></div>
</div>
{if $loginas}
......
......@@ -386,8 +386,7 @@ searchTable.rowfunction = function(rowdata, rownumber, globaldata) {
var identityNodes = [], profileIcon = null, roleSelector = null;
if (rowdata.type == 'user') {
iconid = rowdata.profileicon ? rowdata.profileicon : 0;
profileIcon = IMG({'src': config.wwwroot + 'thumb.php?type=profileiconbyid&maxwidth=20&maxheight=20&id=' + iconid});
profileIcon = IMG({'src': config.wwwroot + 'thumb.php?type=profileicon&maxwidth=20&maxheight=20&id=' + rowdata.id});
identityNodes.push(A({'href': config.wwwroot + 'user/view.php?id=' + rowdata.id, 'target': '_blank'}, rowdata.name));
}
else if (rowdata.type == 'group') {
......
<div class="sidebar-header">
<div id="user-profileicon">
<a href="{$WWWROOT}user/view.php?id={$sbdata.id}"><img src="{$WWWROOT}thumb.php?type=profileiconbyid&amp;maxwidth=50&amp;maxheight=50&amp;id={$sbdata.profileicon}&amp;earlyexpiry=1" alt=""></a>
<a href="{$WWWROOT}user/view.php?id={$sbdata.id}"><img src="{profile_icon_url user=$sbdata.id maxheight=50 maxwidth=50}" alt=""></a>
</div>
<h3><a href="{$WWWROOT}user/view.php?id={$sbdata.id}">{$sbdata.myname}</a></h3>
</div>
......
<div>
<div class="fl">
<img src="{$WWWROOT}thumb.php?type=profileiconbyid&amp;maxwidth=50&amp;maxheight=50&amp;id={$user->profileicon}" alt="">
<img src="{profile_icon_url user=$user maxwidth=50 maxheight=50}" alt="">
</div>
<h3><a href="{$WWWROOT}user/view.php?id={$user->id}">{$user|display_name}</a></h3>
{if $user->introduction}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment