Node Import playing nice with Organic Groups

Oz's picture

Out of the box the Node Import module doesn't play nice with the Organic Groups module. When trying to configure nodes to be posted into a group after the content import, two Drupal database tables are important: og_access_post and og_ancestry. The og_access_post table has two columns, nid and og_public. The og_public field should either 0 or 1 depending on whether you want the post to be public or not. The og_ancestry table also has two columns, nid and group_nid. After importing content, it is import to update these two tables with the appropriate data. I have written two functions that assist in this process.

function _og_post_access_set($start_nid, $end_nid, $value) {
  for($i=$start_nid; $i<=$end_nid; $i++) {
    db_query("UPDATE {og_access_post} SET og_public=$value WHERE nid=$i");
  }
}

function _og_ancestry_set($start_nid, $end_nid, $group_nid) {
  for($i=$start_nid;$i<=$end_nid;$i++) {
    db_query("INSERT INTO {og_ancestry} (nid,group_nid) VALUES (%d,%d)",$i,$group_nid);
  }
}

After the import, just browse the node table and figure out the start nid and end nid for the nodes you just imported, and use these as parameters to these functions. The important step here is to navigate to the "Post Settings" page (admin/content/node-settings) and rebuild the permissions cache to complete this process.

good post

good post