You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

org_document_comments_controller.rb 7.2 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. class OrgDocumentCommentsController < ApplicationController
  2. before_filter :find_organization, :only => [:new, :create, :show, :index]
  3. helper :attachments,:organizations
  4. layout 'base_org'
  5. def new
  6. @org_document_comment = OrgDocumentComment.new
  7. end
  8. def create
  9. @org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id)
  10. @org_document_comment.title = params[:org_document_comment][:title]
  11. @org_document_comment.content = params[:org_document_comment][:content]
  12. @org_document_comment.save_attachments(params[:attachments])
  13. if params[:field_id]
  14. @org_document_comment.org_subfield_id = params[:field_id].to_i
  15. end
  16. if @org_document_comment.save
  17. flash.keep[:notice] = l(:notice_successful_create)
  18. EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at)
  19. if params[:field_id]
  20. @org_subfield = OrgSubfield.find(params[:field_id])
  21. if @org_subfield.subfield_subdomain_dir.nil?
  22. redirect_to organization_path(@organization, :org_subfield_id => params[:field_id])
  23. else
  24. redirect_to show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => @org_subfield.subfield_subdomain_dir.name)
  25. end
  26. else
  27. redirect_to organization_org_document_comments_path(@organization)
  28. end
  29. else
  30. redirect_to new_org_document_comment_path(:organization_id => @organization.id)
  31. end
  32. end
  33. def show
  34. @document = OrgDocumentComment.find(params[:id])
  35. end
  36. def index
  37. if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
  38. @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc")
  39. else
  40. render_403
  41. end
  42. end
  43. def update
  44. @org_document = OrgDocumentComment.find(params[:id])
  45. @org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content])
  46. Attachment.attach_files(@org_document, params[:attachments])
  47. # @org_document.save_attachments(params[:attachments])
  48. if @org_document.parent.nil?
  49. act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first
  50. act.update_attributes(:updated_at => @org_document.updated_at)
  51. EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now)
  52. end
  53. respond_to do |format|
  54. format.html {
  55. if params[:flag].to_i == 0
  56. redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)
  57. else
  58. if params[:flag].to_i == 1
  59. redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id)
  60. else
  61. redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id])
  62. end
  63. end
  64. }
  65. end
  66. end
  67. def edit
  68. @org_document = OrgDocumentComment.find(params[:id])
  69. @flag = params[:flag]
  70. @organization = Organization.find(params[:organization_id])
  71. end
  72. def add_reply
  73. @document = OrgDocumentComment.find(params[:id]).root
  74. @act = OrgActivity.find(params[:id])
  75. @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
  76. @comment.content = params[:org_content]
  77. @document.children << @comment
  78. @document.save
  79. end
  80. def add_reply_in_doc
  81. @document = OrgDocumentComment.find(params[:id]).root
  82. @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
  83. @comment.content = params[:org_comment][:org_content]
  84. @document.children << @comment
  85. @document.save
  86. respond_to do |format|
  87. format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)}
  88. end
  89. end
  90. def find_organization
  91. @organization = Organization.find(params[:organization_id])
  92. end
  93. def destroy
  94. @org_document_comment = OrgDocumentComment.find(params[:id])
  95. org = @org_document_comment.organization
  96. if @org_document_comment.id == org.home_id
  97. org.update_attributes(:home_id => nil)
  98. end
  99. if @org_document_comment.destroy
  100. end
  101. respond_to do |format|
  102. format.js
  103. end
  104. end
  105. def delete_reply
  106. @org_document_comment = OrgDocumentComment.find(params[:id])
  107. @document = @org_document_comment.root
  108. org = @org_document_comment.organization
  109. @org_document_comment.destroy
  110. respond_to do |format|
  111. format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)}
  112. end
  113. end
  114. def quote
  115. @org_comment = OrgDocumentComment.find(params[:id])
  116. @subject = @org_comment.content
  117. @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
  118. @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> "
  119. @temp = OrgDocumentComment.new
  120. #@course_id = params[:course_id]
  121. @temp.content = "<blockquote>#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)} <br/>#{@org_comment.content.html_safe}</blockquote>".html_safe
  122. respond_to do | format|
  123. format.js
  124. end
  125. end
  126. def reply
  127. @document = OrgDocumentComment.find(params[:id]).root
  128. @quote = params[:quote][:quote]
  129. @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id])
  130. # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0
  131. # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0
  132. @org_document.title = params[:org_document_comment][:title]
  133. @org_document.content = params[:org_document_comment][:content]
  134. @org_document.content = @quote + @org_document.content
  135. #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title]
  136. @document.children << @org_document
  137. # @user_activity_id = params[:user_activity_id]
  138. # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first
  139. # if user_activity
  140. # user_activity.updated_at = Time.now
  141. # user_activity.save
  142. # end
  143. # attachments = Attachment.attach_files(@org_document, params[:attachments])
  144. # render_attachment_warning_if_needed(@org_document)
  145. #@article.save
  146. # redirect_to user_blogs_path(:user_id=>params[:user_id])
  147. respond_to do |format|
  148. format.html {
  149. # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的
  150. # redirect_to syllabus_course_path(:id=>params[:course_id])
  151. # else
  152. redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)
  153. # end
  154. }
  155. format.js
  156. end
  157. end
  158. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...