]> git.openstreetmap.org Git - rails.git/blob - app/models/acl.rb
Add support for ACL blocks on note commenting
[rails.git] / app / models / acl.rb
1 class Acl < ActiveRecord::Base
2   def self.match(address, domain = nil)
3     if domain
4       condition = Acl.where("address >>= ? OR domain = ?", address, domain)
5     else
6       condition = Acl.where("address >>= ?", address)
7     end
8   end
9
10   def self.no_account_creation(address, domain = nil)
11     self.match(address, domain).where(:k => "no_account_creation").exists?
12   end
13
14   def self.no_note_comment(address, domain = nil)
15     self.match(address, domain).where(:k => "no_note_comment").exists?
16   end
17
18   def self.no_trace_download(address, domain = nil)
19     self.match(address, domain).where(:k => "no_trace_download").exists?
20   end
21 end