summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-01-24 09:45:02 +0100
committerYorhel <git@yorhel.nl>2010-01-24 09:45:02 +0100
commitd2dd07de4e0d9b8c00cd2db49aa2e7c0a5150bbc (patch)
tree4fc891330f8d7d513e1d22b1599880da304cdcd0 /lib/VNDB/Util
parent0f35ebbfc2cb4f8da4975ded1331bb80f408ccad (diff)
Versioned the deleting and locking of database entries
This is implemented by adding ihid (item hidden) and ilock (item locked) columns to the changes table, The (vn|release|producer).(hidden|locked) columns now work as a cache, refering to the changes.(ihid|ilock) columns with changes.id = (vn|release|producer).latest. The cached columns are updated automatically each time a new revision is inserted. This is a pretty large change, bugs are quite likely.
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r--lib/VNDB/Util/CommonHTML.pm26
-rw-r--r--lib/VNDB/Util/FormHTML.pm14
2 files changed, 25 insertions, 15 deletions
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 79330272..924c91fd 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -83,18 +83,6 @@ sub htmlMainTabs {
end;
}
- if($type =~ /[vrp]/ && $self->authCan('del')) {
- li;
- a href => "/$id/hide", mt $obj->{hidden} ? '_mtabs_unhide' : '_mtabs_hide';
- end;
- }
-
- if($type =~ /[vrp]/ && $self->authCan('lock')) {
- li;
- a href => "/$id/lock", mt $obj->{locked} ? '_mtabs_unlock' : '_mtabs_lock';
- end;
- }
-
if($type eq 'u' && $self->authCan('usermod')) {
li $sel eq 'del' ? (class => 'tabselected') : ();
a href => "/$id/del", mt '_mtabs_del';
@@ -141,12 +129,18 @@ sub htmlHiddenMessage {
my($self, $type, $obj) = @_;
return 0 if !$obj->{hidden};
my $board = $type eq 'r' ? 'v'.$obj->{vn}[0]{vid} : $type.$obj->{id};
+ # fetch edit summary (not present in $obj because the changes aren't fetched)
+ my $editsum = $type eq 'v' ? $self->dbVNGet(id => $obj->{id}, what => 'changes')->[0]{comments}
+ : $type eq 'r' ? $self->dbReleaseGet(id => $obj->{id}, what => 'changes')->[0]{comments}
+ : $self->dbProducerGet(id => $obj->{id}, what => 'changes')->[0]{comments};
div class => 'mainbox';
h1 $obj->{title}||$obj->{name};
div class => 'warning';
h2 mt '_hiddenmsg_title';
p;
lit mt '_hiddenmsg_msg', "/t/$board";
+ br; br;
+ lit bb2html $editsum;
end;
end;
end;
@@ -209,7 +203,11 @@ sub htmlRevision {
end;
end;
my $i = 1;
- revdiff(\$i, $type, $old, $new, @$_) for (@fields);
+ revdiff(\$i, $type, $old, $new, @$_) for (
+ [ ihid => serialize => sub { mt $_[0] ? '_revision_yes' : '_revision_no' } ],
+ [ ilock => serialize => sub { mt $_[0] ? '_revision_yes' : '_revision_no' } ],
+ @fields
+ );
end;
}
end;
@@ -262,7 +260,7 @@ sub revdiff {
$ser2 = mt '_revision_empty' if !$ser2 && $ser2 ne '0';
Tr $$i++ % 2 ? (class => 'odd') : ();
- td mt "_revfield_${type}_$short";
+ td mt $short eq 'ihid' || $short eq 'ilock' ? "_revfield_$short" : "_revfield_${type}_$short";
td class => 'tcval'; lit $ser1; end;
td class => 'tcval'; lit $ser2; end;
end;
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index 2882b4c4..cfac77b9 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -209,11 +209,23 @@ sub htmlForm {
end;
}
- # edit summary / submit button
+ # db mod / edit summary / submit button
if(!$options->{nosubmit}) {
div class => 'mainbox';
fieldset class => 'submit';
if($options->{editsum}) {
+ # hidden / locked checkbox
+ if($self->authCan('del')) {
+ input type => 'checkbox', name => 'ihid', id => 'ihid', value => 1, $options->{frm}{ihid} ? (checked => 'checked') : ();
+ label for => 'ihid', mt '_form_ihid';
+ }
+ if($self->authCan('lock')) {
+ input type => 'checkbox', name => 'ilock', id => 'ilock', value => 1, $options->{frm}{ilock} ? (checked => 'checked') : ();
+ label for => 'ilock', mt '_form_ilock';
+ }
+ txt "\n".mt('_form_hidlock_note')."\n" if $self->authCan('lock') || $self->authCan('del');
+
+ # edit summary
(my $txt = $options->{frm}{editsum}||'') =~ s/&/&amp;/;
$txt =~ s/</&lt;/;
$txt =~ s/>/&gt;/;