1 class MessageController < ApplicationController
4 before_filter :authorize_web
5 before_filter :require_user
8 @title = 'send message'
10 @message = Message.new(params[:message])
11 @message.to_user_id = params[:user_id]
12 @message.from_user_id = @user.id
13 @message.sent_on = Time.now
16 flash[:notice] = 'Message sent'
17 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
23 @title = 'read message'
24 @message = Message.find(params[:message_id], :conditions => ["to_user_id = ?", @user.id])
25 @message.message_read = 1
27 rescue ActiveRecord::RecordNotFound
28 render :nothing => true, :status => :not_found
33 if @user and params[:display_name] == @user.display_name
35 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
40 if params[:message_id]
41 id = params[:message_id]
42 message = Message.find_by_id(id)
43 if params[:mark] == 'unread'
50 message.message_read = message_read
52 flash[:notice] = "Message marked as #{mark_type}"
53 redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name