##// END OF EJS Templates
By default, only show statuses that are used by the tracker on the workflow edit view....
By default, only show statuses that are used by the tracker on the workflow edit view. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3188 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r3055:bb477a3a0fe7
r3074:6bf0723d0654
Show More
message.rb
105 lines | 3.7 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
Makes user unwatch what he can no longer view after its permissions have changed (#3589)....
r3053 def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_messages, project)
end
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
Jean-Philippe Lang
Make sure users don't get notified for thing they can not view (#3589)....
r3055 # Returns the mail adresses of users that should be notified
def recipients
notified = project.notified_users
notified.reject! {|user| !visible?(user)}
notified.collect(&:mail)
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