You are here

function shoutbox_group_node_delete in Shoutbox 7

Same name and namespace in other branches
  1. 7.2 shoutbox_group/shoutbox_group.module \shoutbox_group_node_delete()

Implementation of hook_node_delete()

If a group is deleted, group shouts and references must be purged!

File

shoutbox_group/shoutbox_group.module, line 329

Code

function shoutbox_group_node_delete($node) {

  // If the node acts as a group
  if (og_is_group_type('node', $node->type)) {

    // Gather shout ID's
    $shouts = db_query("SELECT shout_id FROM {shoutbox_groups} WHERE nid = %d", $node->nid);

    // Delete all of the shouts
    while ($shout = db_fetch_object($shouts)) {

      // Hook thrown in shoutbox_delete_shout() will delete group reference as well
      shoutbox_delete_shout($shout->shout_id);
    }
  }
}