mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Fixing a bug nobody reported so far: the avatar gallery displayed a faulty message about avatars being disabled.
Also fixes #10531 (let's pretend that it isn't a new feature. It's neat, though) git-svn-id: file:///svn/phpbb/trunk@7495 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
1eee5ca388
commit
56f4c786a5
3 changed files with 77 additions and 6 deletions
|
@ -1764,6 +1764,61 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var
|
|||
return $avatar_list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tries to (re-)establish avatar dimensions
|
||||
*/
|
||||
function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $current_y = 0)
|
||||
{
|
||||
global $config, $phpbb_root_path;
|
||||
|
||||
switch ($avatar_type)
|
||||
{
|
||||
case AVATAR_REMOTE :
|
||||
break;
|
||||
|
||||
case AVATAR_UPLOAD :
|
||||
// Make sure getimagesize works...
|
||||
$avatar = $phpbb_root_path . $config['avatar_path'] . '/' . get_avatar_filename($avatar);
|
||||
break;
|
||||
|
||||
case AVATAR_GALLERY :
|
||||
$avatar = $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar ;
|
||||
break;
|
||||
}
|
||||
// Make sure getimagesize works...
|
||||
if (($image_data = @getimagesize($avatar)) === false)
|
||||
{
|
||||
$error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($image_data[0] < 2 || $image_data[1] < 2)
|
||||
{
|
||||
$error[] = $user->lang['AVATAR_NO_SIZE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
// try to maintain ratio
|
||||
if (!(empty($current_x) && empty($current_y)))
|
||||
{
|
||||
if ($current_x != 0)
|
||||
{
|
||||
$image_data[1] = (int) floor(($current_x / $image_data[0]) * $image_data[1]);
|
||||
$image_data[1] = min($config['avatar_max_height'], $image_data[1]);
|
||||
$image_data[1] = max($config['avatar_min_height'], $image_data[1]);
|
||||
}
|
||||
if ($current_y != 0)
|
||||
{
|
||||
$image_data[0] = (int) floor(($current_y / $image_data[1]) * $image_data[0]);
|
||||
$image_data[0] = min($config['avatar_max_width'], $image_data[1]);
|
||||
$image_data[0] = max($config['avatar_min_width'], $image_data[1]);
|
||||
}
|
||||
|
||||
}
|
||||
return array($image_data[0], $image_data[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploading/Changing user avatar
|
||||
*/
|
||||
|
@ -1774,8 +1829,8 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
|||
$data = array(
|
||||
'uploadurl' => request_var('uploadurl', ''),
|
||||
'remotelink' => request_var('remotelink', ''),
|
||||
'width' => request_var('width', ''),
|
||||
'height' => request_var('height', ''),
|
||||
'width' => request_var('width', 0),
|
||||
'height' => request_var('height', 0),
|
||||
);
|
||||
|
||||
$error = validate_data($data, array(
|
||||
|
@ -1840,9 +1895,25 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
|||
$sql_ary['user_avatar'] = '';
|
||||
$sql_ary['user_avatar_type'] = $sql_ary['user_avatar_width'] = $sql_ary['user_avatar_height'] = 0;
|
||||
}
|
||||
else if ($data['width'] && $data['height'] && ($userdata['user_avatar_type'] != AVATAR_GALLERY))
|
||||
elseif (!empty($userdata['user_avatar']))
|
||||
{
|
||||
// Only update the dimensions?
|
||||
// Only update the dimensions
|
||||
|
||||
if (empty($data['width']) || empty($data['height']))
|
||||
{
|
||||
if ($dims = avatar_get_dimensions($userdata['user_avatar'], $userdata['user_avatar_type'], $error, $data['width'], $data['height']))
|
||||
{
|
||||
list($guessed_x, $guessed_y) = $dims;
|
||||
if (empty($data['width']))
|
||||
{
|
||||
$data['width'] = $guessed_x;
|
||||
}
|
||||
if (empty($data['height']))
|
||||
{
|
||||
$data['height'] = $guessed_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($config['avatar_max_width'] || $config['avatar_max_height'])
|
||||
{
|
||||
if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height'])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
<div class="panel">
|
||||
<div class="inner"><span class="corners-top"><span></span></span>
|
||||
<!-- IF not S_UPLOAD_AVATAR_FILE and not S_UPLOAD_AVATAR_URL and not S_LINK_AVATAR and not S_DISPLAY_GALLERY -->
|
||||
<!-- IF not S_UPLOAD_AVATAR_FILE and not S_UPLOAD_AVATAR_URL and not S_LINK_AVATAR and not S_IN_AVATAR_GALLERY -->
|
||||
<p>{L_AVATAR_FEATURES_DISABLED}</p>
|
||||
<!-- ENDIF -->
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" />
|
||||
<!-- ENDIF --></td>
|
||||
</tr>
|
||||
<!-- IF not S_UPLOAD_AVATAR_FILE and not S_UPLOAD_AVATAR_URL and not S_LINK_AVATAR and not S_DISPLAY_GALLERY -->
|
||||
<!-- IF not S_UPLOAD_AVATAR_FILE and not S_UPLOAD_AVATAR_URL and not S_LINK_AVATAR and not S_IN_AVATAR_GALLERY -->
|
||||
<tr>
|
||||
<td class="row3" colspan="2" align="center">{L_AVATAR_FEATURES_DISABLED}</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue