function og_node_delete_confirm_submit in Organic groups 6
Same name and namespace in other branches
- 5.8 og.module \og_node_delete_confirm_submit()
- 5 og.module \og_node_delete_confirm_submit()
- 5.2 og.module \og_node_delete_confirm_submit()
- 5.3 og.module \og_node_delete_confirm_submit()
- 5.7 og.module \og_node_delete_confirm_submit()
- 6.2 og.module \og_node_delete_confirm_submit()
1 string reference to 'og_node_delete_confirm_submit'
File
- ./
og.module, line 1915
Code
function og_node_delete_confirm_submit($form, &$form_state) {
$deleted_group_nid = $form_state['values']['nid'];
$target_group_nid = $form_state['values']['target'];
$delete_orphans = $form_state['values']['verb'] == OG_DELETE_ORPHANS;
$move_children = $form_state['values']['verb'] >= OG_DELETE_MOVE_NODES;
$count = 0;
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 guards 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);
}
$count++;
}
if ($delete_orphans) {
drupal_set_message(format_plural($count, 'Deleted 1 orphan post.', 'Deleted @count orphan posts.'));
}
elseif ($move_children) {
drupal_set_message(format_plural($count, 'Moved 1 orphan post.', 'Moved @count orphan posts.'));
}
if ($move_children) {
$form_state['redirect'] = 'node/' . $target_group_nid;
}
}