summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-11-15 12:12:20 +0100
committerYorhel <git@yorhel.nl>2008-11-15 12:12:20 +0100
commit0dd998b8b90f9a57025e4de0386dd7646f756af7 (patch)
treeffdfd29603e308a8e20d19ac88c07b3cd0086325
parentdb820616d0f5c7f49e725987b6cd900944e4ffd0 (diff)
Added revert edit option for producers and changed revert link
-rw-r--r--lib/ChangeLog3
-rw-r--r--lib/VNDB/Handler/Producers.pm17
-rw-r--r--lib/VNDB/Util/CommonHTML.pm2
3 files changed, 17 insertions, 5 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 167bb9e4..72904af8 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -17,6 +17,9 @@ TODO:
- Database changes:
- Added caching of edit and vote counts in users.c_votes and .c_changes
- Split users.flags into users.show_nsfw and .show_list (boolean type)
+ - URL changes:
+ - /p doesn't work anymore, use /p/all
+ - Revert URL changed from /x99/edit?rev=1 to /x99.1/edit
- Functionality changes:
- Ability to sort the userlist on vote and change counts
- Added threads and posts counts to the global statistics
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index bacabb08..c770e435 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -9,7 +9,8 @@ use VNDB::Func;
YAWF::register(
qr{p([1-9]\d*)(?:\.([1-9]\d*))?} => \&page,
- qr{p(?:([1-9]\d*)/edit|/new)} => \&edit,
+ qr{p(?:([1-9]\d*)(?:\.([1-9]\d*))?/edit|/new)}
+ => \&edit,
qr{p([1-9]\d*)/(lock|hide)} => \&mod,
qr{p/([a-z0]|all)} => \&list,
);
@@ -97,10 +98,11 @@ sub page {
# pid as argument = edit producer
# no arguments = add new producer
sub edit {
- my($self, $pid) = @_;
+ my($self, $pid, $rev) = @_;
- my $p = $pid && $self->dbProducerGet(id => $pid)->[0];
+ my $p = $pid && $self->dbProducerGet(id => $pid, what => 'changes', $rev ? (rev => $rev) : ())->[0];
return 404 if $pid && !$p->{id};
+ $rev = undef if $p->{cid} == $p->{latest};
return $self->htmlDenied if !$self->authCan('edit')
|| $pid && ($p->{locked} && !$self->authCan('lock') || $p->{hidden} && !$self->authCan('del'));
@@ -122,7 +124,7 @@ sub edit {
return $self->resRedirect("/p$pid", 'post')
if $pid && !grep $frm->{$_} ne $b4{$_}, keys %b4;
- my $rev = 1;
+ $rev = 1;
if($pid) {
($rev) = $self->dbProducerEdit($pid, %$frm);
} else {
@@ -137,6 +139,7 @@ sub edit {
!defined $frm->{$_} && ($frm->{$_} = $b4{$_}) for keys %b4;
$frm->{lang} = 'ja' if !$pid && !defined $frm->{lang};
+ $frm->{editsum} = sprintf 'Reverted to revision p%d.%d', $pid, $rev if $rev && !defined $frm->{editsum};
$self->htmlHeader(title => $pid ? 'Edit '.$p->{name} : 'Add new producer');
$self->htmlMainTabs('p', $p, 'edit') if $pid;
@@ -154,6 +157,12 @@ sub edit {
}
end;
end;
+ if($rev) {
+ div class => 'warning';
+ h2 'Reverting';
+ p 'You are editing an old revision of this producer. If you save it, all changes made after this revision will be reverted!';
+ end;
+ }
end;
$self->htmlForm({ frm => $frm, action => $pid ? "/p$pid/edit" : '/p/new', editsum => 1 }, "General info" => [
[ select => name => 'Type', short => 'type',
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 25e25982..6540a508 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -241,7 +241,7 @@ sub revheader { # type, obj
my($type, $obj) = @_;
b 'Revision '.$obj->{rev};
txt ' (';
- a href => "/$type$obj->{id}?rev=1", 'edit';
+ a href => "/$type$obj->{id}.$obj->{rev}/edit", 'edit';
txt ')';
br;
txt 'By ';