1 class MessageController < ApplicationController
4 before_filter :authorize_web
5 before_filter :require_user
8 @title = 'send message'
10 to_user = User.find(params[:user_id])
11 body = params[:message][:body]
12 title = params[:message][:title]
16 message.to_user_id = params[:user_id]
17 message.from_user_id = @user.id
18 message.sent_on = Time.now
21 flash[:notice] = 'Message sent'
22 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
24 @message.errors.add("Sending message failed")
31 @title = 'read message'
32 if params[:message_id]
33 id = params[:message_id]
34 @message = Message.find_by_id(id)
40 if @user and params[:display_name] == @user.display_name
42 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
47 if params[:message_id]
48 id = params[:message_id]
49 message = Message.find_by_id(id)
50 message.message_read = 1
52 flash[:notice] = 'Message marked as read'
53 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name