New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gravatar #8
Gravatar #8
Changes from all commits
7f21a5f
1b8ff07
3d78f1f
35dd209
418ef8a
82e418b
e88dcf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2071,6 +2071,44 @@ function avatar_remote($data, &$error) | |
return array(AVATAR_REMOTE, $data['remotelink'], $width, $height); | ||
} | ||
|
||
/** | ||
* Gravatar avatar linking | ||
*/ | ||
function avatar_gravatar($data, &$error) | ||
{ | ||
global $user, $config; | ||
|
||
// Hieght and width, Gravatars are /always/ square, and we are using 80 is | ||
// the Gravatar default. | ||
$size = ($data['width'] > 0) ? $data['width'] : 80; | ||
|
||
if ($config['avatar_max_width'] || $config['avatar_max_height']) | ||
{ | ||
if ($size > $config['avatar_max_width'] || $size > $config['avatar_max_height']) | ||
{ | ||
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $size, $size); | ||
return false; | ||
} | ||
} | ||
|
||
if ($config['avatar_min_width'] || $config['avatar_min_height']) | ||
{ | ||
if ($size < $config['avatar_min_width'] || $size < $config['avatar_min_height']) | ||
{ | ||
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $size, $size); | ||
return false; | ||
} | ||
} | ||
|
||
/* | ||
* According to the specifications at http://gravatar.com/site/implement/url, | ||
* md5() of an strtolower()'d and trim()'d email address. This allows the | ||
* storage only the 'slug' portion, the URL portion is applied when displaying | ||
* the gravatar. | ||
*/ | ||
return array(AVATAR_GRAVATAR, md5($user->data['user_email']), $size, $size); | ||
} | ||
|
||
/** | ||
* Avatar upload using the upload class | ||
*/ | ||
|
@@ -2259,6 +2297,13 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $ | |
case AVATAR_REMOTE : | ||
break; | ||
|
||
case AVATAR_GRAVATAR : | ||
// Note: we actually return in this case. We accecpt whatever | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accecpt -> accept |
||
// current_x is and fall back on 80 (Gravatar standard default) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kind of hard to understand. maybe: "use current_x if the size has been set and fall back on 80 (Gravatar default) if not |
||
$size = ($current_x > 0 && $current_y > 0) ? $current_x : 80; | ||
return array($size, $size); | ||
break; | ||
|
||
case AVATAR_UPLOAD : | ||
$avatar = $phpbb_root_path . $config['avatar_path'] . '/' . get_avatar_filename($avatar); | ||
break; | ||
|
@@ -2312,13 +2357,15 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu | |
'remotelink' => request_var('remotelink', ''), | ||
'width' => request_var('width', 0), | ||
'height' => request_var('height', 0), | ||
'use_gravatar' => request_var('gravatar', 0), | ||
); | ||
|
||
$error = validate_data($data, array( | ||
'uploadurl' => array('string', true, 5, 255), | ||
'remotelink' => array('string', true, 5, 255), | ||
'width' => array('string', true, 1, 3), | ||
'height' => array('string', true, 1, 3), | ||
'use_gravatar' => array('num', true, 0, 1), | ||
)); | ||
|
||
if (sizeof($error)) | ||
|
@@ -2355,6 +2402,10 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu | |
{ | ||
list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_remote($data, $error); | ||
} | ||
else if ($data['use_gravatar'] && $change_avatar && $config['allow_avatar_gravatar']) | ||
{ | ||
list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_gravatar($data, $error); | ||
} | ||
else if ($avatar_select && $change_avatar && $config['allow_avatar_local']) | ||
{ | ||
$category = basename(request_var('category', '')); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,10 +101,21 @@ | |
'ALLOW_REMOTE_UPLOAD' => 'Enable remote avatar uploading', | ||
'ALLOW_REMOTE_UPLOAD_EXPLAIN' => 'Allow uploading of avatars from another website.', | ||
'ALLOW_UPLOAD' => 'Enable avatar uploading', | ||
'ALLOW_GRAVATAR' => 'Enable Gravatar avatars', | ||
'ALLOW_GRAVATAR_EXPLAIN' => 'Allow users to use the Gravatar attached to their email address.', | ||
'AVATAR_GALLERY_PATH' => 'Avatar gallery path', | ||
'AVATAR_GALLERY_PATH_EXPLAIN' => 'Path under your phpBB root directory for pre-loaded images, e.g. <samp>images/avatars/gallery</samp>.', | ||
'AVATAR_STORAGE_PATH' => 'Avatar storage path', | ||
'AVATAR_STORAGE_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. <samp>images/avatars/upload</samp>.', | ||
'GRAVATAR_SETTINGS' => 'Gravatar Ssettings', | ||
'GRAVATAR_FORCE' => 'Force Gravatar avatars', | ||
'GRAVATAR_FORCE_EXPLAIN' => 'Force all newly registered users to use Gravatar avatars. This will work regardless of if avatars are on or not.', | ||
'GRAVATAR_DEFAULT' => 'Default Gravatar image', | ||
'GRAVATAR_DEFAULT_EXPLAIN' => 'If the user\'s email address does not have a Gravatar associated with it, default to this picture. See all possible values <a href="http://en.gravatar.com/site/implement/images/#default-image">here</a> or specify the full URI of a default avatar.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't be using a backslash to escape it |
||
'GRAVATAR_RATING' => 'Maximum rating', | ||
'GRAVATAR_RATING_EXPLAIN' => 'Allow the following <a href="http://en.gravatar.com/site/implement/images/#rating">Gravatar rating</a> in Gravatars on the board', | ||
'GRAVATAR_DEFAULT_SIZE' => 'Default Gravatar dimensions', | ||
'GRAVATAR_DEFAULT_SIZE_EXPLAIN' => 'Size of a side in pixels (Gravatars are square)', | ||
'MAX_AVATAR_SIZE' => 'Maximum avatar dimensions', | ||
'MAX_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', | ||
'MAX_FILESIZE' => 'Maximum avatar file size', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hieght -> Height
you also might not want to capitalise it