From: Gabriel Ebner Date: Sat, 3 May 2008 14:11:23 +0000 (+0000) Subject: split_node_tags: Merge changes from main branch. X-Git-Tag: live~8130^2~388 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/7eb181999d3357bf210ceb24e18c913bf3ef6ba3?hp=-c split_node_tags: Merge changes from main branch. --- 7eb181999d3357bf210ceb24e18c913bf3ef6ba3 diff --combined app/controllers/message_controller.rb index 9dc1d6922,8aecef98e..395d56028 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@@ -20,10 -20,24 +20,22 @@@ class MessageController < ApplicationCo end end + def destroy + @message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ]) + if !@message.message_read + flash[:notice] = 'Message not read and so not deleted' + redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + else + flash[:notice] = "Message '#{@message.title}' deleted" + @message.destroy + redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + end + end + def reply message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ]) - @body = "\n\nOn #{message.sent_on} #{message.sender.display_name} wrote:\n #{message.body}" - @title = "Re: #{message.title}" - @user_id = message.from_user_id - render :action => 'new' + title = message.title.sub(/^Re:\s*/, "Re: ") + redirect_to :action => 'new', :user_id => message.from_user_id, :title => title rescue ActiveRecord::RecordNotFound render :nothing => true, :status => :not_found end