summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-07-08 11:29:36 +0200
committerYorhel <git@yorhel.nl>2009-07-08 11:29:36 +0200
commitf89f04a1c646e59cdc009ddd677748527e2c3c2e (patch)
treec9f5986c7fc3a3bca3400ecb891ed2b76be066db /lib/VNDB
parent5d6f09f838392f1e2c072f44f904b5f9eab95f45 (diff)
Keep track of users who requested tags
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/DB/Tags.pm16
-rw-r--r--lib/VNDB/Handler/Tags.pm4
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm
index 280f3f3e..3e095d3c 100644
--- a/lib/VNDB/DB/Tags.pm
+++ b/lib/VNDB/DB/Tags.pm
@@ -9,7 +9,7 @@ our @EXPORT = qw|dbTagGet dbTagTree dbTagEdit dbTagAdd dbTagMerge dbTagLinks dbT
# %options->{ id noid name search state meta page results order what }
-# what: parents childs(n) aliases
+# what: parents childs(n) aliases addedby
sub dbTagGet {
my $self = shift;
my %o = (
@@ -38,13 +38,19 @@ sub dbTagGet {
defined $o{meta} ? (
't.meta = ?' => $o{meta}?1:0 ) : (),
);
+ my @select = (
+ qw|t.id t.meta t.name t.description t.added t.state t.c_vns|,
+ $o{what} =~ /addedby/ ? ('t.addedby', 'u.username') : (),
+ );
+ my @join = $o{what} =~ /addedby/ ? 'JOIN users u ON u.id = t.addedby' : ();
my($r, $np) = $self->dbPage(\%o, q|
- SELECT t.id, t.meta, t.name, t.description, t.added, t.state, t.c_vns
+ SELECT !s
FROM tags t
+ !s
!W
ORDER BY !s|,
- \%where, $o{order}
+ join(', ', @select), join(' ', @join), \%where, $o{order}
);
if(@$r && $o{what} =~ /aliases/) {
@@ -97,8 +103,8 @@ sub dbTagEdit {
# returns the id of the new tag
sub dbTagAdd {
my($self, %o) = @_;
- my $id = $self->dbRow('INSERT INTO tags (name, meta, description, state) VALUES (!l) RETURNING id',
- [ map $o{$_}, qw|name meta description state| ]
+ my $id = $self->dbRow('INSERT INTO tags (name, meta, description, state, addedby) VALUES (!l, ?) RETURNING id',
+ [ map $o{$_}, qw|name meta description state| ], $o{addedby}||$self->authInfo->{id}
)->{id};
$self->dbExec('INSERT INTO tags_parents (tag, parent) VALUES (?, ?)', $id, $_) for(@{$o{parents}});
$self->dbExec('INSERT INTO tags_aliases (tag, alias) VALUES (?, ?)', $id, $_) for (@{$o{aliases}});
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index a6d02698..6471d44f 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -238,7 +238,7 @@ sub tagedit {
return $self->htmlDenied if !$self->authCan('tag') || $tag && !$self->authCan('tagmod');
- my $t = $tag && $self->dbTagGet(id => $tag, what => 'parents(1) aliases')->[0];
+ my $t = $tag && $self->dbTagGet(id => $tag, what => 'parents(1) aliases addedby')->[0];
return 404 if $tag && !$t;
if($self->reqMethod eq 'POST') {
@@ -319,6 +319,8 @@ sub tagedit {
$self->htmlForm({ frm => $frm, action => $par ? "/g$par->{id}/add" : $tag ? "/g$tag/edit" : '/g/new' }, $title => [
[ input => short => 'name', name => 'Primary name' ],
$self->authCan('tagmod') ? (
+ $tag ?
+ [ static => label => 'Added by', content => sub { a href => "/u$t->{addedby}", $t->{username}; } ] : (),
[ select => short => 'state', name => 'State', options => [
[ 0, 'Awaiting moderation' ], [ 1, 'Deleted/hidden' ], [ 2, 'Approved' ] ] ],
[ checkbox => short => 'meta', name => 'This is a meta-tag (only to be used as parent for other tags, not for linking to VN entries)' ],