From 56d9979b231af7d46f6b06f693fbf9820dcd73aa Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 21 Feb 2013 14:40:11 +0100 Subject: pickup groups --- misc/freeswitch/scripts/dialplan/user.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'misc/freeswitch/scripts/dialplan/user.lua') diff --git a/misc/freeswitch/scripts/dialplan/user.lua b/misc/freeswitch/scripts/dialplan/user.lua index b536600..b6928b4 100644 --- a/misc/freeswitch/scripts/dialplan/user.lua +++ b/misc/freeswitch/scripts/dialplan/user.lua @@ -69,6 +69,23 @@ function User.list_groups(self, id) end +function User.list_group_ids(self, id) + require 'common.str' + id = id or self.id; + local sql_query = 'SELECT `b`.`id` FROM `user_group_memberships` `a` \ + JOIN `user_groups` `b` ON `a`.`user_group_id` = `b`.`id` \ + WHERE `a`.`state` = "active" AND `a`.`user_id`= ' .. tonumber(id) .. ' ORDER BY `b`.`position` LIMIT ' .. MAX_GROUP_MEMBERSHIPS; + + local groups = {}; + + self.database:query(sql_query, function(entry) + table.insert(groups, common.str.downcase(entry.id)); + end); + + return groups; +end + + function User.check_pin(self, pin_to_check) if not self.record then return nil -- cgit v1.2.3