Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql,v
diff -u -N -r1.36 -r1.37
--- openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql	2 Apr 2013 11:05:17 -0000	1.36
+++ openacs-4/packages/acs-kernel/sql/postgresql/acs-permissions-create.sql	2 Apr 2013 14:09:22 -0000	1.37
@@ -626,7 +626,7 @@
     permission_p__privilege varchar
 ) RETURNS table (object_id integer, orig_object_id integer) as $$
 BEGIN
-    return query With RECURSIVE object_context(object_id, context_id, orig_object_id) AS (
+    return query With RECURSIVE object_context(obj_id, context_id, orig_obj_id) AS (
 
             select unnest(permission_p__objects), unnest(permission_p__objects), unnest(permission_p__objects)
 
@@ -635,16 +635,14 @@
             select ao.object_id,
             case when (ao.security_inherit_p = 'f' or ao.context_id is null) 
             then acs__magic_object_id('security_context_root') else ao.context_id END, 
-            oc.orig_object_id
+            oc.orig_obj_id
             from object_context oc, acs_objects ao
             where ao.object_id = oc.context_id
             and ao.object_id != acs__magic_object_id('security_context_root')
 
         ), privilege_ancestors(privilege, child_privilege) AS (
 
            select permission_p__privilege, permission_p__privilege
-           from acs_privilege_hierarchy 
-           where privilege = permission_p__privilege
 
            union all
 
@@ -653,7 +651,7 @@
            on aph.child_privilege = pa.privilege
 
         ) select
-          p.object_id, oc.orig_object_id
+          p.object_id, oc.orig_obj_id
           from
           acs_permissions p
           join  party_approved_member_map pap on pap.party_id   =  p.grantee_id
