@@ -50,13 +50,10 class MessagesController < ApplicationController | |||
|
50 | 50 | |
|
51 | 51 | # Create a new topic |
|
52 | 52 | def new |
|
53 |
@message = Message.new |
|
|
53 | @message = Message.new | |
|
54 | 54 | @message.author = User.current |
|
55 | 55 | @message.board = @board |
|
56 | if params[:message] && User.current.allowed_to?(:edit_messages, @project) | |
|
57 | @message.locked = params[:message]['locked'] | |
|
58 | @message.sticky = params[:message]['sticky'] | |
|
59 | end | |
|
56 | @message.safe_attributes = params[:message] | |
|
60 | 57 | if request.post? |
|
61 | 58 | @message.save_attachments(params[:attachments]) |
|
62 | 59 | if @message.save |
@@ -69,9 +66,10 class MessagesController < ApplicationController | |||
|
69 | 66 | |
|
70 | 67 | # Reply to a topic |
|
71 | 68 | def reply |
|
72 |
@reply = Message.new |
|
|
69 | @reply = Message.new | |
|
73 | 70 | @reply.author = User.current |
|
74 | 71 | @reply.board = @board |
|
72 | @reply.safe_attributes = params[:reply] | |
|
75 | 73 | @topic.children << @reply |
|
76 | 74 | if !@reply.new_record? |
|
77 | 75 | call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) |
@@ -84,11 +82,8 class MessagesController < ApplicationController | |||
|
84 | 82 | # Edit a message |
|
85 | 83 | def edit |
|
86 | 84 | (render_403; return false) unless @message.editable_by?(User.current) |
|
87 |
|
|
|
88 | @message.locked = params[:message]['locked'] | |
|
89 | @message.sticky = params[:message]['sticky'] | |
|
90 | end | |
|
91 | if request.post? && @message.update_attributes(params[:message]) | |
|
85 | @message.safe_attributes = params[:message] | |
|
86 | if request.post? && @message.save | |
|
92 | 87 | attachments = Attachment.attach_files(@message, params[:attachments]) |
|
93 | 88 | render_attachment_warning_if_needed(@message) |
|
94 | 89 | flash[:notice] = l(:notice_successful_update) |
@@ -16,6 +16,7 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class Message < ActiveRecord::Base |
|
19 | include Redmine::SafeAttributes | |
|
19 | 20 | belongs_to :board |
|
20 | 21 | belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' |
|
21 | 22 | acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC" |
@@ -48,6 +49,12 class Message < ActiveRecord::Base | |||
|
48 | 49 | named_scope :visible, lambda {|*args| { :include => {:board => :project}, |
|
49 | 50 | :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } } |
|
50 | 51 | |
|
52 | safe_attributes 'subject', 'content' | |
|
53 | safe_attributes 'locked', 'sticky', | |
|
54 | :if => lambda {|message, user| | |
|
55 | user.allowed_to?(:edit_messages, message.project) | |
|
56 | } | |
|
57 | ||
|
51 | 58 | def visible?(user=User.current) |
|
52 | 59 | !user.nil? && user.allowed_to?(:view_messages, project) |
|
53 | 60 | end |
General Comments 0
You need to be logged in to leave comments.
Login now