You are here

function og_node_delete_confirm_submit in Organic groups 5.2

Same name and namespace in other branches
  1. 5.8 og.module \og_node_delete_confirm_submit()
  2. 5 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 1450

Code

function og_node_delete_confirm_submit($form_id, $form_values) {
  if ($form_values['verb'] == 1 || $form_values['verb'] == 2) {
    $view = views_get_view('og_ghp_ron');
    $info = views_build_view('items', $view, array(
      $form_values['nid'],
    ));
    foreach ($info['items'] as $item) {
      $node = node_load($item->nid);
      if ($form_values['verb'] == 2) {
        unset($node->og_groups[$form_values['nid']]);
        $node->og_groups[] = $form_values['target'];
        node_save($node);
        return 'node/' . $form_values['target'];
      }
      else {

        // we use 1 here since the group node is already gone by now.
        if (count($node->og_groups) < 1) {
          node_delete($item->nid);
        }
      }
    }
  }
}