Class: Message
Overview
Redmine - project management software Copyright (C) 2006-2017
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.
Instance Method Summary
collapse
#delete_unsafe_attributes, #safe_attribute?, #safe_attribute_names, #safe_attributes=
Instance Method Details
#cannot_reply_to_locked_topic ⇒ Object
65
66
67
68
|
# File 'app/models/message.rb', line 65
def cannot_reply_to_locked_topic
errors.add :base, 'Topic is locked' if root.locked? && self != root
end
|
#destroyable_by?(usr) ⇒ Boolean
101
102
103
|
# File 'app/models/message.rb', line 101
def destroyable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
end
|
#editable_by?(usr) ⇒ Boolean
97
98
99
|
# File 'app/models/message.rb', line 97
def editable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:edit_messages, project) || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)))
end
|
#notified_users ⇒ Object
105
106
107
|
# File 'app/models/message.rb', line 105
def notified_users
project.notified_users.reject {|user| !visible?(user)}
end
|
#project ⇒ Object
93
94
95
|
# File 'app/models/message.rb', line 93
def project
board.project
end
|
#reset_counters! ⇒ Object
78
79
80
81
82
83
|
# File 'app/models/message.rb', line 78
def reset_counters!
if parent && parent.id
Message.where({:id => parent.id}).update_all({:last_reply_id => parent.children.maximum(:id)})
end
board.reset_counters!
end
|
#sticky=(arg) ⇒ Object
85
86
87
|
# File 'app/models/message.rb', line 85
def sticky=(arg)
write_attribute :sticky, (arg == true || arg.to_s == '1' ? 1 : 0)
end
|
#sticky? ⇒ Boolean
89
90
91
|
# File 'app/models/message.rb', line 89
def sticky?
sticky == 1
end
|
#update_messages_board ⇒ Object
70
71
72
73
74
75
76
|
# File 'app/models/message.rb', line 70
def update_messages_board
if saved_change_to_board_id?
Message.where(["id = ? OR parent_id = ?", root.id, root.id]).update_all({:board_id => board_id})
Board.reset_counters!(board_id_before_last_save)
Board.reset_counters!(board_id)
end
end
|
#visible?(user = User.current) ⇒ Boolean
61
62
63
|
# File 'app/models/message.rb', line 61
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_messages, project)
end
|