Commit 98dcaee3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Combine profileicon & email queries in thumb.php


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 17f277bd
......@@ -45,20 +45,21 @@ switch ($type) {
if ($type == 'profileicon') {
// Convert ID of user to the ID of a profileicon
$data = get_record_sql('
SELECT u.profileicon, f.filetype
FROM {usr} u INNER JOIN {artefact_file_files} f ON u.profileicon = f.artefact
SELECT u.profileicon, u.email, f.filetype
FROM {usr} u LEFT JOIN {artefact_file_files} f ON u.profileicon = f.artefact
WHERE u.id = ?', array($id));
if ($data) {
if (!empty($data->profileicon)) {
$id = $data->profileicon;
$mimetype = $data->filetype;
}
else {
// Get email address for gravatar icon
$useremail = get_field('usr', 'email', 'id', $id);
$notfound = get_config('wwwroot').'thumb.php?type=profileiconbyid';
foreach ($_GET as $k => $v) {
if ($k != 'id' && $k != 'type') {
$notfound .= '&' . $k . '=' . $v;
if ($useremail = $data->email) {
// We can use the email address for gravatar icon
$notfound = get_config('wwwroot').'thumb.php?type=profileiconbyid';
foreach ($_GET as $k => $v) {
if ($k != 'id' && $k != 'type') {
$notfound .= '&' . $k . '=' . $v;
}
}
}
$id = null;
......
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