##// END OF EJS Templates
Upgraded to Rails 2.3.4 (#3597)...
Upgraded to Rails 2.3.4 (#3597) * Ran the Rails upgrade * Upgraded to Rails Engines 2.3.2 * Added a plugin to let Engines override application views. * Converted tests to use the new classes: ** ActionController::TestCase for functional ** ActiveSupport::TestCase for units * Converted ActiveRecord::Error message to a string. * ActiveRecord grouping returns an ordered hash which doesn't have #sort! * Updated the I18n storage_units format. * Added some default initializers from a fresh rails app * Changed the order of check_box_tags and hidden_field_tags. The hidden tag needs to appear first in Rails 2.3, otherwise it will override any value in the check_box_tag. * Removed the custom handler for when the cookie store is tampered with. Rails 2.3 removed the TamperedWithCookie exception and instead Rails will not load the data from it when it's been tampered with (e.g. no user login). * Fixed mail layouts, 2.3 has problems with implicit multipart emails that use layouts. Also removed some custom Redmine mailer code. * Fixed a bug that occurred in tests where the "required" span tag would be added to the :field_status translation. This resulted in an email string of: <li>Status<span class="required"> *</span><span class="required"> *</span> Instead of: <li>Status: New</li> git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2887 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r2687:7642b5a9ab18
r2773:7b0cb6aba871
Show More
message.rb
94 lines | 3.4 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Per project forums added....
r526 # redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Message < ActiveRecord::Base
belongs_to :board
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
Jean-Philippe Lang
AttachmentsController now handles attachments deletion....
r2114 acts_as_attachable
Jean-Philippe Lang
Per project forums added....
r526 belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
Jean-Philippe Lang
Fixed: unable to migrate from an empty database....
r760 acts_as_searchable :columns => ['subject', 'content'],
Jean-Philippe Lang
Fixes message search eager loading (#2654)....
r2355 :include => {:board => :project},
Jean-Philippe Lang
Fixed: unable to migrate from an empty database....
r760 :project_key => 'project_id',
Jean-Philippe Lang
Ability to search all projects or the projects the user belongs to (#791)....
r1420 :date_column => "#{table_name}.created_on"
Jean-Philippe Lang
Search engines now supports pagination....
r755 acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
:description => :content,
Jean-Philippe Lang
Add an icon to each event on the activity view....
r1327 :type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
Jean-Philippe Lang
Adds anchor to atom feed messages links....
r1574 :url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id}.merge(o.parent_id.nil? ? {:id => o.id} :
{:id => o.parent_id, :anchor => "message-#{o.id}"})}
Jean-Philippe Lang
Activity refactoring....
r1692
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
:author_key => :author_id
Jean-Philippe Lang
Adds watch/unwatch functionality at forum topic level (#1912)....
r1876 acts_as_watchable
Jean-Philippe Lang
Activity refactoring....
r1692
Jean-Philippe Lang
Forums enhancements:...
r913 attr_protected :locked, :sticky
Jean-Philippe Lang
Adds the ability to move threads between project forums (#2452). 'Edit message' permission is required....
r2560 validates_presence_of :board, :subject, :content
Jean-Philippe Lang
Per project forums added....
r526 validates_length_of :subject, :maximum => 255
Jean-Philippe Lang
Adds watch/unwatch functionality at forum topic level (#1912)....
r1876 after_create :add_author_as_watcher
Jean-Philippe Lang
Forums enhancements:...
r913 def validate_on_create
# Can not reply to a locked topic
Jean-Philippe Lang
Fixed: can not lock a topic when creating it....
r1081 errors.add_to_base 'Topic is locked' if root.locked? && self != root
Jean-Philippe Lang
Forums enhancements:...
r913 end
Jean-Philippe Lang
Per project forums added....
r526 def after_create
if parent
parent.reload.update_attribute(:last_reply_id, self.id)
Jean-Philippe Lang
Adds the ability to move threads between project forums (#2452). 'Edit message' permission is required....
r2560 end
board.reset_counters!
end
def after_update
if board_id_changed?
Message.update_all("board_id = #{board_id}", ["id = ? OR parent_id = ?", root.id, root.id])
Board.reset_counters!(board_id_was)
Board.reset_counters!(board_id)
Jean-Philippe Lang
Per project forums added....
r526 end
end
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538
Jean-Philippe Lang
Forums enhancements:...
r913 def after_destroy
Jean-Philippe Lang
Adds the ability to move threads between project forums (#2452). 'Edit message' permission is required....
r2560 board.reset_counters!
Jean-Philippe Lang
Forums enhancements:...
r913 end
Jean-Philippe Lang
Fixed: editing a message may cause sticky attribute to be NULL (#3356)....
r2687 def sticky=(arg)
write_attribute :sticky, (arg == true || arg.to_s == '1' ? 1 : 0)
end
Jean-Philippe Lang
Forums enhancements:...
r913 def sticky?
sticky == 1
end
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538 def project
board.project
end
Jean-Philippe Lang
Adds permissions to let users edit and/or delete their messages (#854, patch by Markus Knittig with slight changes)....
r2017
def editable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:edit_messages, project) || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)))
end
def destroyable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
end
Jean-Philippe Lang
Adds watch/unwatch functionality at forum topic level (#1912)....
r1876
private
def add_author_as_watcher
Watcher.create(:watchable => self.root, :user => author)
end
Jean-Philippe Lang
Per project forums added....
r526 end