summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-01-15 15:44:09 +0100
committerYorhel <git@yorhel.nl>2009-01-15 15:44:09 +0100
commitf48da95f3a04d72f512ac85421d4dffc232e687f (patch)
tree03cde0eb90edf5605ab65122ccbe2dd9b280762d /lib/VNDB
parent45deb3802bccc2dfb3c12e57399b82e7c92bc05b (diff)
Don't forget to update the vn.c_* columns when hiding/unhiding a release
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/Handler/Misc.pm6
-rw-r--r--lib/VNDB/Handler/Releases.pm20
-rw-r--r--lib/VNDB/Util/Misc.pm24
3 files changed, 29 insertions, 21 deletions
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index 5a9b9a2a..39af8155 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -326,12 +326,16 @@ sub itemmod {
return $self->htmlDenied if !$self->authCan($act eq 'hide' ? 'del' : 'lock');
my $obj = $type eq 'v' ? $self->dbVNGet(id => $iid)->[0] :
- $type eq 'r' ? $self->dbReleaseGet(id => $iid)->[0] :
+ $type eq 'r' ? $self->dbReleaseGet(id => $iid, what => 'vn')->[0] :
$self->dbProducerGet(id => $iid)->[0];
return 404 if !$obj->{id};
$self->dbItemMod($type, $iid, $act eq 'hide' ? (hidden => !$obj->{hidden}) : (locked => !$obj->{locked}));
+ # update cached vn info when hiding an r+ page
+ $self->vnCacheUpdate(map $_->{vid}, @{$obj->{vn}})
+ if $type eq 'r' && $act eq 'hide';
+
$self->resRedirect("/$type$iid", 'temp');
}
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index aed1b291..38a1fa02 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -296,7 +296,7 @@ sub edit {
($rid) = $self->dbReleaseAdd(%opts) if !$rid;
$self->multiCmd("ircnotify r$rid.$rev");
- _update_vncache($self, @$new_vn, map $_->{vid}, @$vn);
+ $self->vnCacheUpdate(@$new_vn, map $_->{vid}, @$vn);
return $self->resRedirect("/r$rid.$rev", 'post');
}
@@ -413,23 +413,5 @@ sub _form {
}
-# Recalculates the vn.c_* columns and regenerates the related relation graphs on any change
-sub _update_vncache {
- my($self, @vns) = @_;
-
- my $before = $self->dbVNGet(id => \@vns, order => 'v.id', what => 'relations');
- $self->dbVNCache(@vns);
- my $after = $self->dbVNGet(id => \@vns, order => 'v.id');
-
- my @upd = map {
- @{$before->[$_]{relations}} && (
- $before->[$_]{c_released} != $after->[$_]{c_released}
- || $before->[$_]{c_languages} ne $after->[$_]{c_languages}
- ) ? $before->[$_]{id} : ();
- } 0..$#$before;
- $self->multiCmd('relgraph '.join(' ', @upd)) if @upd;
-}
-
-
1;
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm
index 94cdcd1e..139eb571 100644
--- a/lib/VNDB/Util/Misc.pm
+++ b/lib/VNDB/Util/Misc.pm
@@ -6,7 +6,7 @@ use warnings;
use Exporter 'import';
use Tie::ShareLite ':lock';
-our @EXPORT = qw|multiCmd|;
+our @EXPORT = qw|multiCmd vnCacheUpdate|;
# Sends a command to Multi
@@ -26,3 +26,25 @@ sub multiCmd {
$s->unlock();
$self->{_multiCmd} = [];
}
+
+
+# Recalculates the vn.c_* columns and regenerates the related relation graphs on any change
+# Arguments: list of vids to be updated
+sub vnCacheUpdate {
+ my($self, @vns) = @_;
+
+ my $before = $self->dbVNGet(id => \@vns, order => 'v.id', what => 'relations');
+ $self->dbVNCache(@vns);
+ my $after = $self->dbVNGet(id => \@vns, order => 'v.id');
+
+ my @upd = map {
+ @{$before->[$_]{relations}} && (
+ $before->[$_]{c_released} != $after->[$_]{c_released}
+ || $before->[$_]{c_languages} ne $after->[$_]{c_languages}
+ ) ? $before->[$_]{id} : ();
+ } 0..$#$before;
+ $self->multiCmd('relgraph '.join(' ', @upd)) if @upd;
+}
+
+
+1;