资源id判空

This commit is contained in:
lizanle 2015-04-03 16:35:46 +08:00
parent 5299d2d332
commit 1009f7ac07
5 changed files with 28 additions and 15 deletions

View File

@ -30,8 +30,10 @@ class CommentsController < ApplicationController
@comment.comments = params[:comment] @comment.comments = params[:comment]
@comment.author = User.current @comment.author = User.current
if @news.comments << @comment if @news.comments << @comment
ids = params[:asset_id].split(',') if params[:asset_id]
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
end
flash[:notice] = l(:label_comment_added) flash[:notice] = l(:label_comment_added)
end end

View File

@ -63,8 +63,10 @@ class ForumsController < ApplicationController
respond_to do |format| respond_to do |format|
if @memo.save if @memo.save
ids = params[:asset_id].split(',') if params[:asset_id]
update_kindeditor_assets_owner ids ,@memo.id,OwnerTypeHelper::MEMO ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@memo.id,OwnerTypeHelper::MEMO
end
#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.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 } format.json { render json: @memo, status: :created, location: @memo }
@ -170,8 +172,10 @@ class ForumsController < ApplicationController
# Author lizanle # Author lizanle
# Description after save后需要进行资源记录的更新 # Description after save后需要进行资源记录的更新
# owner_type = 2 对应的是 forum # owner_type = 2 对应的是 forum
ids = params[:asset_id].split(',') if params[:asset_id]
update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM
end
#end #end
respond_to do |format| respond_to do |format|

View File

@ -87,9 +87,10 @@ class MessagesController < ApplicationController
@message.save_attachments(params[:attachments]) @message.save_attachments(params[:attachments])
if @message.save if @message.save
# 更新kindeditor上传的图片资源所有者 # 更新kindeditor上传的图片资源所有者
ids = params[:asset_id].split(',') if params[:asset_id]
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE 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}) call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@message) render_attachment_warning_if_needed(@message)
redirect_to board_message_url(@board, @message) redirect_to board_message_url(@board, @message)
@ -121,8 +122,10 @@ class MessagesController < ApplicationController
@topic.children << @reply @topic.children << @reply
#@topic.update_attribute(:updated_on, Time.now) #@topic.update_attribute(:updated_on, Time.now)
if !@reply.new_record? if !@reply.new_record?
ids = params[:asset_id].split(',') if params[:asset_id]
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}) call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments]) attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply) render_attachment_warning_if_needed(@reply)

View File

@ -137,8 +137,10 @@ class NewsController < ApplicationController
@news.safe_attributes = params[:news] @news.safe_attributes = params[:news]
@news.save_attachments(params[:attachments]) @news.save_attachments(params[:attachments])
if @news.save if @news.save
ids = params[:asset_id].split(',') if params[:asset_id]
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
end
render_attachment_warning_if_needed(@news) render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to course_news_index_url(@course) redirect_to course_news_index_url(@course)

View File

@ -209,8 +209,10 @@ class WordsController < ApplicationController
message = params[:new_form][:course_message] message = params[:new_form][:course_message]
feedback = Course.add_new_jour(user, message, params[:id]) feedback = Course.add_new_jour(user, message, params[:id])
if(feedback.errors.empty?) if(feedback.errors.empty?)
ids = params[:asset_id].split(',') if params[:asset_id]
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE 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) redirect_to course_feedback_url(params[:id]), notice: l(:label_feedback_success)
else else
flash[:error] = feedback.errors.full_messages[0] flash[:error] = feedback.errors.full_messages[0]