Project

General

Profile

Feature #854 » own_message_edit.patch

enable editing of own posts - Jan Losinski, 2008-09-15 23:50

View differences:

controllers/messages_controller.rb (Arbeitskopie)
menu_item :boards
before_filter :find_board, :only => [:new, :preview]
before_filter :find_message, :except => [:new, :preview]
before_filter :authorize, :except => :preview
before_filter :authorize, :except => [:preview, :edit]
before_filter :authorize_edit, :only => :edit
verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show }
verify :xhr => true, :only => :quote
......
rescue ActiveRecord::RecordNotFound
render_404
end
def authorize_edit
authorize if @message.author != User.current
end
end
views/messages/show.rhtml (Arbeitskopie)
<a name="<%= "message-#{message.id}" %>"></a>
<div class="contextual">
<%= link_to_remote_if_authorized image_tag('comment.png'), { :url => {:action => 'quote', :id => message} }, :title => l(:button_quote) %>
<%= link_to_if_authorized image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit) %>
<%= (link_to_if_authorized image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit)) ||
(link_to image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit) if message.author == User.current) %>
<%= link_to_if_authorized image_tag('delete.png'), {:action => 'destroy', :id => message}, :method => :post, :confirm => l(:text_are_you_sure), :title => l(:button_delete) %>
</div>
<div class="message reply">
(1-1/2)