LiveJournal Moods
head<=
<=head
body<=
. You can always enter your own, but these are the ones that can have pictures associated with them and can be searched on, etc. You're encouraged to use these if possible. p?>modify journal page and select your preferred icon set. p?>";
};
# Get a list of all possible moods
my $moods = LJ::get_moods();
my @mlist = ();
my %lists = {};
foreach (sort { $moods->{$a}->{'name'} cmp $moods->{$b}->{'name'} } keys %$moods) {
my $m = $moods->{$_};
push @mlist, $m;
}
# FIXME: cache this. it's small.
$sth = $dbr->prepare("SELECT moodthemeid, name, is_public FROM moodthemes WHERE is_public='Y'");
$sth->execute;
my @themes = ();
push @themes, $_ while $_ = $sth->fetchrow_hashref;
@themes = sort { lc($a->{name}) cmp lc($b->{name}) } @themes;
my @user_themes;
# Determine the action depending on the GET arguments, or lack thereof
if (defined $GET{'moodtheme'}) {
$ret .= BML::ml('Backlink', {
'link'=>'/moodlist.bml',
'text'=>'Mood Themes',
}). "
";
$add_header->();
my $remote = LJ::get_remote();
# Check if the user is logged in and didn't specify an owner. If so append their private mood themes
my $sth;
if ($remote && ! $GET{'ownerid'}) {
# FIXME: cache this. it's small.
$sth = $dbr->prepare("SELECT moodthemeid, name, is_public FROM moodthemes WHERE ownerid=?");
$sth->execute($remote->{userid});
@user_themes = ();
push @user_themes, $_ while $_ = $sth->fetchrow_hashref;
} elsif ($GET{'ownerid'}) {
# FIXME: cache this. it's small.
$sth = $dbr->prepare("SELECT moodthemeid, name, is_public FROM moodthemes WHERE ownerid=? AND moodthemeid=?");
$sth->execute($GET{'ownerid'}, $GET{'moodtheme'});
@user_themes = ();
push @user_themes, $_ while $_ = $sth->fetchrow_hashref;
}
# Sort the user themes
@user_themes = sort { lc($a->{name}) cmp lc($b->{name}) } @user_themes;
# See if the user can even view this theme
my $theme = (grep { $_->{moodthemeid} == $GET{moodtheme} } (@themes, @user_themes))[0];
if (! $theme) {
# It isn't theirs, or they aren't logged in, and it isn't public and it actually exists
return LJ::bad_input("You only have permission to view public mood themes or user themes with an ownerid parameter.");
} elsif ( defined $GET{mode} && $GET{mode} == 'tree') {
if ($GET{'ownerid'}) {
$ret .= "
";
if ($GET{'ownerid'}) {
$ret .= " ";
$ret .= LJ::ehtml(@user_themes[0]->{name}) . ' - ';
$ret .= LJ::ljuser(LJ::get_username($GET{'ownerid'}));
$ret .= " | ||||
" .
"" .
" $mood | ";
} else {
$ret .= "" .
"$mood" .
" | ";
}
}
$ret .= "