Index: openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql	21 Mar 2003 14:57:44 -0000	1.6
+++ openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql	17 May 2003 01:46:41 -0000	1.7
@@ -143,6 +143,18 @@
    (v_object_id_one, v_object_id_two, :new.rel_id, v_object_id_one,
     v_rel_type, 'composition_rel');
 
+  for members in (select distinct member_id, rel_type
+               from group_approved_member_map m
+               where group_id = v_object_id_two
+                 and not exists (select 1
+		                 from group_element_map
+		                 where group_id = v_object_id_one
+		                   and element_id = m.member_id
+		                   and rel_id = m.rel_id))
+  loop
+    party_approved_member.add(v_object_id_one, members.member_id, members.rel_type);
+  end loop;
+
   -- Make my elements be elements of my new composite group
   insert into group_element_index
    (group_id, element_id, rel_id, container_id,
@@ -173,6 +185,19 @@
       v_rel_type, 'composition_rel');
 
     -- Add rows for my elements
+
+    for members in (select distinct member_id, rel_type
+                    from group_approved_member_map m
+                    where group_id = v_object_id_two
+                      and not exists (select 1
+		                      from group_element_map
+		                      where group_id = map.group_id
+		                        and element_id = m.member_id
+		                        and rel_id = m.rel_id))
+    loop
+      party_approved_member.add(map.group_id, members.member_id, members.rel_type);
+    end loop;
+
     insert into group_element_index
      (group_id, element_id, rel_id, container_id,
       rel_type, ancestor_rel_type)
@@ -228,6 +253,15 @@
     and component_id = map.component_id;
 
     if n_rows = 0 then
+
+      for members in (select member_id, rel_type
+                      from group_approved_member_map
+                      where group_id = map.group_id
+                        and container_id = map.component_id)
+      loop
+        party_approved_member.remove(map.group_id, members.member_id, members.rel_type);
+      end loop;
+
       delete from group_element_index
       where group_id = map.group_id
       and container_id = map.component_id
@@ -236,7 +270,6 @@
 
   end loop;
 
-
   for map in (select *
               from group_component_map
 	      where group_id in (select group_id
@@ -264,18 +297,27 @@
     and component_id = map.component_id;
 
     if n_rows = 0 then
+
+      for members in (select member_id, rel_type
+                      from group_approved_member_map
+                      where group_id = map.group_id
+                        and container_id = map.component_id)
+      loop
+        party_approved_member.remove(map.group_id, members.member_id, members.rel_type);
+      end loop;
+
       delete from group_element_index
       where group_id = map.group_id
       and container_id = map.component_id
       and ancestor_rel_type = 'membership_rel';
+
     end if;
 
   end loop;
 end;
 /
 show errors
 
-
 --------------------
 -- PACKAGE BODIES --
 --------------------
