their INBOX so they no longer see it.
@title = t'message.no_such_user.title'
render :action => 'no_such_user', :status => :not_found
end
+
+ # Delete the message.
+ def delete
+ if params[:message_id]
+ id = params[:message_id]
+ message = Message.find_by_id(id)
+ message.visible = false
+ if message.save
+ flash[:notice] = t 'message.delete.deleted'
+ redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
+ end
+ end
+ rescue ActiveRecord::RecordNotFound
+ @title = t'message.no_such_user.title'
+ render :action => 'no_such_user', :status => :not_found
+ end
end
-
has_many :traces
has_many :diary_entries, :order => 'created_at DESC'
- has_many :messages, :foreign_key => :to_user_id, :order => 'sent_on DESC'
- has_many :new_messages, :class_name => "Message", :foreign_key => :to_user_id, :conditions => {:message_read => false}, :order => 'sent_on DESC'
+ has_many :messages, :foreign_key => :to_user_id, :conditions => { :visible => true }, :order => 'sent_on DESC'
+ has_many :new_messages, :class_name => "Message", :foreign_key => :to_user_id, :conditions => { :message_read => false }, :order => 'sent_on DESC'
has_many :sent_messages, :class_name => "Message", :foreign_key => :from_user_id, :order => 'sent_on DESC'
has_many :friends, :include => :befriendee, :conditions => ["users.visible = ?", true]
has_many :tokens, :class_name => "UserToken"
<td><%= button_to t('message.message_summary.read_button'), :controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'read' %></td>
<% end %>
<td><%= button_to t('message.message_summary.reply_button'), :controller => 'message', :action => 'reply', :message_id => message_summary.id %></td>
+ <td><%= button_to t('message.message_summary.delete_button'), :controller => 'message', :action => 'delete', :message_id => message_summary.id %></td>
</tr>
<th><%= t'message.inbox.date' %></th>
<th></th>
<th></th>
+ <th></th>
</tr>
<%= render :partial => "message_summary", :collection => @user.messages %>
</table>
unread_button: "Mark as unread"
read_button: "Mark as read"
reply_button: "Reply"
+ delete_button: "Delete"
new:
title: "Send message"
send_message_to: "Send a new message to {{name}}"
mark:
as_read: "Message marked as read"
as_unread: "Message marked as unread"
+ delete:
+ deleted: "Message deleted"
site:
index:
js_1: "You are either using a browser that doesn't support javascript, or you have disabled javascript."
map.connect '/message/read/:message_id', :controller => 'message', :action => 'read'
map.connect '/message/mark/:message_id', :controller => 'message', :action => 'mark'
map.connect '/message/reply/:message_id', :controller => 'message', :action => 'reply'
+ map.connect '/message/delete/:message_id', :controller => 'message', :action => 'delete'
# fall through
map.connect ':controller/:id/:action'
--- /dev/null
+class AddVisibleToMessage < ActiveRecord::Migration
+ def self.up
+ add_column :messages, :visible, :boolean, :default => true, :null => false
+ end
+
+ def self.down
+ remove_column :messages, :visible
+ end
+end