Forum .LRN Q&A: move forum between groups

Collapse
Posted by Michael Cordova on
There is no API (nor UI) to move a forum to another group (class nor community). I know that this feature should be available at (oacs) forums level (maybe at Site-Wide admin pages, or forum admin pages), but I need it now in a .LRN instance. I mean... I'm probably using dotlrn::* funcitons, and I'd like to improve that...

What I'm doing is an admin page to move a forum (given a forum_id) to a target group (given a community_id). Then I go to a confirmation page, where forum name, source and target group names are shown.

I think that the simple thing to do is:

  1. get the context_id (forums package_id of the target group)
  2. update acs_objects
  3. update forums_forums

And I'm figuring out what additional changes should I make... for intance, remove user notifications to that forum if the user is not in the target group...

That's the forums::move function I've wrote

ad_proc -public forums::move {
    {-forum_id ""}
    {-target_community_id ""}
} {
    db_0or1row forums::move_forum::get_target_context_id {}
    db_0or1row forums::move_forum::get_parent_node_id {}
    db_0or1row forums::move_forum::get_target_package_id {}

    acs_object::set_context_id -object_id object_id -context_id context_id
    # DO THIS SQL: set package_id = :target_package_id where forum_id = :forum_id;

    # TODO: deal with user notifications... Remove those from users that doesn't belong to target group?

    # TODO: flush cache
}

Comments are welcome :)

Collapse
Posted by Dave Bauer on
You also need to update the acs_objects.package_id of the forum object as well as the forums.forums.package_id.

You should also update the acs_objects.package_id of all the forums messages to the new package_id.

Dealing with notifications probably also makes sense.