class Users
this file is part of manqod manqod is distributed under the CDDL licence the owner of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Attributes
drbdb[R]
Public Class Methods
new(drbdb)
click to toggle source
# File lib/DrbDB/Users.rb, line 8 def initialize(drbdb) @drbdb=drbdb @users=Hash.new @groups=Hash.new @usergroups=Hash.new end
Public Instance Methods
auth?(nick,password)
click to toggle source
# File lib/DrbDB/Users.rb, line 56 def auth?(nick,password) found=false @users.each{|key,user| found=true if nick.to_s == user["nick"].to_s && user["passwd"].to_s == password.to_s } found end
each() { |im_key| ... }
click to toggle source
# File lib/DrbDB/Users.rb, line 53 def each @users.each_key{|im_key| yield im_key} end
get_user(user_id)
click to toggle source
# File lib/DrbDB/Users.rb, line 49 def get_user(user_id) @users[user_id] end
load_all()
click to toggle source
# File lib/DrbDB/Users.rb, line 16 def load_all @users.clear @groups.clear @usergroups.clear drbdb.admin.rows("select * from users").each{|row| @users[row["id"].to_i]=row } einfo("#{@users.length} users\n") drbdb.admin.rows("select * from groups").each{|row| @groups[row["id"].to_i]=row } drbdb.admin.rows("select * from usergroups").each{|row| @usergroups[row["id"].to_i]=row } self end
mygroups(nick)
click to toggle source
# File lib/DrbDB/Users.rb, line 41 def mygroups(nick) gr=Hash.new @usergroups.each_value{|ugrp| gr[ugrp["groupid"].to_i]=@groups[ugrp["groupid"].to_i]["name"] if @groups.has_key?(ugrp["groupid"].to_i) && @users.has_key?(ugrp["userid"].to_i) && @users[ugrp["userid"].to_i]['nick'] == nick } gr end
to_s()
click to toggle source
# File lib/DrbDB/Users.rb, line 65 def to_s "Users of #{drbdb}" end
user_in_group?(user_id,group_id)
click to toggle source
# File lib/DrbDB/Users.rb, line 33 def user_in_group?(user_id,group_id) found=false @usergroups.each_value{|ugrp| found=true if ugrp["userid"].to_i == user_id && ugrp["groupid"].to_i == group_id } found end