转发帖子新建帖子,并更新相关表
This commit is contained in:
parent
5334a3d40f
commit
77e0f0cd08
|
@ -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
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
<div class="cl"></div>
|
||||
|
||||
<ul class="copyright mt10">
|
||||
<li class="fl mr30">Copyright © 2007-2015, All Rights Riserved</li>
|
||||
<li class="fl mr30">Copyright © 2007-2015, All Rights Reserved</li>
|
||||
<li>ICP备09019772</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddQuotesToMessages < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :messages, :quotes, :integer
|
||||
end
|
||||
end
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue