summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/Util/DB.pm8
-rw-r--r--lib/VNDB/VN.pm7
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/VNDB/Util/DB.pm b/lib/VNDB/Util/DB.pm
index 2f9ae9f2..8641f6b0 100644
--- a/lib/VNDB/Util/DB.pm
+++ b/lib/VNDB/Util/DB.pm
@@ -824,7 +824,7 @@ sub DBGetVN { # %options->{ id rev char search order results page what cati cate
if($o{what} =~ /screenshots/) {
push(@{$r->[$r{$_->{vid}}]{screenshots}}, $_) && delete $_->{vid} for (@{$s->DBAll(q|
- SELECT vs.vid, s.id, vs.nsfw, s.width, s.height
+ SELECT vs.vid, s.id, vs.nsfw, vs.rid, s.width, s.height
FROM vn_screenshots vs
JOIN screenshots s ON vs.scr = s.id
WHERE vs.vid IN(!l)
@@ -917,9 +917,9 @@ sub _insert_vn_rev { # columns in vn_rev + categories + screenshots + relations
) for (@{$o->{categories}});
$s->DBExec(q|
- INSERT INTO vn_screenshots (vid, scr, nsfw)
- VALUES (?, ?, ?)|,
- $cid, $_->[0], $_->[1]?1:0
+ INSERT INTO vn_screenshots (vid, scr, nsfw, rid)
+ VALUES (?, ?, ?, ?)|,
+ $cid, $_->[0], $_->[1]?1:0, $_->[2]
) for (@{$o->{screenshots}});
$s->DBExec(q|
diff --git a/lib/VNDB/VN.pm b/lib/VNDB/VN.pm
index 9c872619..544bc351 100644
--- a/lib/VNDB/VN.pm
+++ b/lib/VNDB/VN.pm
@@ -83,7 +83,7 @@ sub VNEdit {
relations => join('|||', map { $_->{relation}.','.$_->{id}.','.$_->{title} } @{$v->{relations}}),
categories => join(',', map { $_->[0].$_->[1] } sort { $a->[0] cmp $b->[0] } @{$v->{categories}}),
anime => join(' ', sort { $a <=> $b } map $_->{id}, @{$v->{anime}}),
- screenshots => join(' ', map "$$_{id},$$_{nsfw}", @{$v->{screenshots}}),
+ screenshots => join(' ', map sprintf('%d,%d,%d', $$_{id}, $$_{nsfw}?1:0, $$_{rid}||0), @{$v->{screenshots}}),
) : ();
my $frm = {};
@@ -107,11 +107,11 @@ sub VNEdit {
my $relations = [ map { /^([0-9]+),([0-9]+)/ && $2 != $id ? ( [ $1, $2 ] ) : () } split /\|\|\|/, $frm->{relations} ];
my $cat = [ map { [ substr($_,0,3), substr($_,3,1) ] } split /,/, $frm->{categories} ];
my $anime = [ grep /^[0-9]+$/, split / +/, $frm->{anime} ];
- my $screenshots = [ map [split /,/], grep /^[0-9]+,[01]$/, split / +/, $frm->{screenshots} ];
+ my $screenshots = [ map { local $_=[split /,/];$$_[2]||=undef; $_ } grep /^[0-9]+,[01],[0-9]+$/, split / +/, $frm->{screenshots} ];
$frm->{img_nsfw} = $frm->{img_nsfw} ? 1 : 0;
$frm->{anime} = join ' ', sort { $a <=> $b } @$anime; # re-sort
- $frm->{screenshots} = join ' ', map "$$_[0],$$_[1]", sort { $$a[0] <=> $$b[0] } @$screenshots;
+ $frm->{screenshots} = join ' ', map sprintf('%d,%d,%d', $$_[0], $$_[1]?1:0, $$_[2]||0), sort { $$a[0] <=> $$b[0] } @$screenshots;
return $self->ResRedirect('/v'.$id, 'post')
if $id && !$self->ReqParam('img') && 13 == scalar grep { $b4{$_} eq $frm->{$_} } keys %b4;
@@ -191,6 +191,7 @@ sub VNEdit {
form => $frm,
id => $id,
vn => $v,
+ rel => scalar $self->DBGetRelease(vid => $id),
});
}