|
|
|
@ -89,72 +89,54 @@ class MessagesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# Create a new topic
|
|
|
|
|
def new
|
|
|
|
|
@message = Message.new
|
|
|
|
|
@message.author = User.current
|
|
|
|
|
@message.board = @board
|
|
|
|
|
@message.safe_attributes = params[:message]
|
|
|
|
|
if request.post?
|
|
|
|
|
@message.save_attachments(params[:attachments])
|
|
|
|
|
if @message.save
|
|
|
|
|
# 更新kindeditor上传的图片资源所有者
|
|
|
|
|
if params[:asset_id]
|
|
|
|
|
ids = params[:asset_id].split(',')
|
|
|
|
|
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
|
|
|
|
end
|
|
|
|
|
# # 与我相关动态的记录add start
|
|
|
|
|
# if(@board && @board.course) #项目的先不管
|
|
|
|
|
# teachers = searchTeacherAndAssistant(@board.course)
|
|
|
|
|
# for teacher in teachers
|
|
|
|
|
# if(teacher.user_id != User.current.id)
|
|
|
|
|
# notify = ActivityNotify.new()
|
|
|
|
|
# if(@board.course)
|
|
|
|
|
# notify.activity_container_id = @board.course_id
|
|
|
|
|
# notify.activity_container_type = 'Course'
|
|
|
|
|
# else
|
|
|
|
|
# notify.activity_container_id = @board.project_id
|
|
|
|
|
# notify.activity_container_type = 'Project'
|
|
|
|
|
# end
|
|
|
|
|
# notify.activity_id = @message.id
|
|
|
|
|
# notify.activity_type = 'Message'
|
|
|
|
|
# notify.notify_to = teacher.user_id
|
|
|
|
|
# notify.is_read = 0
|
|
|
|
|
# notify.save()
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# 与我相关动态的记录add end
|
|
|
|
|
if User.current.logged?
|
|
|
|
|
@message = Message.new
|
|
|
|
|
@message.author = User.current
|
|
|
|
|
@message.board = @board
|
|
|
|
|
@message.safe_attributes = params[:message]
|
|
|
|
|
if request.post?
|
|
|
|
|
@message.save_attachments(params[:attachments])
|
|
|
|
|
if @message.save
|
|
|
|
|
# 更新kindeditor上传的图片资源所有者
|
|
|
|
|
if params[:asset_id]
|
|
|
|
|
ids = params[:asset_id].split(',')
|
|
|
|
|
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
|
|
|
|
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)
|
|
|
|
|
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
|
|
|
|
|
else
|
|
|
|
|
redirect_to board_message_url(@board, @message)
|
|
|
|
|
if params[:is_board]
|
|
|
|
|
if @project
|
|
|
|
|
redirect_to project_boards_path(@project, :flag => true)
|
|
|
|
|
elsif @course
|
|
|
|
|
redirect_to course_boards_path(@course, :flag => true)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
layout_file = @project ? 'base_projects' : 'base_courses'
|
|
|
|
|
render :action => 'new', :layout => layout_file
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if params[:is_board]
|
|
|
|
|
if @project
|
|
|
|
|
redirect_to project_boards_path(@project, :flag => true)
|
|
|
|
|
elsif @course
|
|
|
|
|
redirect_to course_boards_path(@course, :flag => true)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
layout_file = @project ? 'base_projects' : 'base_courses'
|
|
|
|
|
render :action => 'new', :layout => layout_file
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html {
|
|
|
|
|
layout_file = @project ? 'base_projects' : 'base_courses'
|
|
|
|
|
render :layout => layout_file
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html {
|
|
|
|
|
layout_file = @project ? 'base_projects' : 'base_courses'
|
|
|
|
|
render :layout => layout_file
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
redirect_to signin_path
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|