+
+ @message ||= Message.new(:recipient => @this_user)
+ @title = t "message.new.title"
+ end
+
+ # Allow the user to reply to another message.
+ def reply
+ message = Message.find(params[:message_id])
+
+ if message.to_user_id == @user.id
+ message.update(:message_read => true)
+
+ @message = Message.new(
+ :recipient => message.sender,
+ :title => "Re: #{message.title.sub(/^Re:\s*/, '')}",
+ :body => "On #{message.sent_on} #{message.sender.display_name} wrote:\n\n#{message.body.gsub(/^/, '> ')}"
+ )
+
+ @title = @message.title
+
+ render :action => "new"
+ else
+ flash[:notice] = t "message.reply.wrong_user", :user => @user.display_name
+ redirect_to :controller => "user", :action => "login", :referer => request.fullpath
+ end
+ rescue ActiveRecord::RecordNotFound
+ @title = t "message.no_such_message.title"
+ render :action => "no_such_message", :status => :not_found