diff options
author | Yorhel <git@yorhel.nl> | 2015-02-03 11:22:41 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-02-03 11:22:41 +0100 |
commit | c0f9cafbe7f7b5d9b2f2a6458c6ef0986de3d2c8 (patch) | |
tree | b51b5e87ea696110ab2558499681cfe2b57874f3 /lib | |
parent | 76548db77ef061f22c4b0d82a3f7affc2ca695f3 (diff) |
Disallow editing your own post after one week
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/Handler/Discussions.pm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm index e1645fd5..755d14c9 100644 --- a/lib/VNDB/Handler/Discussions.pm +++ b/lib/VNDB/Handler/Discussions.pm @@ -19,6 +19,13 @@ TUWF::register( ); +sub caneditpost { + my($self, $post) = @_; + return $self->authCan('boardmod') || + ($self->authInfo->{id} && $post->{uid} == $self->authInfo->{id} && !$post->{hidden} && time()-$post->{date} < $self->{board_edit_time}) +} + + sub thread { my($self, $tid, $page) = @_; $page ||= 1; @@ -63,7 +70,7 @@ sub thread { } end; td class => 'tc2'; - if($self->authCan('boardmod') || $self->authInfo->{id} && $_->{uid} == $self->authInfo->{id} && !$_->{hidden}) { + if(caneditpost($self, $_)) { i class => 'edit'; txt '< '; a href => "/t$tid.$_->{num}/edit", mt '_thread_editpost'; @@ -149,8 +156,7 @@ sub edit { # are we allowed to perform this action? return $self->htmlDenied if !$self->authCan('board') || ($tid && ($t->{locked} || $t->{hidden}) && !$self->authCan('boardmod')) - || ($num && $p->{uid} != $self->authInfo->{id} && !$self->authCan('boardmod')) - || ($num && $p->{hidden} && !$self->authCan('boardmod')); + || ($num && !caneditpost($self, $p)); # check form etc... my $frm; |