You are here

function flag_import_form_submit in Flag 6.2

Same name and namespace in other branches
  1. 7.3 includes/flag.export.inc \flag_import_form_submit()
  2. 7.2 includes/flag.export.inc \flag_import_form_submit()

Submit handler; Import a flag.

File

includes/flag.export.inc, line 133
Import/Export functionality provided by Flag module.

Code

function flag_import_form_submit($form, &$form_state) {
  module_load_include('inc', 'flag', 'includes/flag.admin');
  foreach ($form_state['flags'] as $flag) {
    $flag
      ->save();
    if (!empty($flag->status)) {
      $flag
        ->enable();
    }
    if ($flag->is_new) {
      drupal_set_message(t('Flag @name has been imported.', array(
        '@name' => $flag->name,
      )));
    }
    else {
      drupal_set_message(t('Flag @name has been updated.', array(
        '@name' => $flag->name,
      )));
    }
  }
  _flag_clear_cache();
  $form_state['redirect'] = 'admin/build/flags';
}