Feature #854 » own_message_edit.patch
controllers/messages_controller.rb (Arbeitskopie) | ||
---|---|---|
19 | 19 |
menu_item :boards |
20 | 20 |
before_filter :find_board, :only => [:new, :preview] |
21 | 21 |
before_filter :find_message, :except => [:new, :preview] |
22 |
before_filter :authorize, :except => :preview |
|
22 |
before_filter :authorize, :except => [:preview, :edit] |
|
23 |
before_filter :authorize_edit, :only => :edit |
|
23 | 24 | |
24 | 25 |
verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show } |
25 | 26 |
verify :xhr => true, :only => :quote |
... | ... | |
120 | 121 |
rescue ActiveRecord::RecordNotFound |
121 | 122 |
render_404 |
122 | 123 |
end |
124 | ||
125 |
def authorize_edit |
|
126 |
authorize if @message.author != User.current |
|
127 |
end |
|
123 | 128 |
end |
views/messages/show.rhtml (Arbeitskopie) | ||
---|---|---|
24 | 24 |
<a name="<%= "message-#{message.id}" %>"></a> |
25 | 25 |
<div class="contextual"> |
26 | 26 |
<%= link_to_remote_if_authorized image_tag('comment.png'), { :url => {:action => 'quote', :id => message} }, :title => l(:button_quote) %> |
27 |
<%= link_to_if_authorized image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit) %> |
|
27 |
<%= (link_to_if_authorized image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit)) || |
|
28 |
(link_to image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit) if message.author == User.current) %> |
|
28 | 29 |
<%= link_to_if_authorized image_tag('delete.png'), {:action => 'destroy', :id => message}, :method => :post, :confirm => l(:text_are_you_sure), :title => l(:button_delete) %> |
29 | 30 |
</div> |
30 | 31 |
<div class="message reply"> |