Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Changing Return Value for Profile Pic Global

Quote Reply
Changing Return Value for Profile Pic Global
Hey guys,

Looking for a bit of help here with some basic Perl in the globals.

We're busy redoing our comment system's layout and requires us to use a placeholder image as an avatar for users who do not have a profile picture set.

However, the way the global is set up - when there is no picture in the profile, it returns an empty value - as opposed to a null value.

This means that we're unable to do an <%if uiPhoto%>.

So we're thinking that we need to change it so that the global returns a default value (Image URL) when it finds no profile picture for that particular user.

Here's the global:

Code:
sub {
my $username = shift;
my $size = shift;
use lib ('/home/site/site.com/cgi-bin/forum/admin');

my $DB = GT::SQL->new('/home/site/site.com/cgi-bin/forum/admin/defs');
my $sth = $DB->table('User')->do_query(qq|
SELECT * FROM forum_User
WHERE user_icon IS NOT NULL
AND profile_picture_index != 0
AND user_username = "$username";
|);

my $out;
my ( @UserInfo );
my $hits = 0;
while (my $res = $sth->fetchrow_hashref()) {

my $username = $res->{user_username};
my $pic = $res->{profile_picture_index};
if($pic == 0)
{
next;
}
$hits++;
my $rows = $DB->table('Profile_Pictures')->do_query(qq|
SELECT picture$pic|.qq|_$size FROM forum_Profile_Pictures
WHERE user_id = $res->{user_id};
|);

my $row = $rows->fetchrow_arrayref();
my $picLink = qq|/graphics/forum/users/profile_pictures/$row->[0]|;

push(@UserInfo, { 'uiUsername' => $username,
'uiPhoto' => $picLink,
},
);
}

return {UserInfoLoop => \@UserInfo,
UserInfoHits => $hits,
};

}
Thanks!
Subject Author Views Date
Thread; hot thread Changing Return Value for Profile Pic Global meso 14542 May 27, 2014, 2:00 AM
Thread; hot thread Re: [meso] Changing Return Value for Profile Pic Global
Andy 14348 May 27, 2014, 3:01 AM
Thread; hot thread Re: [Andy] Changing Return Value for Profile Pic Global
meso 14255 May 27, 2014, 4:55 AM
Thread; hot thread Re: [meso] Changing Return Value for Profile Pic Global
Andy 14310 May 27, 2014, 4:56 AM
Thread; hot thread Re: [Andy] Changing Return Value for Profile Pic Global
meso 14271 May 27, 2014, 5:20 AM
Thread; hot thread Re: [meso] Changing Return Value for Profile Pic Global
Andy 14286 May 27, 2014, 5:25 AM
Thread; hot thread Re: [Andy] Changing Return Value for Profile Pic Global
eupos 14271 May 27, 2014, 5:32 AM
Post; hot thread Re: [eupos] Changing Return Value for Profile Pic Global
Andy 14292 May 27, 2014, 5:36 AM
Thread; hot thread Re: [Andy] Changing Return Value for Profile Pic Global
meso 14266 May 27, 2014, 5:44 AM
Post; hot thread Re: [meso] Changing Return Value for Profile Pic Global
Andy 14295 May 27, 2014, 5:46 AM
Thread; hot thread Re: [meso] Changing Return Value for Profile Pic Global
eupos 14236 May 27, 2014, 5:49 AM
Thread; hot thread Re: [eupos] Changing Return Value for Profile Pic Global
meso 14251 May 27, 2014, 6:19 AM
Thread; hot thread Re: [meso] Changing Return Value for Profile Pic Global
eupos 14255 May 27, 2014, 6:33 AM
Thread; hot thread Re: [eupos] Changing Return Value for Profile Pic Global
meso 14258 May 27, 2014, 6:37 AM
Post; hot thread Re: [meso] Changing Return Value for Profile Pic Global
eupos 14226 May 27, 2014, 6:43 AM
Post; hot thread Post deleted by el noe
el noe 14163 May 28, 2014, 4:37 AM