Forum OpenACS Q&A: Manual manipulation of users and groups

One of my clients is looking to use OpenACS as a glorified address book with some specialized Web-based applications, slowly but surely expanding the use of the site for what it was intended, namely an online community.

This means that I'll want to add the users en masse and assigning them to one or more groups apiece. (The users will only be able to log into the site several months after we begin to use the back-end data model.) The input data will come from several different Access databases that are currently scattered across the organization's various international offices.

So what I'm looking to do is take the Access data (in CSV or tab-delimited format) and use it to create a number of users, each of whom will be associated with one or more groups.

I've been reading a lot about the data model, and it generally seems like I'll be able to pull this off pretty easily, even though I'll undoubtedly encounter some e-mail address collisions and some out-of-date personal data. That said, I have a few questions:

  • Since most users won't be logging in for the first few months that we use this site, should I add them as people, or as users? Can I easily turn a person into a user? This doesn't seem worthwhile, given that everyone will eventually log into the system, but I want to remain somewhat loyal to the data model.
  • I found ad_user_new without too much trouble. But how do I easily associate a user with a group? (I can create the groups in advance via the Web.) It looks like I should use relation_add; am I right?
  • I'll want to keep track of the user's address, phone number, and other such personal data that isn't in the standard data model for users. Assuming that each group (or group type) will have its own set of attributes, what's the best way for me to add this information manually?
  • Are there any massive pitfalls that I should worry about when mucking with users and groups manually? I did this for a previous client in OpenACS 3.x, and it took me a while to get it just right -- that's why I'm asking this time, rather than experimenting...

Thanks for any and all advice!

Collapse
Posted by Hamilton Chua on
Hi,

Please see this post on the bboard

https://openacs.org/bboard/q-and-a-fetch-msg.tcl?msg_id=0003GP&topic_id=OpenACS&topic=11

It has an answer for your question on making users members of a group.

Regards

Collapse
Posted by Reuven Lerner on

Thanks! I knew that there had to be a function somewhere; it hadn't occurred to me that the function was written in Pl/PgSQL, rather than Tcl.

I'm also having fun reading through https://openacs.org/new-file-storage/download/permissions-notes-vadim.html?version_id=229, which is explaining permissions and the data model rather nicely; even if it doesn't directly address this issue, that document will undoubtedly help me to understand the rest of the system.

Collapse
Posted by Roberto Mello on
Ugh! This reminds me that I need to finish "porting" the 'ACS 4 Permissions Tediously Explained' document from HTML to Docbook XML before release.
Collapse
Posted by Andrew Piskorski on
See also these two old Group definitions and use and Groups API in 4.x threads.
Collapse
Posted by Reuven Lerner on

Thanks to everyone for their advice several months ago, I've managed to get just about everything done that I wanted. However, I'm struggling over how to create a new group and give it a composition relation with the main group for the current subsite.

That is: I have several subsites, each of which has its own group of users. (So for the "foo" subsite, OpenACS gives me a "foo parties" group.) I'm trying to create a form that lets me enter information about a new user and the name of a group to which this user should be added. If the named group exists, then we simply add this user to the group. If the named group doesn't exist, then I create the group, give it a composition relation to the subsite's group, and then add the user to the group.

I've been pouring over the documentation, actual OpenACS code, and help that people have given on the bboard, and I'm finding myself stuff. That is, I have the following code:

ns_log Notice "


About to create the new group (community) with id '$group_id'


"

db_transaction {

    # Add the new group
    group::new -group_id $group_id -context_id [ad_conn package_id] -group_name $community_name "group" 

    # Get the group ID for this subsite's default group
    set add_to_group_id [site_node_closest_ancestor_package "acs-subsite"]

    # Create a composition relation between our the subsite's group and our new group
    ns_log Notice "About to execute:


relation_add composition_rel $add_to_group_id $group_id


"

    set relation_id [relation_add "composition_rel" $add_to_group_id $group_id]
    ns_log Notice "New relation_id is $relation_id


"
}

Everything seems to work fine until I invoke relation_add, which fails on me. My "about to execute" log message looks like:

relation_add composition_rel 7272 7653

which seems pretty normal to me, since 7272 is the group for the current subsite, and 7653 is the ID of the new group I just created and want to attach. So I'm guessing that I have failed to understand something having to do with creating a new group (which appears to be working just fine) and/or giving it a composition relation with the subsite's group.

When I run the Pl/PgSQL query by hand, it looks like this:

select composition_rel__new(NULL,'composition_rel','7299',7606,'2537','212.29.241.228');
NOTICE:  Adding missing FROM-clause entry for table "acs_object_id_seq"
NOTICE:  identifier "acs_object__initialize_attributes" will be truncated to "acs_object__initialize_attribut"
NOTICE:  identifier "acs_object_type_get_tree_sortkey" will be truncated to "acs_object_type_get_tree_sortke"
NOTICE:  identifier "acs_object_type_get_tree_sortkey" will be truncated to "acs_object_type_get_tree_sortke"
ERROR:  -20001: composition_rel  violation: Invalid object types. Object 7299 () must be of type  Object 7606 () must be of type 

So:

  • Am I making a mistake when creating my group? (It appears in the groups table, but perhaps that's not enough?)
  • Am I making a mistake when adding the composition relation?
  • Is this simply a bug in OpenACS that I should have been smart enough to avoid?