Index: openacs-4/packages/dotlrn/sql/postgresql/privacy-init.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/sql/postgresql/privacy-init.sql,v
diff -u -r1.1.2.1 -r1.1.2.2
--- openacs-4/packages/dotlrn/sql/postgresql/privacy-init.sql 21 Feb 2004 02:34:38 -0000 1.1.2.1
+++ openacs-4/packages/dotlrn/sql/postgresql/privacy-init.sql 21 Feb 2004 05:20:56 -0000 1.1.2.2
@@ -119,3 +119,98 @@
select guest_p into v_guest_p from dotlrn_guest_status where user_id = v_user_id;
return v_guest_p;
end;' language 'plpgsql';
+
+create or replace function dotlrn_privacy__set_user_non_guest (integer)
+returns integer as '
+declare
+ v_user_id alias for $1;
+ v_rel_id integer;
+ cur record;
+begin
+ for cur in
+ select r.rel_id
+ from acs_rels r,
+ membership_rels m
+ where m.rel_id = r.rel_id
+ and (r.rel_type = ''dotlrn_guest_rel''
+ or r.rel_type = ''dotlrn_non_guest_rel'')
+ and r.object_id_one = acs__magic_object_id(''registered_users'')
+ and r.object_id_two = v_user_id
+ loop
+ perform membership_rel__delete(cur.rel_id);
+ end loop;
+ v_rel_id := membership_rel__new(
+ null,
+ ''dotlrn_non_guest_rel'',
+ acs__magic_object_id(''registered_users''),
+ v_user_id,
+ ''approved'',
+ null,
+ null
+ );
+
+ return 0;
+end;' language 'plpgsql';
+
+create or replace function dotlrn_privacy__set_user_guest (integer)
+returns integer as '
+declare
+ v_user_id alias for $1;
+ v_rel_id integer;
+ cur record;
+begin
+ for cur in
+ select r.rel_id
+ from acs_rels r,
+ membership_rels m
+ where m.rel_id = r.rel_id
+ and (r.rel_type = ''dotlrn_guest_rel''
+ or r.rel_type = ''dotlrn_non_guest_rel'')
+ and r.object_id_one = acs__magic_object_id(''registered_users'')
+ and r.object_id_two = v_user_id
+ loop
+ perform membership_rel__delete(cur.rel_id);
+ end loop;
+ v_rel_id := membership_rel__new(
+ null,
+ ''dotlrn_guest_rel'',
+ acs__magic_object_id(''registered_users''),
+ v_user_id,
+ ''approved'',
+ null,
+ null
+ );
+
+ return 0;
+end;' language 'plpgsql';
+
+create or replace function dotlrn_privacy__grant_rd_prv_dt_for_rel (integer,varchar)
+returns integer as '
+declare
+ v_object_id alias for $1;
+ v_rel_type alias for $2;
+ v_segment_id integer;
+begin
+ select segment_id into v_segment_id
+ from rel_segments
+ where group_id = acs__magic_object_id(''registered_users'')
+ and rel_type = v_rel_type;
+ perform acs_permission__grant_permission(v_object_id,v_segment_id,''read_private_data'');
+ return 0;
+end;' language 'plpgsql';
+
+create or replace function dotlrn_privacy__revoke_rd_prv_dt_for_rel (integer,varchar)
+returns integer as '
+declare
+ v_object_id alias for $1;
+ v_rel_type alias for $2;
+ v_segment_id integer;
+begin
+ select segment_id into v_segment_id
+ from rel_segments
+ where group_id = acs__magic_object_id(''registered_users'')
+ and rel_type = v_rel_type;
+ perform acs_permission__revoke_permission(v_object_id,v_segment_id,''read_private_data'');
+ return 0;
+end;' language 'plpgsql';
+
Index: openacs-4/packages/dotlrn/tcl/privacy-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/privacy-procs-postgresql.xql,v
diff -u -r1.1.2.2 -r1.1.2.3
--- openacs-4/packages/dotlrn/tcl/privacy-procs-postgresql.xql 21 Feb 2004 03:17:54 -0000 1.1.2.2
+++ openacs-4/packages/dotlrn/tcl/privacy-procs-postgresql.xql 21 Feb 2004 05:20:56 -0000 1.1.2.3
@@ -5,67 +5,19 @@
- declare
- v_rel_id integer;
- begin
- for cur in (select r.rel_id from acs_rels r,
- membership_rels m
- where m.rel_id = r.rel_id
- and (r.rel_type = 'dotlrn_guest_rel'
- or r.rel_type = 'dotlrn_non_guest_rel')
- and r.object_id_one = acs__magic_object_id('registered_users')
- and r.object_id_two = :user_id)
- loop
- membership_rel__del(cur.rel_id);
- end loop;
- v_rel_id := membership_rel__new(
- null,
- 'dotlrn_non_guest_rel',
- acs__magic_object_id('registered_users'),
- :user_id,
- 'approved'
- );
- end;
+ select dotlrn_privacy__set_user_non_guest(:user_id)
- declare
- v_rel_id integer;
- begin
- for cur in (select r.rel_id from acs_rels r,
- membership_rels m
- where m.rel_id = r.rel_id
- and (r.rel_type = 'dotlrn_guest_rel'
- or r.rel_type = 'dotlrn_non_guest_rel')
- and r.object_id_one = acs__magic_object_id('registered_users')
- and r.object_id_two = :user_id)
- loop
- membership_rel__del(cur.rel_id);
- end loop;
- v_rel_id := membership_rel__new(
- null,
- 'dotlrn_guest_rel',
- acs__magic_object_id('registered_users'),
- :user_id,
- 'approved'
- );
- end;
+ select dotlrn_privacy__set_user_guest(:user_id)
- declare
- v_segment_id integer;
- begin
- select segment_id into v_segment_id
- from rel_segments
- where group_id = acs__magic_object_id('registered_users')
- and rel_type = :rel_type;
- acs_permission__${action}_permission(:object_id,v_segment_id,'read_private_data');
- end;
+ select dotlrn_privacy__${action}_rd_prv_dt_for_rel(:object_id,:rel_type)