You are here

function organigrams_form_import_items_submit in Organigrams 7

Submit function for organigrams_form_import_items.

File

./organigrams.admin.inc, line 721
Defines the administration forms for managing organigrams.

Code

function organigrams_form_import_items_submit($form, &$form_state) {

  // Only add a new key and rebuild the form when the import data is submitted.
  if (empty($form_state['confirm_import'])) {
    $form_state['confirm_import'] = TRUE;
    $form_state['rebuild'] = TRUE;
  }
  else {

    // If the import is confirmed, execute the actual import.
    $status = organigrams_import_items($form['#organigram']->oid, json_decode($form_state['values']['import']));

    // Let the user know if the imported succeeded.
    if ($status === TRUE) {
      drupal_set_message(t('Successfully imported new items.'));

      // Redirect to the item overview.
      drupal_goto('admin/structure/organigrams/' . $form['#organigram']->machine_name);
    }
    else {
      drupal_set_message($status, 'error');
    }
  }
}