72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'app/models/topic_post.rb', line 72
def mark_as_deleted(by_user, del)
self.is_visible = del ? 0 : 1
self. ||= ''
self. += (self.is_visible? ? "Undeleted" : "Deleted") + " by #{by_user.email} at #{Time.now}<br/>"
self.save
if self.topic_thread.topic_posts.where("is_visible=#{del ? 1 : 0}").count==0
self.topic_thread.update_attributes(:is_visible=>del ? 0 : 1, :post_count=>self.topic_thread.topic_posts.where("is_visible=1").count)
else
self.topic_thread.update_attributes(:post_count => self.topic_thread.post_count - (self.is_visible==0 ? 1 : -1))
end
end
|