diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index 4e3286700..514903e93 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -302,7 +302,7 @@ class OrganizationsController < ApplicationController
def org_resources_subfield
@org = Organization.find(params[:id])
- 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')
@subfield = @org.org_subfields.where("field_type = 'Post'")
else
@subfield = @org.org_subfields.where('field_type = "Resource" ')
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 38d148907..84f7d44c4 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1791,16 +1791,6 @@ class UsersController < ApplicationController
def share_news_to_project
news = News.find(params[:send_id])
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 = Project.find(project_id)
if project.news.map(&:id).exclude?(news.id)
@@ -1826,6 +1816,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)
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
end
@@ -2175,7 +2212,7 @@ class UsersController < ApplicationController
@user = User.current
if !params[:search].nil? #发送到有栏目类型为资源的组织中
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}
else
@orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0}
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index 8cb547b13..d4d12232e 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -185,20 +185,6 @@
}
-
- function org_id_click(){
- var sendText = $("input[name='org_id']:checked").next().text();
- var orgDirection = "目标地址:"
- $(".orgDirection").text(orgDirection + sendText);
- }
- function subfield_click(){
- var sendText = $("input[name='org_id']:checked").next().text();
- var orgDirection = "目标地址:"
- var sendColumn = $("input[name='subfield']:checked").next().text();
- $(".orgDirection").text(orgDirection + sendText + " / " + sendColumn);
- }
-
-
function course_attachmenttypes_change(id, type) {
<% if @course%>
$.ajax({
diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb
index c3278a209..ce2f6e085 100644
--- a/app/views/messages/_course_show.html.erb
+++ b/app/views/messages/_course_show.html.erb
@@ -60,7 +60,7 @@
) if @message.course_destroyable_by?(User.current) %>
<% end %>
-
<% if activity.parent_id.nil? %>
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb
index 5abd08224..8a7c6d4cd 100644
--- a/app/views/users/_course_message.html.erb
+++ b/app/views/users/_course_message.html.erb
@@ -71,9 +71,7 @@
) if activity.course_destroyable_by?(User.current) %>
<% end %>
-
- <%= link_to "发送",messages_join_org_subfield_path(:message_id => activity.id) , :remote=> true,:class => 'postOptionLink' %>
-
+
<%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %>
diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb
index d4a7a9e60..ec36854cb 100644
--- a/app/views/users/_project_message.html.erb
+++ b/app/views/users/_project_message.html.erb
@@ -71,9 +71,7 @@
) if activity.destroyable_by?(User.current) %>
<% end %>
-
- <%= link_to "发送",messages_join_org_subfield_path(:message_id => activity.id) , :remote=> true,:class => 'postOptionLink' %>
-
+
<%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %>
diff --git a/app/views/users/_share_message_to_course.html.erb b/app/views/users/_share_message_to_course.html.erb
new file mode 100644
index 000000000..eda4a9b97
--- /dev/null
+++ b/app/views/users/_share_message_to_course.html.erb
@@ -0,0 +1,56 @@
+
+
+
+
+
发送到
+
+
+ 课程
+ 项目
+ 组织
+
+
+
+
+
+
+ <%= form_tag search_user_course_user_path(user),:method => 'get',
+ :remote=>true,:id=>'search_user_course_form',:class=>'resourcesSearchBox' do %>
+ <%= hidden_field_tag(:send_id, send_id) %>
+ <%= hidden_field_tag(:send_ids, send_ids) %>
+
+
+
+ <%= submit_tag '',:class=>'searchIcon2',:onfocus=>"this.blur();",:style=>'border-style:none' %>
+ <% end %>
+
+ <%= form_tag share_message_to_course_user_path(user),:remote=>true,:id=>'course_list_form' %>
+
+
+ <%= hidden_field_tag(:send_id, send_id) %>
+ <%= hidden_field_tag(:send_ids, send_ids) %>
+
+ <% if !courses.empty? %>
+ <% courses.each do |course| %>
+
+ <% end %>
+
+
+
+
+
+ <%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();' %>
+
+
+
+
+ <% end %>
+
+
diff --git a/app/views/users/_share_message_to_org.html.erb b/app/views/users/_share_message_to_org.html.erb
new file mode 100644
index 000000000..da3c7a072
--- /dev/null
+++ b/app/views/users/_share_message_to_org.html.erb
@@ -0,0 +1,59 @@
+
+
发送到
+
+
+ 课程
+ 项目
+ 组织
+
+
+ <%= form_tag search_user_org_user_path(user),:method => 'get',
+ :remote=>true,:id=>'search_user_org_form' do %>
+ <%= hidden_field_tag(:send_id, send_id) %>
+ <%= hidden_field_tag(:send_ids, send_ids) %>
+
+
+ <% end %>
+
+
+<%= form_tag share_message_to_org_user_path(user),:remote=>true,:id=>'orgs_list_form' do %>
+ <%= hidden_field_tag(:send_id, send_id) %>
+ <%= hidden_field_tag(:send_ids, send_ids) %>
+
+
+
+
+
+ <%= render :partial => 'users/org_resources_subfield',:locals => {:subfield=>nil}%>
+
+
+
+
+
+
+
+
+
目标地址:
+
+ <%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();',:onclick=>"check_des(event);" %>
+
+
+
+<%end %>
\ No newline at end of file
diff --git a/app/views/users/_share_message_to_project.html.erb b/app/views/users/_share_message_to_project.html.erb
new file mode 100644
index 000000000..4b79a779c
--- /dev/null
+++ b/app/views/users/_share_message_to_project.html.erb
@@ -0,0 +1,53 @@
+
+
+
发送到
+
+
+ 课程
+ 项目
+ 组织
+
+
+
+
+
+
+ <%= form_tag search_user_project_user_path(user),:method => 'get',
+ :remote=>true,:id=>'search_user_project_form',:class=>'resourcesSearchBox' do %>
+ <%= hidden_field_tag(:send_id, send_id) %>
+ <%= hidden_field_tag(:send_ids, send_ids) %>
+
+
+
+ <%= submit_tag '',:class=>'searchIcon2',:onfocus=>"this.blur();",:style=>'border-style:none' %>
+ <% end %>
+
+ <%= form_tag share_message_to_project_user_path(user), :remote => true, :id=>'projects_list_form' %>
+
+ <%= hidden_field_tag(:send_id, send_id) %>
+ <%= hidden_field_tag(:send_ids, send_ids) %>
+
+ <% if !projects.empty? %>
+ <% projects.each do |project| %>
+
+ <% end %>
+
+
+
+
+
+ <%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();' %>
+
+
+
+
+ <% end %>
+
+
diff --git a/app/views/users/search_user_course.js.erb b/app/views/users/search_user_course.js.erb
index 138eab6f9..eed7499d5 100644
--- a/app/views/users/search_user_course.js.erb
+++ b/app/views/users/search_user_course.js.erb
@@ -11,8 +11,10 @@
//$("#upload_box").css('display','block');
<% if params[:send_type].present? && params[:send_type] == 'news' %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_news_to_course' ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
-<% else %>
+<% elsif params[:send_type] == 'file' %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_popup' ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
+<% elsif params[:send_type] == 'message' %>
+ $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_message_to_course' ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
<% end %>
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
diff --git a/app/views/users/search_user_org.js.erb b/app/views/users/search_user_org.js.erb
index fb6efec9a..877629e34 100644
--- a/app/views/users/search_user_org.js.erb
+++ b/app/views/users/search_user_org.js.erb
@@ -1,7 +1,9 @@
<% if params[:send_type].present? && params[:send_type] == 'news' %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_news_to_org' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
-<% else %>
+<% elsif params[:send_type] == 'file' %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_orgs' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
+<% elsif params[:send_type] == 'message' %>
+ $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_message_to_org' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
<% end %>
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
diff --git a/app/views/users/search_user_project.js.erb b/app/views/users/search_user_project.js.erb
index 926b7aa58..f80be34f8 100644
--- a/app/views/users/search_user_project.js.erb
+++ b/app/views/users/search_user_project.js.erb
@@ -1,7 +1,9 @@
<% if params[:send_type].present? && params[:send_type] == 'news' %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_news_to_project', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>');
-<% else %>
+<% elsif params[:send_type] == 'file' %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_project_popup', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>');
+<% elsif params[:send_type] == 'message' %>
+ $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_message_to_project', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>');
<% end %>
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
diff --git a/app/views/users/share_message_to_course.js.erb b/app/views/users/share_message_to_course.js.erb
new file mode 100644
index 000000000..5a5046dfa
--- /dev/null
+++ b/app/views/users/share_message_to_course.js.erb
@@ -0,0 +1,2 @@
+hideModal();
+alert("发送成功!");
\ No newline at end of file
diff --git a/app/views/users/share_message_to_org.js.erb b/app/views/users/share_message_to_org.js.erb
new file mode 100644
index 000000000..5a5046dfa
--- /dev/null
+++ b/app/views/users/share_message_to_org.js.erb
@@ -0,0 +1,2 @@
+hideModal();
+alert("发送成功!");
\ No newline at end of file
diff --git a/app/views/users/share_message_to_project.js.erb b/app/views/users/share_message_to_project.js.erb
new file mode 100644
index 000000000..5a5046dfa
--- /dev/null
+++ b/app/views/users/share_message_to_project.js.erb
@@ -0,0 +1,2 @@
+hideModal();
+alert("发送成功!");
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 3a4d2fb92..4f191a9bf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -541,6 +541,9 @@ RedmineApp::Application.routes.draw do
post 'share_news_to_course'
post 'share_news_to_project'
post 'share_news_to_org'
+ post 'share_message_to_course'
+ post 'share_message_to_project'
+ post 'share_message_to_org'
get 'resource_preview'
get 'rename_resource'
get 'search_user_project'