From f7ad600dde20ac930f4524508061756bae417668 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 8 May 2015 15:02:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=B8=96=E5=AD=90=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 55 +++++++------------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index fd1266095..431577f9a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -93,15 +93,7 @@ class MessagesController < ApplicationController end call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) render_attachment_warning_if_needed(@message) - if params[:is_board] - if @project - redirect_to project_boards_path(@project) - elsif @course - redirect_to course_boards_path(@course) - end - else - redirect_to board_message_url(@board, @message) - end + redirect_to board_message_url(@board, @message) else layout_file = @project ? 'base_projects' : 'base_courses' render :action => 'new', :layout => layout_file @@ -131,24 +123,17 @@ class MessagesController < ApplicationController #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? if params[:asset_id] - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE end call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) render_attachment_warning_if_needed(@reply) - else - #render file: 'messages#show', layout: 'base_courses' - end - if params[:is_board] - if @project - redirect_to project_boards_path(@project) - elsif @course - redirect_to course_boards_path(@course) - end else - redirect_to board_message_url(@board, @topic, :r => @reply) + #render file: 'messages#show', layout: 'base_courses' end + redirect_to board_message_url(@board, @topic, :r => @reply) + end # Edit a message @@ -165,15 +150,7 @@ class MessagesController < ApplicationController render_attachment_warning_if_needed(@message) flash[:notice] = l(:notice_successful_update) @message.reload - if params[:is_board] - if @project - redirect_to project_boards_path(@project) - elsif @course - redirect_to course_boards_path(@course) - end - else - redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)) - end + redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)) elsif request.get? respond_to do |format| format.html { @@ -195,20 +172,16 @@ class MessagesController < ApplicationController @message.destroy # modify by nwb if @project - if params[:is_board] - redirect_to project_boards_url(@project) + if @message.parent + redirect_to board_message_url(@board, @message.parent, :r => r) else - redirect_to board_message_url(@board, @topic, :r => @reply) + redirect_to project_boards_url(@project) end elsif @course - if params[:is_board] - redirect_to course_boards_url(@course) + if @message.parent + redirect_to board_message_url(@board, @message.parent, :r => r) else - if @message.parent - redirect_to board_message_url(@board, @message.parent, :r => r) - else - redirect_to course_board_url(@course, @board) - end + redirect_to course_board_url(@course, @board) end end end @@ -229,7 +202,7 @@ class MessagesController < ApplicationController render :partial => 'common/preview' end -private + private def find_message return unless find_board @message = @board.messages.find(params[:id], :include => :parent)