mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-25 04:24:31 +02:00
[feature/avatars] Miscellaneous fixes
PHPBB3-10018
This commit is contained in:
@ -334,7 +334,7 @@ class acp_groups
|
||||
{
|
||||
// Handle avatar
|
||||
$driver = str_replace('_', '.', request_var('avatar_driver', ''));
|
||||
$config_name = preg_replace('#^avatar.driver.#', '', $driver);
|
||||
$config_name = preg_replace('#^avatar\.driver.#', '', $driver);
|
||||
$avatar_delete = $request->variable('avatar_delete', '');
|
||||
if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete))
|
||||
{
|
||||
@ -534,7 +534,7 @@ class acp_groups
|
||||
if ($avatar->is_enabled())
|
||||
{
|
||||
$avatars_enabled = true;
|
||||
$config_name = preg_replace('#^avatar.driver.#', '', $driver);
|
||||
$config_name = preg_replace('#^avatar\.driver.#', '', $driver);
|
||||
$template->set_filenames(array(
|
||||
'avatar' => "acp_avatar_options_$config_name.html",
|
||||
));
|
||||
@ -558,8 +558,10 @@ class acp_groups
|
||||
|
||||
$avatar = get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
|
||||
// Merge any avatars errors into the primary error array
|
||||
// Drivers use lang constants, so we need to map to the actual strings
|
||||
/*
|
||||
* Merge any avatar errors into the primary error array
|
||||
* Drivers use language constants, so we need to map to the actual strings
|
||||
*/
|
||||
foreach ($avatar_error as $e)
|
||||
{
|
||||
if (is_array($e))
|
||||
@ -569,7 +571,7 @@ class acp_groups
|
||||
}
|
||||
else
|
||||
{
|
||||
$error[] = $user->lang((string) $e);
|
||||
$error[] = $user->lang("$e");
|
||||
}
|
||||
}
|
||||
|
||||
@ -615,7 +617,7 @@ class acp_groups
|
||||
|
||||
'S_RANK_OPTIONS' => $rank_options,
|
||||
'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
|
||||
'AVATAR' => (empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar),
|
||||
'AVATAR' => empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar,
|
||||
'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
|
||||
'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '',
|
||||
'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '',
|
||||
|
@ -454,7 +454,7 @@ class acp_users
|
||||
{
|
||||
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
|
||||
}
|
||||
|
||||
|
||||
$sql_ary = array(
|
||||
'user_avatar' => '',
|
||||
'user_avatar_type' => '',
|
||||
@ -1745,7 +1745,7 @@ class acp_users
|
||||
if (check_form_key($form_name))
|
||||
{
|
||||
$driver = str_replace('_', '.', request_var('avatar_driver', ''));
|
||||
$config_name = preg_replace('#^avatar.driver.#', '', $driver);
|
||||
$config_name = preg_replace('#^avatar\.driver.#', '', $driver);
|
||||
$avatar_delete = $request->variable('avatar_delete', '');
|
||||
if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete))
|
||||
{
|
||||
@ -1761,6 +1761,7 @@ class acp_users
|
||||
'user_avatar_width' => $result['avatar_width'],
|
||||
'user_avatar_height' => $result['avatar_height'],
|
||||
);
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $result) . '
|
||||
WHERE user_id = ' . $user_id;
|
||||
@ -1771,7 +1772,8 @@ class acp_users
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']))
|
||||
$avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']);
|
||||
if ($avatar)
|
||||
{
|
||||
$avatar->delete($avatar_data);
|
||||
}
|
||||
@ -1786,7 +1788,7 @@ class acp_users
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $result) . '
|
||||
WHERE user_id = ' . $user_id;
|
||||
WHERE user_id = ' . (int) $user_id;
|
||||
|
||||
$db->sql_query($sql);
|
||||
trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
|
||||
@ -1807,7 +1809,7 @@ class acp_users
|
||||
if ($avatar->is_enabled())
|
||||
{
|
||||
$avatars_enabled = true;
|
||||
$config_name = preg_replace('#^avatar.driver.#', '', $driver);
|
||||
$config_name = preg_replace('#^avatar\.driver.#', '', $driver);
|
||||
$template->set_filenames(array(
|
||||
'avatar' => "acp_avatar_options_$config_name.html",
|
||||
));
|
||||
|
@ -56,11 +56,10 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver
|
||||
*/
|
||||
public function get_custom_html($row, $ignore_config = false, $alt = '')
|
||||
{
|
||||
$html = '<img src="' . $this->get_gravatar_url($row) . '" ' .
|
||||
return '<img src="' . $this->get_gravatar_url($row) . '" ' .
|
||||
($row['avatar_width'] ? ('width="' . $row['avatar_width'] . '" ') : '') .
|
||||
($row['avatar_height'] ? ('height="' . $row['avatar_height'] . '" ') : '') .
|
||||
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,7 +120,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver
|
||||
$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 = getimagesize($url)) === false))
|
||||
{
|
||||
$error[] = 'UNABLE_GET_IMAGE_SIZE';
|
||||
return false;
|
||||
|
@ -106,7 +106,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
||||
// Make sure getimagesize works...
|
||||
if (function_exists('getimagesize'))
|
||||
{
|
||||
if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false))
|
||||
if (($width <= 0 || $height <= 0) && (($image_data = getimagesize($url)) === false))
|
||||
{
|
||||
$error[] = 'UNABLE_GET_IMAGE_SIZE';
|
||||
return false;
|
||||
|
@ -521,7 +521,7 @@ class ucp_groups
|
||||
{
|
||||
// Handle avatar
|
||||
$driver = str_replace('_', '.', request_var('avatar_driver', ''));
|
||||
$config_name = preg_replace('#^avatar.driver.#', '', $driver);
|
||||
$config_name = preg_replace('#^avatar\.driver.#', '', $driver);
|
||||
$avatar_delete = $request->variable('avatar_delete', '');
|
||||
if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete))
|
||||
{
|
||||
|
@ -564,7 +564,7 @@ class ucp_profile
|
||||
if (check_form_key('ucp_avatar'))
|
||||
{
|
||||
$driver = str_replace('_', '.', request_var('avatar_driver', ''));
|
||||
$config_name = preg_replace('#^avatar.driver.#', '', $driver);
|
||||
$config_name = preg_replace('#^avatar\.driver.#', '', $driver);
|
||||
$avatar_delete = $request->variable('avatar_delete', '');
|
||||
if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete))
|
||||
{
|
||||
|
@ -2722,27 +2722,27 @@ function change_database_data(&$no_updates, $version)
|
||||
foreach ($avatar_type_map as $old => $new)
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
SET user_avatar_type = '" . $db->sql_escape($new) . "'
|
||||
WHERE user_avatar_type = '" . $db->sql_escape($old) . "'";
|
||||
SET user_avatar_type = '" . $new . "'
|
||||
WHERE user_avatar_type = '" . $old . "'";
|
||||
_sql($sql, $errored, $error_ary);
|
||||
|
||||
$sql = 'UPDATE ' . GROUPS_TABLE . "
|
||||
SET group_avatar_type = '" . $db->sql_escape($new) . "'
|
||||
WHERE group_avatar_type = '" . $db->sql_escape($old) . "'";
|
||||
SET group_avatar_type = '" . $new . "'
|
||||
WHERE group_avatar_type = '" . $old . "'";
|
||||
_sql($sql, $errored, $error_ary);
|
||||
}
|
||||
|
||||
// update avatar module_auth
|
||||
$sql = 'UPDATE ' . MODULES_TABLE . '
|
||||
SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload || cfg_allow_avatar_gravatar)\'
|
||||
WHERE module_class = \'ucp\'
|
||||
AND module_basename = \'ucp_profile\'
|
||||
AND module_mode = \'avatar\'';
|
||||
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||
SET module_auth = 'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload || cfg_allow_avatar_gravatar)'
|
||||
WHERE module_class = 'ucp'
|
||||
AND module_basename = 'ucp_profile'
|
||||
AND module_mode = 'avatar'";
|
||||
_sql($sql, $errored, $error_ary);
|
||||
|
||||
if (!isset($config['allow_avatar_gravatar']))
|
||||
{
|
||||
$config->set('allow_avatar_gravatar', '');
|
||||
$config->set('allow_avatar_gravatar', '0');
|
||||
}
|
||||
|
||||
$no_updates = false;
|
||||
|
Reference in New Issue
Block a user