Index: openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql,v diff -u -r1.3.2.1 -r1.3.2.2 --- openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql 15 Feb 2003 03:23:55 -0000 1.3.2.1 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-create.sql 15 Feb 2003 20:56:27 -0000 1.3.2.2 @@ -301,3 +301,22 @@ end; / show errors; + +-- Create the default context. +declare + object_id integer; +begin + object_id := acs_object.new ( + object_id => -3 + ); + + insert into acs_magic_objects + (name, object_id) + values + ('default_context', object_id); + + commit; +end; +/ +show errors; + Index: openacs-4/packages/acs-kernel/sql/oracle/acs-install.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-install.sql,v diff -u -r1.3.2.2 -r1.3.2.3 --- openacs-4/packages/acs-kernel/sql/oracle/acs-install.sql 15 Feb 2003 03:23:55 -0000 1.3.2.2 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-install.sql 15 Feb 2003 20:56:27 -0000 1.3.2.3 @@ -58,9 +58,10 @@ set object_type = 'application_group' where object_id = -2; - segment_id := rel_segment__new( + segment_id := rel_segment.new( segment_name => 'Main Site Members', - group_id => -2 + group_id => -2, + rel_type => 'membership_rel' ); admin_id := apm_service.new ( Index: openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql,v diff -u -r1.6.2.2 -r1.6.2.3 --- openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql 15 Feb 2003 03:23:55 -0000 1.6.2.2 +++ openacs-4/packages/acs-kernel/sql/oracle/acs-objects-create.sql 15 Feb 2003 20:56:27 -0000 1.6.2.3 @@ -527,7 +527,7 @@ delete from acs_attribute_values where object_id = acs_object.delete.object_id; -- Delete directly assigned permissions - delete from acs_permissions where object_id = acs_object.delete.object_id; + -- delete from acs_permissions where object_id = acs_object.delete.object_id; for object_type in (select table_name, id_column 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.3.4.1 -r1.3.4.2 --- openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql 15 Feb 2003 03:23:55 -0000 1.3.4.1 +++ openacs-4/packages/acs-kernel/sql/oracle/groups-body-create.sql 15 Feb 2003 20:56:27 -0000 1.3.4.2 @@ -10,36 +10,6 @@ -- TRIGGERS -- -------------- -create or replace trigger group_element_index_in_tr -before insert on group_element_index -for each row -declare - v_member_state membership_rels.member_state%TYPE; -begin - - select member_state into v_member_state - from membership_rels - where rel_id = :new.rel_id; - - -- Only membership_rels are tracked in the party_approved_member_map - - if v_member_state = 'approved' then - party_approved_member.add(:new.group_id, :new.element_id, :new.rel_type); - end if; - -end; -/ -show errors; - -create or replace trigger group_element_index_del_tr -after delete on group_element_index -for each row -begin - party_approved_member.remove(:old.group_id, :old.element_id, :old.rel_type); -end; -/ -show errors; - create or replace trigger membership_rels_up_tr before update on membership_rels for each row @@ -93,6 +63,10 @@ (v_object_id_one, v_object_id_two, :new.rel_id, v_object_id_one, v_rel_type, 'membership_rel'); + if :new.member_state = 'approved' then + party_approved_member.add(v_object_id_one, v_object_id_two, v_rel_type); + end if; + -- For all groups of which I am a component, insert a -- row in the group_member_index. for map in (select distinct group_id @@ -104,11 +78,41 @@ values (map.group_id, v_object_id_two, :new.rel_id, v_object_id_one, v_rel_type, 'membership_rel'); + + if :new.member_state = 'approved' then + party_approved_member.add(map.group_id, v_object_id_two, v_rel_type); + end if; + end loop; end; / show errors +create or replace trigger membership_rels_del_tr +before delete on membership_rels +for each row +declare + v_error varchar2(4000); +begin + -- First check if removing this relation would violate any relational constraints + v_error := rel_constraint.violation_if_removed(:old.rel_id); + if v_error is not null then + raise_application_error(-20000,v_error); + end if; + + for map in (select group_id, element_id, rel_type + from group_element_index + where rel_id = :new.rel_id) + loop + party_approved_member.remove(map.group_id, map.element_id, map.rel_type); + end loop; + + delete from group_element_index + where rel_id = :old.rel_id; +end; +/ +show errors; + create or replace trigger composition_rels_in_tr after insert on composition_rels for each row @@ -187,24 +191,6 @@ / show errors -create or replace trigger membership_rels_del_tr -before delete on membership_rels -for each row -declare - v_error varchar2(4000); -begin - -- First check if removing this relation would violate any relational constraints - v_error := rel_constraint.violation_if_removed(:old.rel_id); - if v_error is not null then - raise_application_error(-20000,v_error); - end if; - - delete from group_element_index - where rel_id = :old.rel_id; -end; -/ -show errors; - -- -- TO DO: See if this can be optimized now that the member and component -- mapping tables have been combined Index: openacs-4/packages/acs-kernel/sql/oracle/rel-segments-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/rel-segments-create.sql,v diff -u -r1.1.4.1 -r1.1.4.2 --- openacs-4/packages/acs-kernel/sql/oracle/rel-segments-create.sql 15 Feb 2003 03:23:55 -0000 1.1.4.1 +++ openacs-4/packages/acs-kernel/sql/oracle/rel-segments-create.sql 15 Feb 2003 20:56:27 -0000 1.1.4.2 @@ -240,7 +240,7 @@ -- Triggers to maintain party_approved_member_map when parties are create or replaced or -- destroyed. -create or replace trigger parties_in_tr before insert on parties +create or replace trigger parties_in_tr after insert on parties for each row begin insert into party_approved_member_map Index: openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-4.6-4.6.1.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/upgrade/Attic/upgrade-4.6-4.6.1.sql,v diff -u -r1.1.2.4 -r1.1.2.5 --- openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-4.6-4.6.1.sql 15 Feb 2003 13:10:25 -0000 1.1.2.4 +++ openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-4.6-4.6.1.sql 15 Feb 2003 20:56:56 -0000 1.1.2.5 @@ -911,7 +911,7 @@ -- Triggers to maintain party_approved_member_map when parties are create or replaced or -- destroyed. -create or replace trigger parties_in_tr before insert on parties +create or replace trigger parties_in_tr after insert on parties for each row begin insert into party_approved_member_map @@ -938,7 +938,7 @@ -- group with that rel_type. This was intentional on the part of the aD folks -- who added relational segments to ACS 4.2. -create or replace trigger rel_segments_in_tr before insert on rel_segments +create or replace trigger rel_segments_in_tr after insert on rel_segments for each row begin insert into party_approved_member_map @@ -1088,60 +1088,108 @@ / show errors; -create or replace trigger group_element_index_in_tr -before insert on group_element_index +create or replace trigger membership_rels_up_tr +before update on membership_rels for each row +begin + + if :new.member_state = :old.member_state then + return; + end if; + + for map in (select group_id, element_id, rel_type + from group_element_index + where rel_id = :new.rel_id) + loop + if :new.member_state = 'approved' then + party_approved_member.add(map.group_id, map.element_id, map.rel_type); + else + party_approved_member.remove(map.group_id, map.element_id, map.rel_type); + end if; + end loop; + +end; +/ +show errors + +create or replace trigger membership_rels_in_tr +after insert on membership_rels +for each row declare - v_member_state membership_rels.member_state%TYPE; + v_object_id_one acs_rels.object_id_one%TYPE; + v_object_id_two acs_rels.object_id_two%TYPE; + v_rel_type acs_rels.rel_type%TYPE; + v_error varchar2(4000); begin + + -- First check if added this relation violated any relational constraints + v_error := rel_constraint.violation(:new.rel_id); + if v_error is not null then + raise_application_error(-20000,v_error); + end if; - select member_state into v_member_state - from membership_rels + select object_id_one, object_id_two, rel_type + into v_object_id_one, v_object_id_two, v_rel_type + from acs_rels where rel_id = :new.rel_id; - -- Only membership_rels are tracked in the party_approved_member_map + -- Insert a row for me in the group_member_index. + insert into group_element_index + (group_id, element_id, rel_id, container_id, + rel_type, ancestor_rel_type) + values + (v_object_id_one, v_object_id_two, :new.rel_id, v_object_id_one, + v_rel_type, 'membership_rel'); - if v_member_state = 'approved' then - party_approved_member.add(:new.group_id, :new.element_id, :new.rel_type); + if :new.member_state = 'approved' then + party_approved_member.add(v_object_id_one, v_object_id_two, v_rel_type); end if; -end; -/ -show errors; + -- For all groups of which I am a component, insert a + -- row in the group_member_index. + for map in (select distinct group_id + from group_component_map + where component_id = v_object_id_one) loop + insert into group_element_index + (group_id, element_id, rel_id, container_id, + rel_type, ancestor_rel_type) + values + (map.group_id, v_object_id_two, :new.rel_id, v_object_id_one, + v_rel_type, 'membership_rel'); -create or replace trigger group_element_index_del_tr -after delete on group_element_index -for each row -begin - party_approved_member.remove(:old.group_id, :old.element_id, :old.rel_type); + if :new.member_state = 'approved' then + party_approved_member.add(map.group_id, v_object_id_two, v_rel_type); + end if; + + end loop; end; / -show errors; +show errors - -create or replace trigger membership_rels_up_tr -before update on membership_rels +create or replace trigger membership_rels_del_tr +before delete on membership_rels for each row +declare + v_error varchar2(4000); begin - - if :new.member_state = :old.member_state then - return; + -- First check if removing this relation would violate any relational constraints + v_error := rel_constraint.violation_if_removed(:old.rel_id); + if v_error is not null then + raise_application_error(-20000,v_error); end if; for map in (select group_id, element_id, rel_type from group_element_index where rel_id = :new.rel_id) loop - if :new.member_state = 'approved' then - party_approved_member.add(map.group_id, map.element_id, map.rel_type); - else - party_approved_member.remove(map.group_id, map.element_id, map.rel_type); - end if; + party_approved_member.remove(map.group_id, map.element_id, map.rel_type); end loop; + delete from group_element_index + where rel_id = :old.rel_id; end; / -show errors +show errors; -- New fast version of acs_object_party_privilege_map