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 @@
diff --git a/db/migrate/20151229022049_add_quotes_to_messages.rb b/db/migrate/20151229022049_add_quotes_to_messages.rb new file mode 100644 index 000000000..6311f0231 --- /dev/null +++ b/db/migrate/20151229022049_add_quotes_to_messages.rb @@ -0,0 +1,5 @@ +class AddQuotesToMessages < ActiveRecord::Migration + def change + add_column :messages, :quotes, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 6448833c6..72ca3c649 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151223062932) do +ActiveRecord::Schema.define(:version => 20151229022049) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1045,6 +1045,7 @@ ActiveRecord::Schema.define(:version => 20151223062932) do t.boolean "locked", :default => false t.integer "sticky", :default => 0 t.integer "reply_id" + t.integer "quotes" end add_index "messages", ["author_id"], :name => "index_messages_on_author_id"