Sha256: 977d47afb5c899f89f98fbce8245fcfee9734076bbb706a1193d46138b754cdb
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
# Copyright © 2012 The Pennsylvania State University # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class MailboxController < ApplicationController before_filter :authenticate_user! def index if current_user inbox = current_user.mailbox.inbox @messages = inbox.all current_user.mark_as_read @messages else @messages =[] end end def delete_all current_user.mailbox.inbox.each do |msg| delete_message(msg) end empty_trash(current_user) redirect_to mailbox_path end def delete if (current_user) msg = Conversation.find(params[:uid]) if (msg.participants[0] == current_user) || (msg.participants[1] == current_user) delete_message(msg) empty_trash(msg.participants[0]) end else flash[:alert] = "You do not have privileges to delete the notification..." end redirect_to mailbox_path end private def delete_message (msg) msg.move_to_trash(msg.participants[0]) msg.move_to_trash(msg.participants[1]) end def empty_trash (user) user.mailbox.trash.each { |conv| conv.messages.each {|notify| notify.receipts.each { |receipt| receipt.delete}; notify.delete}; conv.delete} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sufia-0.0.1.pre1 | app/controllers/mailbox_controller.rb |