my $self = shift;
$self->{'kernel'}->post('FSpotDB',
- single => { sql => $self->{'sql'}, event => 'find_photo_result' }
+ single => {
+ sql => $self->{'sql'},
+ placeholders => $self->{'tags'},
+ event => 'find_photo_result',
+ }
);
}
FROM photos, photo_tags, tags
WHERE photos.id = photo_tags.photo_id
AND photo_tags.tag_id = tags.id
- AND tags.name = 'Brooke'
+ ";
+
+ if (defined $self->{'config'}{'_config'}{'plugins'}{'FSpot'}{'tags'}) {
+ $self->{'tags'} = $self->{'config'}{'_config'}{'plugins'}{'FSpot'}{'tags'};
+
+ if (scalar (@{ $self->{'tags'} })) {
+ my $holders = "?, " x scalar(@{ $self->{'tags'} });
+ $holders =~ s/, $//;
+
+ $self->{'sql'} .= "AND tags.name IN ($holders)";
+ } else {
+ $self->{'sql'} .= "AND tags.name = '?'";
+ }
+
+ $self->{'tags'} = $self->{'config'}{'_config'}{'plugins'}{'FSpot'}{'tags'};
+ } else {
+ $self->{'sql'} .= "AND tags.name = 'Favorites'"; # Sigh
+ }
+
+ $self->{'sql'} .= "
ORDER BY random()
LIMIT 1
";