diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 0d1c39104..57ad9d4ce 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -27,11 +27,13 @@ class CommentsController < ApplicationController raise Unauthorized unless @news.commentable? @comment = Comment.new - @comment.comments = params[:comment] + @comment.safe_attributes = params[:comment] @comment.author = User.current if @news.comments << @comment - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT + end flash[:notice] = l(:label_comment_added) end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index f59704a62..253e1d28d 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -63,8 +63,10 @@ class ForumsController < ApplicationController respond_to do |format| if @memo.save - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids ,@memo.id,OwnerTypeHelper::MEMO + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids ,@memo.id,OwnerTypeHelper::MEMO + end #end format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" } format.json { render json: @memo, status: :created, location: @memo } @@ -170,8 +172,10 @@ class ForumsController < ApplicationController # Author lizanle # Description after save后需要进行资源记录的更新 # owner_type = 2 对应的是 forum - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM + end #end respond_to do |format| diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 2ad388f41..c58ebf851 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -87,9 +87,10 @@ class MessagesController < ApplicationController @message.save_attachments(params[:attachments]) if @message.save # 更新kindeditor上传的图片资源所有者 - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE - + 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) redirect_to board_message_url(@board, @message) @@ -121,8 +122,10 @@ class MessagesController < ApplicationController @topic.children << @reply #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE + if params[:asset_id] + 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) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 27c4aa37f..d41491349 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -137,8 +137,10 @@ class NewsController < ApplicationController @news.safe_attributes = params[:news] @news.save_attachments(params[:attachments]) if @news.save - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS + end render_attachment_warning_if_needed(@news) flash[:notice] = l(:notice_successful_create) redirect_to course_news_index_url(@course) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index de2fbc732..680a13963 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -209,8 +209,10 @@ class WordsController < ApplicationController message = params[:new_form][:course_message] feedback = Course.add_new_jour(user, message, params[:id]) if(feedback.errors.empty?) - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE + end redirect_to course_feedback_url(params[:id]), notice: l(:label_feedback_success) else flash[:error] = feedback.errors.full_messages[0]