summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-01 22:10:17 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-01 22:10:17 +0000
commit3e4fbb3cc4fa116159b9d10735eda8a78e4b0736 (patch)
tree5166de18cfc6eed5e9f2c87ee2baa98f4bbfbb6a /sql
parentf59b58077c9b7c97e1238a58d06532dbf9fb6e6e (diff)
Adding role listing function
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1683 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rw-r--r--sql/modules/admin.sql20
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/modules/admin.sql b/sql/modules/admin.sql
index 6b6aecfb..9423e737 100644
--- a/sql/modules/admin.sql
+++ b/sql/modules/admin.sql
@@ -402,4 +402,24 @@ comment on function admin_delete_group(text) IS $$
remove a login-capable user.
$$;
+CREATE OR REPLACE FUNCTION admin_list_roles(in_username text)
+RETURNS SETOF text AS
+$$
+DECLARE out_rolename RECORD;
+BEGIN
+ FOR out_rolename IN
+ SELECT rolname FROM pg_authid
+ WHERE oid IN (SELECT id FROM connectby(
+ '(SELECT m.member, m.roleid, r.oid FROM pg_authid r
+ LEFT JOIN pg_auth_members m ON (r.oid = m.roleid)) a',
+ 'oid', 'member', 'oid', '320461', '0', ','
+ ) c(id integer, parent integer, "level" integer,
+ path text, list_order integer)
+ )
+ LOOP
+ RETURN NEXT out_rolename.rolname;
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
-- TODO: Add admin user