diff options
author | Yorhel <git@yorhel.nl> | 2019-06-26 13:03:27 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-06-26 13:03:27 +0200 |
commit | 7eacaba4ab19e4a57d02e0ac35f66bb10e85823a (patch) | |
tree | ad974f84925b73ccf5c25b305219ef996528a278 | |
parent | 8972da44acdc5fa4e053f32a184430fb0bdf9e80 (diff) |
Re-add tag vote deletion moderation feature
-rw-r--r-- | lib/VNDB/DB/Tags.pm | 8 | ||||
-rw-r--r-- | lib/VNDB/Handler/Tags.pm | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm index dc542ff8..97852724 100644 --- a/lib/VNDB/DB/Tags.pm +++ b/lib/VNDB/DB/Tags.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Exporter 'import'; -our @EXPORT = qw|dbTagGet dbTTTree dbTagEdit dbTagAdd dbTagMerge dbTagLinks dbTagLinkEdit dbTagStats|; +our @EXPORT = qw|dbTagGet dbTTTree dbTagEdit dbTagAdd dbTagMerge dbTagLinks dbTagLinkEdit dbTagStats dbTagWipeVotes|; # %options->{ id noid name search state searchable applicable page results what sort reverse } @@ -275,5 +275,11 @@ sub dbTagStats { return wantarray ? ($r, $np) : $r; } + +# Deletes all votes on a tag. +sub dbTagWipeVotes { + $_[0]->dbExec('DELETE FROM tags_vn WHERE tag = ?', $_[1]) +} + 1; diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm index 33da3dd6..6c0325f9 100644 --- a/lib/VNDB/Handler/Tags.pm +++ b/lib/VNDB/Handler/Tags.pm @@ -176,6 +176,7 @@ sub tagedit { { post => 'defaultspoil',required => 0, default => 0, enum => [ 0..2 ] }, { post => 'parents', required => !$self->authCan('tagmod'), default => '' }, { post => 'merge', required => 0, default => '' }, + { post => 'wipevotes', required => 0, default => 0 }, ); my @aliases = split /[\t\s]*\n[\t\s]*/, $frm->{alias}; my @parents = split /[\t\s]*,[\t\s]*/, $frm->{parents}; @@ -213,6 +214,7 @@ sub tagedit { $self->dbTagEdit($tag, %opts, upddate => $frm->{state} == 2 && $t->{state} != 2); _set_childs_cat($self, $tag, $frm->{cat}) if $frm->{catrec}; } + $self->dbTagWipeVotes($tag) if $self->authCan('tagmod') && $frm->{wipevotes}; $self->dbTagMerge($tag, @merge) if $self->authCan('tagmod') && @merge; $self->resRedirect("/g$tag", 'post'); return; @@ -270,13 +272,16 @@ sub tagedit { [ input => short => 'parents', name => 'Parent tags' ], [ static => content => 'Comma separated list of tag names to be used as parent for this tag.' ], $self->authCan('tagmod') ? ( - [ part => title => 'Merge tags' ], + [ part => title => 'DANGER: Merge tags' ], [ input => short => 'merge', name => 'Tags to merge' ], [ static => content => 'Comma separated list of tag names to merge into this one.' .' All votes and aliases/names will be moved over to this tag, and the old tags will be deleted.' .' Just leave this field empty if you don\'t intend to do a merge.' .'<br />WARNING: this action cannot be undone!' ], + + [ part => title => 'DANGER: Delete tag votes' ], + [ checkbox => short => 'wipevotes', name => 'Remove all votes on this tag. WARNING: cannot be undone!' ], ) : (), ]); $self->htmlFooter; |