Commit 0da7313fcbe71dda99b5a41dd6a7bbf9f2a2d804
1 parent
575c695e
Exists in
master
and in
29 other branches
[tolerance-time] Filtering access to edit_comment action after expiration
Showing
1 changed file
with
16 additions
and
0 deletions
Show diff stats
plugins/tolerance_time/lib/tolerance_time_plugin.rb
| ... | ... | @@ -41,6 +41,22 @@ class ToleranceTimePlugin < Noosfero::Plugin |
| 41 | 41 | :block => block } |
| 42 | 42 | end |
| 43 | 43 | |
| 44 | + def content_viewer_controller_filters | |
| 45 | + return if !context.environment.plugin_enabled?(ToleranceTimePlugin) | |
| 46 | + block = lambda do | |
| 47 | + content = Comment.find(params[:id]) | |
| 48 | + if ToleranceTimePlugin.expired?(content) | |
| 49 | + session[:notice] = _('This content can\'t be edited anymore because it expired the tolerance time') | |
| 50 | + redirect_to content.article.url | |
| 51 | + end | |
| 52 | + end | |
| 53 | + | |
| 54 | + { :type => 'before_filter', | |
| 55 | + :method_name => 'expired_content', | |
| 56 | + :options => {:only => 'edit_comment'}, | |
| 57 | + :block => block } | |
| 58 | + end | |
| 59 | + | |
| 44 | 60 | def content_expire_edit(content) |
| 45 | 61 | if ToleranceTimePlugin.expired?(content) |
| 46 | 62 | _('The tolerance time for editing this content is over.') | ... | ... |