| Class | Flag |
| In: |
app/models/flag.rb
|
| Parent: | ActiveRecord::Base |
# File app/models/flag.rb, line 28
28: def self.count_active
29: count(:conditions => { :active => true })
30: end
# File app/models/flag.rb, line 14
14: def self.uniq_ip_count(obj, active_only = false)
15: conditions = (active_only) ? { :active => true } : {}
16: if obj.class == Item
17: conditions[:item_id] = obj.id
18: elsif obj.class == Comment
19: conditions[:comment_id] = obj.id
20: end
21: count(
22: :joins => "INNER JOIN visits ON visits.id=flags.visit_id",
23: :conditions => conditions,
24: :group => 'visits.ip_address'
25: ).values.length
26: end
# File app/models/flag.rb, line 32
32: def suspend(count_active_only = true)
33: if self.item # suspend item
34: self.item.suspend if Flag.uniq_ip_count(self.item, count_active_only) >= Param.item_flags_for_suspend
35: elsif self.comment # suspend comment
36: self.comment.suspend if Flag.uniq_ip_count(self.comment, count_active_only) >= Param.comment_flags_for_suspend
37: end
38: end