diff options
author | francis <francis> | 2008-03-12 13:01:04 +0000 |
---|---|---|
committer | francis <francis> | 2008-03-12 13:01:04 +0000 |
commit | facda1bfffb9d91da6a2f2e22b2345590e452f96 (patch) | |
tree | 200b6ace27d3c6bbde73644cb3bdfe65a4c07928 /app/controllers/user_controller.rb | |
parent | 7639ebcc9f5f0eba90f6e05d5e22e03a21102703 (diff) |
Form for contacting other users.
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r-- | app/controllers/user_controller.rb | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index edde31749..7be9fa963 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user_controller.rb,v 1.35 2008-03-06 14:15:41 francis Exp $ +# $Id: user_controller.rb,v 1.36 2008-03-12 13:01:04 francis Exp $ class UserController < ApplicationController # Show page about a set of users with same url name @@ -165,6 +165,46 @@ class UserController < ApplicationController end end + # Send a message to another user + def contact + @recipient_user = User.find(params[:id]) + + # You *must* be logged into send a message to another user. (This is + # partly to avoid spam, and partly to have some equanimity of openess + # between the two users) + if not authenticated?( + :web => "To send a message to " + CGI.escapeHTML(@recipient_user.name), + :email => "Then you can send a message to " + @recipient_user.name + ".", + :email_subject => "Send a message to " + @recipient_user.name + ) + # "authenticated?" has done the redirect to signin page for us + return + end + + if params[:submitted_contact_form] + params[:contact][:name] = @user.name + params[:contact][:email] = @user.email + @contact = ContactValidator.new(params[:contact]) + if @contact.valid? + ContactMailer.deliver_user_message( + @user, + @recipient_user, + main_url(user_url(@recipient_user)), + params[:contact][:subject], + params[:contact][:message] + ) + flash[:notice] = "Your message to " + CGI.escapeHTML(@recipient_user.name) + " has been sent!" + redirect_to user_url(@recipient_user) + return + end + else + @contact = ContactValidator.new( + { :message => "" + @recipient_user.name + ",\n\n\n\nYours,\n\n" + @user.name } + ) + end + + end + private |