diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b9fe14aba..f4ad88757 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -316,13 +316,22 @@ class MessagesController < ApplicationController # @message.update_attribute(:updated_on, Time.now) type = @message.board.course_id.nil? ? "Project":"Course" org_subfield_ids.each do |field_id| - OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => @message.id, :message_type => type) - org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id) - if org_acts.all.size() > 0 - org_acts.first.update_attribute(:updated_at, Time.now) - else - OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => @message.id, :user_id => User.current.id) + @message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1) + @message.save + mes = Message.create(:board_id => @message.board_id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id, + :created_on => Time.now, :updated_on => Time.now, :locked => @message.locked, :sticky => @message.sticky) + @message.attachments.each do |attach| + mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) end + OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => mes.id, :message_type => type) + # org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id) + # if org_acts.all.size() > 0 + # org_acts.first.update_attribute(:updated_at, Time.now) + # else + OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => mes.id, :user_id => User.current.id) + # end end end diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 4ece1ba8c..808e80239 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -161,7 +161,7 @@