Mercurial > hg > soundsoftware-site
comparison app/controllers/messages_controller.rb @ 929:5f33065ddc4b redmine-1.3
Update to Redmine SVN rev 9414 on 1.3-stable branch
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 14:54:18 +0100 |
parents | cbb26bc654de |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
909:cbb26bc654de | 929:5f33065ddc4b |
---|---|
51 render :action => "show", :layout => false if request.xhr? | 51 render :action => "show", :layout => false if request.xhr? |
52 end | 52 end |
53 | 53 |
54 # Create a new topic | 54 # Create a new topic |
55 def new | 55 def new |
56 @message = Message.new(params[:message]) | 56 @message = Message.new |
57 @message.author = User.current | 57 @message.author = User.current |
58 @message.board = @board | 58 @message.board = @board |
59 if params[:message] && User.current.allowed_to?(:edit_messages, @project) | 59 @message.safe_attributes = params[:message] |
60 @message.locked = params[:message]['locked'] | |
61 @message.sticky = params[:message]['sticky'] | |
62 end | |
63 if request.post? && @message.save | 60 if request.post? && @message.save |
64 call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) | 61 call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) |
65 attachments = Attachment.attach_files(@message, params[:attachments]) | 62 attachments = Attachment.attach_files(@message, params[:attachments]) |
66 render_attachment_warning_if_needed(@message) | 63 render_attachment_warning_if_needed(@message) |
67 redirect_to :action => 'show', :id => @message | 64 redirect_to :action => 'show', :id => @message |
68 end | 65 end |
69 end | 66 end |
70 | 67 |
71 # Reply to a topic | 68 # Reply to a topic |
72 def reply | 69 def reply |
73 @reply = Message.new(params[:reply]) | 70 @reply = Message.new |
74 @reply.author = User.current | 71 @reply.author = User.current |
75 @reply.board = @board | 72 @reply.board = @board |
73 @reply.safe_attributes = params[:reply] | |
76 @topic.children << @reply | 74 @topic.children << @reply |
77 if !@reply.new_record? | 75 if !@reply.new_record? |
78 call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) | 76 call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) |
79 attachments = Attachment.attach_files(@reply, params[:attachments]) | 77 attachments = Attachment.attach_files(@reply, params[:attachments]) |
80 render_attachment_warning_if_needed(@reply) | 78 render_attachment_warning_if_needed(@reply) |
83 end | 81 end |
84 | 82 |
85 # Edit a message | 83 # Edit a message |
86 def edit | 84 def edit |
87 (render_403; return false) unless @message.editable_by?(User.current) | 85 (render_403; return false) unless @message.editable_by?(User.current) |
88 if params[:message] | 86 @message.safe_attributes = params[:message] |
89 @message.locked = params[:message]['locked'] | 87 if request.post? && @message.save |
90 @message.sticky = params[:message]['sticky'] | |
91 end | |
92 if request.post? && @message.update_attributes(params[:message]) | |
93 attachments = Attachment.attach_files(@message, params[:attachments]) | 88 attachments = Attachment.attach_files(@message, params[:attachments]) |
94 render_attachment_warning_if_needed(@message) | 89 render_attachment_warning_if_needed(@message) |
95 flash[:notice] = l(:notice_successful_update) | 90 flash[:notice] = l(:notice_successful_update) |
96 @message.reload | 91 @message.reload |
97 redirect_to :action => 'show', :board_id => @message.board, :id => @message.root, :r => (@message.parent_id && @message.id) | 92 redirect_to :action => 'show', :board_id => @message.board, :id => @message.root, :r => (@message.parent_id && @message.id) |