Forum OpenACS Q&A: Re: Groups as members of groups

Collapse
Posted by Tony Kirkham on
Dave, thank you very much. I had searched for info on this topic without much success. The postings from Tom Jackson were quite helpful. They have given me a better idea about how the system may have been intended to be used and certainly how it can be used. The reason I want a membership relation between groups and groups as opposed to composition is so that members of a group do not show up as members of the supergroup.

I notice that Tom, in the example code, does not use the tcl api but, instead uses the more direct sql api. I am referring to the tcl calls group::add_member and group::remove_member. With an understanding of Tom's explanation of the system, I am still not sure the purpose of the group::add_member call. It is the one that, if the rel_type passed in is not "membership_rel" it creates a "membership_rel" anyway, in addition to a relation of the desired type:
ad_proc -public group::add_member
...
if { ![string equal $rel_type "membership_rel"] } {
# Add them with a membership_rel first
relation_add -member_state $member_state "membership_rel" $group_id $user_id
}

relation_add -member_state $member_state $rel_type $group_id $user_id
...

I now assume that this was intended to only be used for subtypes of the membership_rel but, I am still not sure why both relations would get created unless it is needed to make all subtypes of membership_rel show up in the membership_rel queries as well. Is that assumption true?

With that in mind, is it true that if I create my own rel_type I should not use the provided group::member_add call but write my own using the sql api for relationship creation and deletion, unless my rel_type is truly a subtype of the established membership_rel?

I also do not understand relational segments. Tom mentions them but I don't see anywhere in his code examples where a record would get created in the rel_segments table or where these relational segments might be used. Are they simply the members of a group with a particular rel_type or is there more to them being that there is a table defined to contain them. It looks like membership_rel and admin_rel are created by default as rel_segments but not composition_rel. Is there any info on the what and why of relational segments?

Collapse
Posted by Tom Jackson on
I also do not understand relational segments.

Here is a link to a test page in OpenACS which uses a rel_segment:

rel-segments-test.sql

A relational segment creates a subgroup where all members have the same rel_type to the original parent group.

Example from the above:

 -- the segment of all parties that are blah members of G
 seg_G_blahs := rel_segment__new(null,
   ''rel_segment'',
   now(),
   null,
   null,
   null,
   null,                                  
   ''Blahs of Group G'',
   G, 
   ''blah_member_rel'',
   null
);
Collapse
Posted by Tom Jackson on

Here is a search on all of OpenACS code, many examples of creating specialized rel_segments:

Relational Segments Search

Note that this is a 5-10 second search due to the size of the source code

Collapse
Posted by Tom Jackson on

Uggg, the URL got mangled by the enhanced text.

Retry:

Relational Segments Search