Closes #634.
end
end
+ def reply
+ message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
+ 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
+
def read
@title = 'read message'
@message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
:controller => "message", :action => "read",
:message_id => message.id),
:replyurl => url_for(:host => SERVER_URL,
- :controller => "message", :action => "new",
- :user_id => message.from_user_id)
+ :controller => "message", :action => "reply",
+ :message_id => message.id)
end
def friend_notification(friend)
<% else %>
<td><%= button_to 'Mark as read', :controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'read' %></td>
<% end %>
- <td><%= button_to 'Reply', :controller => 'message', :action => 'new', :user_id => message_summary.from_user_id %></td>
+ <td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => message_summary.id %></td>
</tr>
-<% display_name = (User.find_by_id(params[:user_id])).display_name %>
+<% display_name = User.find_by_id(params[:user_id]).display_name %>
+<% title = params[:message] ? params[:message][:title] : params[:title] %>
<h2>Send a new message to <%= display_name %></h2>
<table>
<tr valign="top">
<th>Subject</th>
- <td><%= f.text_field :title, :size => 60 %></td>
+ <td><%= text_field_tag 'message[title]', title, :size => 60 %></td>
</tr>
<tr valign="top">
<th>Body</th>
<table>
<tr>
- <td><%= button_to 'Reply', :controller => 'message', :action => 'new', :user_id => @message.from_user_id %></td>
+ <td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => @message.id %></td>
<td><%= button_to 'Mark as unread', :controller => 'message', :action => 'mark', :message_id => @message.id, :mark => 'unread' %></td>
<td><%= link_to 'Back to inbox', :controller => 'message', :action => 'inbox', :display_name => @user.display_name %></td>
</tr>
map.connect '/message/new/:user_id', :controller => 'message', :action => 'new'
map.connect '/message/read/:message_id', :controller => 'message', :action => 'read'
map.connect '/message/mark/:message_id', :controller => 'message', :action => 'mark'
-
+ map.connect '/message/reply/:message_id', :controller => 'message', :action => 'reply'
+
# fall through
map.connect ':controller/:id/:action'
map.connect ':controller/:action'