[Jifty-commit] r5550 - jifty/trunk/lib/Jifty/Plugin
Jifty commits
jifty-commit at lists.jifty.org
Tue Jul 15 10:59:45 EDT 2008
Author: yves
Date: Tue Jul 15 10:59:41 2008
New Revision: 5550
Modified:
jifty/trunk/lib/Jifty/Plugin/Comment.pm
Log:
Update synopsys on plugin::comment,
triggers are needed on Model::Comment and Model::FooComment and callback need to return 'allow' or 'deny'
Modified: jifty/trunk/lib/Jifty/Plugin/Comment.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Comment.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Comment.pm Tue Jul 15 10:59:41 2008
@@ -51,20 +51,27 @@
use Jifty::Plugin::Comment::Mixin::Model::Commented;
- App::Model::FoobleComment->add_trigger( before_access => sub {
+ sub allow_owner_update_delete {
my $self = shift;
my ($right, %args) = @_;
if ($right eq 'create') {
- return 1 if $self->current_user->id;
+ return 'allow' ;#if $self->current_user->id;
+ }
+
+ if ($right eq 'update' || $right eq 'delete') {
+ return 'allow' if $self->current_user->id;
}
if ($right eq 'read') {
- return 1;
+ return 'allow';
}
- return $self->App::Model::FoobleComment::current_user_can(@_);
- });
+ return 'deny';
+ };
+
+ App::Model::FoobleComment->add_trigger( name => 'before_access', callback => \&allow_owner_update_delete);
+ App::Model::Comment->add_trigger( name => 'before_access', callback => \&allow_owner_update_delete);
Setup a view for creating, viewing, and managing the comments:
More information about the Jifty-commit
mailing list