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.

comments_controller.rb 4.2 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class CommentsController < ApplicationController
  18. default_search_scope :news
  19. include ApplicationHelper
  20. model_object News
  21. before_filter :find_model_object, :except => [:reply, :quote]
  22. before_filter :find_project_from_association, :except => [:reply, :quote]
  23. before_filter :authorize
  24. def create
  25. raise Unauthorized unless @news.commentable?
  26. if !@news.org_subfield_id.nil?
  27. @org_subfield = OrgSubfield.find(@news.org_subfield_id)
  28. end
  29. @comment = Comment.new
  30. #@project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment]
  31. if params[:user_activity_id]
  32. @comment.comments = params[:comment]
  33. else
  34. @comment.comments = params[:comment][:comments]
  35. end
  36. @comment.author = User.current
  37. if @news.comments << @comment
  38. if params[:asset_id]
  39. ids = params[:asset_id].split(',')
  40. update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
  41. end
  42. # # ������ض�̬�ļ�¼add start
  43. # if( @comment.id && @news.course )
  44. # if(@news.author_id != User.current.id)
  45. # notify = ActivityNotify.new()
  46. # notify.activity_container_id = @news.course.id
  47. # notify.activity_container_type = 'Course'
  48. # notify.activity_id = @comment.id
  49. # notify.activity_type = 'Comment'
  50. # notify.notify_to = @news.author_id
  51. # notify.is_read = 0
  52. # notify.save()
  53. # end
  54. # end
  55. # # ������ض�̬�ļ�¼add end
  56. #flash[:notice] = l(:label_comment_added)
  57. update_course_activity(@news.class,@news.id)
  58. update_user_activity(@news.class,@news.id)
  59. update_org_activity(@news.class,@news.id)
  60. end
  61. if params[:user_activity_id]
  62. @user_activity_id = params[:user_activity_id]
  63. respond_to do |format|
  64. format.js
  65. end
  66. else
  67. redirect_to news_url(@news)
  68. end
  69. end
  70. def destroy
  71. @news.comments.find(params[:comment_id]).destroy
  72. if params[:user_activity_id]
  73. @user_activity_id = params[:user_activity_id]
  74. respond_to do |format|
  75. format.js
  76. return
  77. end
  78. else
  79. redirect_to news_url(@news)
  80. end
  81. end
  82. def quote
  83. @comment = Comment.find(params[:id])
  84. respond_to do | format|
  85. format.js
  86. end
  87. end
  88. def reply
  89. comment = Comment.find(params[:id])
  90. @news = News.find comment.commented_id
  91. new_comment = @news.comments.build(:author_id => User.current.id, :reply_id => params[:id], :comments => params[:content], :parent_id => comment.id)
  92. @user_activity_id = params[:user_activity_id]
  93. if new_comment.save
  94. update_course_activity(@news.class,@news.id)
  95. update_user_activity(@news.class,@news.id)
  96. update_org_activity(@news.class,@news.id)
  97. if @user_activity_id
  98. respond_to do |format|
  99. format.js
  100. return
  101. end
  102. else
  103. respond_to do |format|
  104. format.html {
  105. redirect_to news_path(@news)
  106. }
  107. end
  108. end
  109. end
  110. end
  111. private
  112. # ApplicationController's find_model_object sets it based on the controller
  113. # name so it needs to be overriden and set to @news instead
  114. def find_model_object
  115. super
  116. @news = @object
  117. @comment = nil
  118. @news
  119. end
  120. end

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