Add server-side support for unselecting images.
authorSteinar H. Gunderson <sesse@debian.org>
Sat, 17 Apr 2010 10:40:49 +0000 (12:40 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Sat, 17 Apr 2010 10:40:49 +0000 (12:40 +0200)
perl/Sesse/pr0n/Select.pm

index a2b15e7d65fe306552c68e629e407151f1c0d181..897294429f2e475c1ba2826c78d308a5b6be99fc 100644 (file)
@@ -23,9 +23,13 @@ sub handler {
                local $dbh->{AutoCommit} = 0;
                local $dbh->{RaiseError} = 1;
 
-               # FIXME: need to support disable too
                my $filename = $apr->param('filename');
-               $dbh->do('UPDATE images SET selected=\'t\' WHERE vhost=? AND event=? AND filename=?', undef, $r->get_server_name, $event, $filename);
+               my $selected = $apr->param('selected');
+               my $sql_selected = 'f';
+               if (!defined($selected) || $selected eq '1') {
+                       $sql_selected = 't';
+               }
+               $dbh->do('UPDATE images SET selected=? WHERE vhost=? AND event=? AND filename=?', undef, $sql_selected, $r->get_server_name, $event, $filename);
        }
 
        $dbh->do('UPDATE last_picture_cache SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?', undef, $r->get_server_name, $event)