You are here

function oa_core_node_delete_redirect in Open Atrium Core 7.2

Helper to redirect to proper landing page after content deletion

1 string reference to 'oa_core_node_delete_redirect'
oa_core_form_node_delete_confirm_alter in ./oa_core.module
Implements hook_form_alter().

File

./oa_core.module, line 1772

Code

function oa_core_node_delete_redirect($form, &$form_state) {
  $id = oa_core_get_section_context();
  if (empty($id)) {
    $id = oa_core_get_space_context();
  }
  if (!empty($form['#node'])) {
    if (in_array($form['#node']->type, array(
      OA_SPACE_TYPE,
      OA_GROUP_TYPE,
    )) && module_exists('oa_subspaces') && !empty($form['#node']->{OA_PARENT_SPACE}[LANGUAGE_NONE][0]['target_id'])) {

      // redirect to parent space when deleting subspace
      $id = $form['#node']->{OA_PARENT_SPACE}[LANGUAGE_NONE][0]['target_id'];
    }
    elseif ($form['#node']->type == OA_SECTION_TYPE) {
      $id = oa_core_get_space_context();
    }
    if ($id == $form['#node']->nid) {
      $id = NULL;

      // don't redirect back to deleted node ever
    }
  }
  if (!empty($id)) {
    $form_state['redirect'] = 'node/' . $id;
  }
}