phpBB

Code Changes

File: phpbb/avatar/driver/gravatar.php

  Unmodified   Added   Modified   Removed
Line 52Line 52
	public function prepare_form($request, $template, $user, $row, &$error)
{
$template->assign_vars(array(

	public function prepare_form($request, $template, $user, $row, &$error)
{
$template->assign_vars(array(

			'AVATAR_GRAVATAR_WIDTH' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_gravatar_width', 0),
'AVATAR_GRAVATAR_HEIGHT' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_gravatar_width', 0),

			'AVATAR_GRAVATAR_WIDTH' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_gravatar_width', ''),
'AVATAR_GRAVATAR_HEIGHT' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_gravatar_width', ''),

			'AVATAR_GRAVATAR_EMAIL' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar']) ? $row['avatar'] : '',
));


			'AVATAR_GRAVATAR_EMAIL' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar']) ? $row['avatar'] : '',
));


Line 98Line 98
			return false;
}


			return false;
}


		// Make sure getimagesize works...
if (function_exists('getimagesize') && ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0))

		// Get image dimensions if they are not set
if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0)

		{
/**
* default to the minimum of the maximum allowed avatar size if the size

		{
/**
* default to the minimum of the maximum allowed avatar size if the size

Line 108Line 108
			$row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']);
$url = $this->get_gravatar_url($row);


			$row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']);
$url = $this->get_gravatar_url($row);


			if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = getimagesize($url)) === false))

			if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = $this->imagesize->getImageSize($url)) === false))

			{
$error[] = 'UNABLE_GET_IMAGE_SIZE';
return false;
}


			{
$error[] = 'UNABLE_GET_IMAGE_SIZE';
return false;
}


			if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0))

			if (!empty($image_data) && ($image_data['width'] <= 0 || $image_data['width'] <= 0))

			{
$error[] = 'AVATAR_NO_SIZE';
return false;
}


			{
$error[] = 'AVATAR_NO_SIZE';
return false;
}


			$row['avatar_width'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_width'] : $image_data[0];
$row['avatar_height'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_height'] : $image_data[1];

			$row['avatar_width'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_width'] : $image_data['width'];
$row['avatar_height'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_height'] : $image_data['height'];

		}

if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0)

		}

if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0)

Line 172Line 172
	*/
protected function get_gravatar_url($row)
{

	*/
protected function get_gravatar_url($row)
{

 
		global $phpbb_dispatcher;


		$url = self::GRAVATAR_URL;
$url .= md5(strtolower(trim($row['avatar'])));


		$url = self::GRAVATAR_URL;
$url .= md5(strtolower(trim($row['avatar'])));


Line 179Line 181
		{
$url .= '?s=' . max($row['avatar_width'], $row['avatar_height']);
}

		{
$url .= '?s=' . max($row['avatar_width'], $row['avatar_height']);
}

 

/**
* Modify gravatar url
*
* @event core.get_gravatar_url_after
* @var string row User data or group data
* @var string url Gravatar URL
* @since 3.1.7-RC1
*/
$vars = array('row', 'url');
extract($phpbb_dispatcher->trigger_event('core.get_gravatar_url_after', compact($vars)));


return $url;
}


return $url;
}