|
|
@ -1854,16 +1854,6 @@ class UsersController < ApplicationController
|
|
|
|
def share_news_to_project
|
|
|
|
def share_news_to_project
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
# project_ids.each do |project_id|
|
|
|
|
|
|
|
|
# if Project.find(project_id).news.map(&:id).exclude?(news.id)
|
|
|
|
|
|
|
|
# project_news = News.create(:project_id => project_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now)
|
|
|
|
|
|
|
|
# news.attachments.each do |attach|
|
|
|
|
|
|
|
|
# project_news.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
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
project = Project.find(project_id)
|
|
|
|
project = Project.find(project_id)
|
|
|
|
if project.news.map(&:id).exclude?(news.id)
|
|
|
|
if project.news.map(&:id).exclude?(news.id)
|
|
|
@ -1889,6 +1879,53 @@ class UsersController < ApplicationController
|
|
|
|
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'News', :org_act_id => org_news.id, :user_id => User.current.id)
|
|
|
|
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'News', :org_act_id => org_news.id, :user_id => User.current.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def share_message_to_course
|
|
|
|
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
|
|
|
|
course_ids = params[:course_ids]
|
|
|
|
|
|
|
|
course_ids.each do |course_id|
|
|
|
|
|
|
|
|
course = Course.find(course_id)
|
|
|
|
|
|
|
|
if course.news.map(&:id).exclude?(@message.id)
|
|
|
|
|
|
|
|
message = Message.create(:board_id => course.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
|
|
|
|
|
|
|
|
@message.attachments.each do |attach|
|
|
|
|
|
|
|
|
message.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
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def share_message_to_project
|
|
|
|
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
|
|
|
|
project = Project.find(project_id)
|
|
|
|
|
|
|
|
if project.news.map(&:id).exclude?(@message.id)
|
|
|
|
|
|
|
|
message = Message.create(:board_id => project.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
|
|
|
|
|
|
|
|
@message.attachments.each do |attach|
|
|
|
|
|
|
|
|
message.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
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def share_message_to_org
|
|
|
|
|
|
|
|
field_id = params[:subfield]
|
|
|
|
|
|
|
|
@message = Message.find(params[:send_id])
|
|
|
|
|
|
|
|
@message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1)
|
|
|
|
|
|
|
|
@message.save
|
|
|
|
|
|
|
|
board = OrgSubfield.find(field_id).boards.first
|
|
|
|
|
|
|
|
mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
def change_org_subfield
|
|
|
|
def change_org_subfield
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -2130,9 +2167,9 @@ class UsersController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif params[:type] == "4" #附件
|
|
|
|
elsif params[:type] == "4" #附件
|
|
|
|
if User.current.id.to_i == params[:id].to_i
|
|
|
|
if User.current.id.to_i == params[:id].to_i
|
|
|
|
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
|
|
|
|
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
|
|
|
|
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif params[:type] == "5" #用户资源
|
|
|
|
elsif params[:type] == "5" #用户资源
|
|
|
|
if User.current.id.to_i == params[:id].to_i
|
|
|
|
if User.current.id.to_i == params[:id].to_i
|
|
|
@ -2238,7 +2275,7 @@ class UsersController < ApplicationController
|
|
|
|
@user = User.current
|
|
|
|
@user = User.current
|
|
|
|
if !params[:search].nil? #发送到有栏目类型为资源的组织中
|
|
|
|
if !params[:search].nil? #发送到有栏目类型为资源的组织中
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
|
if params[:send_type].present? and params[:send_type] == 'news'
|
|
|
|
if params[:send_type].present? and (params[:send_type] == 'news' or params[:send_type] == 'message')
|
|
|
|
@orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Post'").count > 0}
|
|
|
|
@orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Post'").count > 0}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0}
|
|
|
|
@orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0}
|
|
|
|