From 1009f7ac073f1fc9c3f0ab892a7b97fcbbe38781 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 3 Apr 2015 16:35:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B5=84=E6=BA=90id=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/comments_controller.rb | 6 ++++-- app/controllers/forums_controller.rb | 12 ++++++++---- app/controllers/messages_controller.rb | 13 ++++++++----- app/controllers/news_controller.rb | 6 ++++-- app/controllers/words_controller.rb | 6 ++++-- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 0d1c39104..bb84b1fa4 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -30,8 +30,10 @@ class CommentsController < ApplicationController @comment.comments = 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] From 84c2e39e6c6642ceda85c296fed9581f5482dcfe Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 3 Apr 2015 17:06:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E9=97=BB=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=94=99=E8=AF=AF=E3=80=82=E8=AF=AF=E5=B0=86?= =?UTF-8?q?safe=5Fattributes=E6=8D=A2=E4=B8=BA=E7=9B=B4=E6=8E=A5=E5=B1=9E?= =?UTF-8?q?=E6=80=A7comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/comments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index bb84b1fa4..57ad9d4ce 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -27,7 +27,7 @@ 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 if params[:asset_id]