1 class MessageController < ApplicationController
3 # before_filter :authorize
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_display_name = to_user.display_name
18 message.from_user_id = @user.id
19 message.sent_on = Time.now
22 flash[:notice] = 'Message sent'
23 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
25 @message.errors.add("Sending message failed")
32 @title = 'read message'
33 if params[:message_id]
34 id = params[:message_id]
35 @message = Message.find_by_id(id)
41 if @user and params[:display_name] == @user.display_name
43 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
48 if params[:message_id]
49 id = params[:message_id]
50 message = Message.find_by_id(id)
51 message.message_read = 1
53 flash[:notice] = 'Message marked as read'
54 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name