class AccessGroups
Defines groups for access to the internet
Public Class Methods
allow_user(user, time)
click to toggle source
# File Entities/AccessGroups.rb, line 22 def self.allow_user(user, time) dputs(4) { "Searching for #{user} at #{time}" } if user.class == Person user = user.login_name end search_all_.sort { |a, b| b.priority.to_i <=> a.priority.to_i }.each { |ag| match_user = true if ag.members.class == Array and ag.members.size > 0 dputs(5) { "members.index is #{ag.members.index(user).inspect}" } match_user = ag.members.index(user) != nil end match_time = ag.time_in_atimes(time) limit_ok = true if (limit = ag.limit_day_mo.to_i) > 0 limit_ok = Network::Captive.usage_daily.to_i / 1e6 <= limit end dputs(4) { "Checking #{ag.name}, u,t = #{match_user},#{match_time}" } dputs(4) { "Action is #{ag.action[0].inspect}, members = #{ag.members.inspect}" } case ag.action[0] when /allow_else_block/ dputs(4) { 'allow_else_block' } return [true, "#{ag.name}"] if (match_time and match_user and limit_ok) return [false, "Over limit of #{ag.limit_day_mo}Mo in rule **#{ag.name}**"] if not limit_ok return [false, "Blocked by rule **#{ag.name}**"] if match_user when /block/ dputs(4) { 'block' } return [false, "Blocked by rule **#{ag.name}**"] if (match_time and match_user) when /allow/ dputs(4) { 'allow' } return [true, "#{ag.name}"] if (match_time and match_user and limit_ok) end } dputs(4) { 'Nothing found - must be OK' } return [true, 'default'] end
allow_user_now(user)
click to toggle source
# File Entities/AccessGroups.rb, line 60 def self.allow_user_now(user) self.allow_user(user, Time.now) end
Public Instance Methods
listp_name()
click to toggle source
# File Entities/AccessGroups.rb, line 13 def listp_name search_all_.sort { |a, b| b.priority.to_i <=> a.priority.to_i }.collect { |ag| ag.priority ||= '10' [ag.accessgroup_id, "#{ag.priority.rjust(2, '0')}:#{ag.name}"] } end
setup_data()
click to toggle source
# File Entities/AccessGroups.rb, line 4 def setup_data value_str :name value_list_single :members value_list_drop :action, '%w( allow allow_else_block block )' value_int :priority value_int :limit_day_mo value_list_single :access_times, '[]' end