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.3 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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, :except => [:destroy]
  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. @contest = Contest.find(@news.contest_id) if @news.contest_id
  30. @comment = Comment.new
  31. #@project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment]
  32. if params[:user_activity_id]
  33. @comment.comments = params[:comment]
  34. else
  35. @comment.comments = params[:comment][:comments]
  36. end
  37. @comment.author = User.current
  38. if @news.comments << @comment
  39. if params[:asset_id]
  40. ids = params[:asset_id].split(',')
  41. update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
  42. end
  43. # # ������ض�̬�ļ�¼add start
  44. # if( @comment.id && @news.course )
  45. # if(@news.author_id != User.current.id)
  46. # notify = ActivityNotify.new()
  47. # notify.activity_container_id = @news.course.id
  48. # notify.activity_container_type = 'Course'
  49. # notify.activity_id = @comment.id
  50. # notify.activity_type = 'Comment'
  51. # notify.notify_to = @news.author_id
  52. # notify.is_read = 0
  53. # notify.save()
  54. # end
  55. # end
  56. # # ������ض�̬�ļ�¼add end
  57. #flash[:notice] = l(:label_comment_added)
  58. update_course_activity(@news.class,@news.id)
  59. update_user_activity(@news.class,@news.id)
  60. update_org_activity(@news.class,@news.id)
  61. end
  62. if params[:user_activity_id]
  63. @user_activity_id = params[:user_activity_id]
  64. respond_to do |format|
  65. format.js
  66. end
  67. else
  68. redirect_to news_url(@news)
  69. end
  70. end
  71. def destroy
  72. @news.comments.find(params[:comment_id]).destroy
  73. if params[:user_activity_id]
  74. @user_activity_id = params[:user_activity_id]
  75. respond_to do |format|
  76. format.js
  77. return
  78. end
  79. else
  80. redirect_to news_url(@news)
  81. end
  82. end
  83. def quote
  84. @comment = Comment.find(params[:id])
  85. respond_to do | format|
  86. format.js
  87. end
  88. end
  89. def reply
  90. comment = Comment.find(params[:id])
  91. @news = News.find comment.commented_id
  92. new_comment = @news.comments.build(:author_id => User.current.id, :reply_id => params[:id], :comments => params[:content], :parent_id => comment.id)
  93. @user_activity_id = params[:user_activity_id]
  94. if new_comment.save
  95. update_course_activity(@news.class,@news.id)
  96. update_user_activity(@news.class,@news.id)
  97. update_org_activity(@news.class,@news.id)
  98. if @user_activity_id
  99. respond_to do |format|
  100. format.js
  101. return
  102. end
  103. else
  104. respond_to do |format|
  105. format.html {
  106. redirect_to news_path(@news)
  107. }
  108. end
  109. end
  110. end
  111. end
  112. private
  113. # ApplicationController's find_model_object sets it based on the controller
  114. # name so it needs to be overriden and set to @news instead
  115. def find_model_object
  116. super
  117. @news = @object
  118. @comment = nil
  119. @news
  120. end
  121. end

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