Index: openacs-4/packages/acs-kernel/sql/oracle/acs-permissions-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-permissions-create.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-kernel/sql/oracle/acs-permissions-create.sql	11 May 2001 00:14:48 -0000	1.3
+++ openacs-4/packages/acs-kernel/sql/oracle/acs-permissions-create.sql	21 Jun 2002 21:59:31 -0000	1.4
@@ -364,7 +364,7 @@
     and grantee_id = revoke_permission.grantee_id
     and privilege = revoke_permission.privilege;
   end revoke_permission;
-  --
+
   function permission_p (
     object_id	 acs_objects.object_id%TYPE,
     party_id	 parties.party_id%TYPE,
@@ -374,69 +374,71 @@
     exists_p char(1);
   begin
     --
-    -- Check group permmissions
-    select decode( count(*), 0,'f', 't') into exists_p
+    -- direct permissions
+    select decode(count(*),0,'f','t') into exists_p
     from dual where exists (
-          select 'x'
-          from acs_object_grantee_priv_map ogpm,
-               group_approved_member_map gmm
+        select 'x'
+          from acs_object_grantee_priv_map
          where object_id = permission_p.object_id
-           and gmm.member_id = permission_p.party_id
-           and privilege = permission_p.privilege
-           and ogpm.grantee_id = gmm.group_id);
+           and grantee_id = permission_p.party_id
+           and privilege = permission_p.privilege);
     if exists_p = 't' then
         return 't';
     end if;
     --
-    -- relational segment approved group
-    select decode( count(*), 0,'f', 't') into exists_p
+    -- public-like permissions
+    select decode(count(*),0,'f','t') into exists_p
     from dual where exists (
         select 'x'
-          from acs_object_grantee_priv_map ogpm,
-               rel_seg_approved_member_map rsmm
+          from acs_object_grantee_priv_map
          where object_id = permission_p.object_id
-           and rsmm.member_id = permission_p.party_id
+           and 0 = permission_p.party_id
            and privilege = permission_p.privilege
-           and ogpm.grantee_id = rsmm.segment_id);
+           and grantee_id = -1);
     if exists_p = 't' then
         return 't';
     end if;
     --
-    -- Check direct permissions
-    select decode( count(*), 0,'f', 't') into exists_p
+    -- public permissions
+    select decode(count(*),0,'f','t') into exists_p
     from dual where exists (
         select 'x'
-          from acs_object_grantee_priv_map
+          from acs_object_grantee_priv_map m, users u
          where object_id = permission_p.object_id
-           and grantee_id = permission_p.party_id
-           and privilege = permission_p.privilege);
+           and u.user_id = permission_p.party_id
+           and privilege = permission_p.privilege
+           and m.grantee_id = -1);
     if exists_p = 't' then
         return 't';
     end if;
     --
-    -- Check public permissions
-    select decode( count(*), 0,'f', 't') into exists_p
+    -- group permmissions
+    select decode(count(*),0,'f','t') into exists_p
     from dual where exists (
-        select 'x'
-          from acs_object_grantee_priv_map m, users u
+          select 'x'
+          from acs_object_grantee_priv_map ogpm,
+               group_approved_member_map gmm
          where object_id = permission_p.object_id
-           and u.user_id = permission_p.party_id
+           and gmm.member_id = permission_p.party_id
            and privilege = permission_p.privilege
-           and m.grantee_id = -1);
+           and ogpm.grantee_id = gmm.group_id);
     if exists_p = 't' then
         return 't';
     end if;
     --
-    -- Check public-like permissions
-    select decode( count(*), 0,'f', 't') into exists_p
+    -- relational segment approved group
+    select decode(count(*),0,'f','t') into exists_p
     from dual where exists (
         select 'x'
-          from acs_object_grantee_priv_map
+          from acs_object_grantee_priv_map ogpm,
+               rel_seg_approved_member_map rsmm
          where object_id = permission_p.object_id
-           and 0 = permission_p.party_id
+           and rsmm.member_id = permission_p.party_id
            and privilege = permission_p.privilege
-           and grantee_id = -1);
-    --
+           and ogpm.grantee_id = rsmm.segment_id);
+    if exists_p = 't' then
+        return 't';
+    end if;
     return exists_p;
   end;
   --
