summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Producers.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-11-14 11:16:39 +0100
committerYorhel <git@yorhel.nl>2008-11-14 11:16:39 +0100
commitcb196de6bc61c9f513a564643926bee656758450 (patch)
treec990c5b9c6e8031f3eff9447de2bd99a04a6d0ea /lib/VNDB/DB/Producers.pm
parented7a3c08b0d062a0b174d577b2639e88f18d3a42 (diff)
Adding new producer works + abstracted adding of new items and revisions
...and those URL regexes are getting more and more complex >.>
Diffstat (limited to 'lib/VNDB/DB/Producers.pm')
-rw-r--r--lib/VNDB/DB/Producers.pm39
1 files changed, 21 insertions, 18 deletions
diff --git a/lib/VNDB/DB/Producers.pm b/lib/VNDB/DB/Producers.pm
index eee42f48..8b8b29aa 100644
--- a/lib/VNDB/DB/Producers.pm
+++ b/lib/VNDB/DB/Producers.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Exporter 'import';
-our @EXPORT = qw|dbProducerGet dbProducerMod dbProducerEdit|;
+our @EXPORT = qw|dbProducerGet dbProducerMod dbProducerEdit dbProducerAdd|;
# options: results, page, id, search, char, rev
@@ -88,32 +88,35 @@ sub dbProducerMod {
}
-# arguments: id, %options ->( editsum + columns in producers_rev )
+# arguments: id, %options ->( editsum + insert_rev )
# returns: ( local revision, global revision )
sub dbProducerEdit {
my($self, $pid, %o) = @_;
+ my($rev, $cid) = $self->dbRevisionInsert(2, $pid, $o{editsum});
+ insert_rev($self, $cid, $pid, \%o);
+ return ($rev, $cid);
+}
+
- my $c = $self->dbRow(q|
- INSERT INTO changes (type, requester, ip, comments, rev)
- VALUES (2, ?, ?, ?, (
- SELECT c.rev+1
- FROM changes c
- JOIN producers_rev pr ON pr.id = c.id
- WHERE pr.pid = ?
- ORDER BY c.id DESC
- LIMIT 1
- ))
- RETURNING id, rev|,
- $self->authInfo->{id}, $self->reqIP, $o{editsum}, $pid);
+# arguments: %options ->( editsum + insert_rev )
+# returns: ( item id, global revision )
+sub dbProducerAdd {
+ my($self, %o) = @_;
+ my($pid, $cid) = $self->dbItemInsert(2, $o{editsum});
+ insert_rev($self, $cid, $pid, \%o);
+ return ($pid, $cid);
+}
+
+# helper function, inserts a producer revision
+# Arguments: global revision, item id, { columns in producers_rev }
+sub insert_rev {
+ my($self, $cid, $pid, $o) = @_;
$self->dbExec(q|
INSERT INTO producers_rev (id, pid, name, original, website, type, lang, "desc")
VALUES (!l)|,
- [ $c->{id}, $pid, @o{qw| name original website type lang desc|} ]
+ [ $cid, $pid, @$o{qw| name original website type lang desc|} ]
);
-
- $self->dbExec(q|UPDATE producers SET latest = ? WHERE id = ?|, $c->{id}, $pid);
- return ($c->{rev}, $c->{id});
}