Forum OpenACS Q&A: Groups API Question

Collapse
Posted by Radam Batnag on
I have two types of groups: block sections, and free sections.

Block sections are composed of one or more free sections.
Free sections are associated with zero or one block section.

Requirements:

1. If a user is added as a member of a block section, he is automatically
a member of all the free sections associated with the block section.

2. If a user is added as a member of a free section, he should not
be automatically added as a member of the block section associated with
the free section.

3. If a member of a block section is removed from the block section,
he should be automatically removed from all associated free sections.

To make the example more concrete:

The group Nerds is a block section, and it has two free sections:
Nerdy Chemistry 101, and Nerdy Algebra 101. Juan joins the group
Nerds and is automatically enrolled to Nerdy Chemistry 101 and
Nerdy Algebra 101. Maria does not join the group Nerds but joins
the group Nerdy Algebra 101.

A query on group_member_map on Nerdy Algebra 101 should list both Juan
and Maria as members. However, a query on group_member_map on Nerds should
not include Maria.

I tried making a free section a component of a block sections,
but this does not satisfy requirement #2 above. If I add a user
to a free section, the user is also added to the associated block section.

I tried making a free section a member of a block section, but the
groups API won't allow me. membership_rel__new(integer, integer) requires
that the second parameter should be a Person object.

How do I represent this organization with the Groups API?

Collapse
Posted by Stephen . on
Make free sections component groups of block sections.  Visit /admin/group-types/one?group_type=group. 'Add a group of this type', Nerdy Chemistry. Click 'Nerdy Chemistry' and 'Add Component', Nerds. Add Juan as member of Nerds. Add salt to taste.
Collapse
Posted by Radam Batnag on

I forgot to add to my previous post: I'm using Jonathan Mardsen's OpenACS 4 RPMs, which seem to be based on a Jan. 14, 2002 CVS snapshot. Red Hat 7.1, PostgreSQL 7.1.3. AOLServer 3.3 + ad13.

And maybe I need to clarify my original post.

Nope, making a free section a component of a block section won't work. Let me restate Requirement #2 above: A user U who joins a free section F which is a component of block section B but does not explicitly join B should not be made a member of B.

However, according to the ACS documentation (Part 6, ACS Groups Requirements, of the ACS 4 Kernel Documentation):

50.0 Membership

A party P is a member of group G

- when a direct membership exists between P and G
- or when there exists a direct membership relationship between P and
  some group Gc and Gc has a composition relationship with G

So the fairly obvious way of using component groups will not work.

Another fairly obvious solution is to create my own user-group mapping, which I do not want to do. My hunch is that the problem I face is a common one, and either:

  1. veterans in the community have implemented relationship mappings similar to the one I'm trying to create using the Groups API, and I just don't understand the API enough, or
  2. the Groups API lacks the support for these kinds of relationships, which means we have some more work to do...

I think #1 is more probable than #2, which is why I asked first instead of going directly to add code and salt and pepper...

Collapse
Posted by Stephen . on
Sorry, "Make block sections component groups of free sections" is what I meant to say, I got the instructions right though...  This doesn't work for you?
Collapse
Posted by Radam Batnag on
Yes!!! That worked. How stupid of me.
My mental model is block sections are composed of free sections, so that somehow prevented me from thinking of making block sections components of free sections.

Thanks!