You are here

function og_node_delete_confirm_submit in Organic groups 5

Same name and namespace in other branches
  1. 5.8 og.module \og_node_delete_confirm_submit()
  2. 5.2 og.module \og_node_delete_confirm_submit()
  3. 5.3 og.module \og_node_delete_confirm_submit()
  4. 5.7 og.module \og_node_delete_confirm_submit()
  5. 6.2 og.module \og_node_delete_confirm_submit()
  6. 6 og.module \og_node_delete_confirm_submit()

File

./og.module, line 1623

Code

function og_node_delete_confirm_submit($form_id, $form_values) {
  $deleted_group_nid = $form_values['nid'];
  $target_group_nid = $form_values['target'];
  $move_children = $form_values['verb'] == 2;
  $delete_orphans = $form_values['verb'] == 1;
  foreach (og_group_child_nids($deleted_group_nid) as $child_nid) {
    $node = node_load($child_nid);
    unset($node->og_groups[$deleted_group_nid]);
    if ($move_children) {

      // there is an array_unique() in og_save_ancestry which giards against duplicates so don't worry here.
      $node->og_groups[$target_group_nid] = $target_group_nid;
    }
    if ($delete_orphans && count($node->og_groups) == 0) {
      node_delete($node->nid);
    }
    else {
      node_save($node);
    }
  }
  if ($move_children) {
    return 'node/' . $target_group_nid;
  }
}