fixing perm lookup bug
[Evergreen.git] / Open-ILS / src / sql / Pg / 006.schema.permissions.sql
index 4fee24f..a7ab679 100644 (file)
@@ -149,7 +149,12 @@ CREATE OR REPLACE FUNCTION permission.usr_perms ( INT ) RETURNS SETOF permission
                                        UNION ALL
                        (SELECT -p.id, $1 AS usr, p.perm, p.depth, p.grantable
                          FROM  permission.grp_perm_map p
-                         WHERE p.grp = (SELECT profile FROM actor.usr WHERE id = $1 LIMIT 1))
+                         WHERE p.grp IN (
+                               SELECT  (permission.grp_ancestors(
+                                               (SELECT profile FROM actor.usr WHERE id = $1)
+                                       )).id
+                               )
+                       )
                                        UNION ALL
                        (SELECT -p.id, $1 AS usr, p.perm, p.depth, p.grantable
                          FROM  permission.grp_perm_map p