You are here

function social_content_import_run_form_submit in Social Content 7

Same name and namespace in other branches
  1. 7.2 social_content.admin.inc \social_content_import_run_form_submit()

Submit handler for social_content_import_run_form().

Run the selected import (regardless of whether it's enabled on cron). Report back results to the user.

NOTE: This should really be in a batch job, but because cron doesn't currently run on batch it was decided to simulate the request here.

File

./social_content.admin.inc, line 134
Social Content administration area. Provides menu callbacks for the Social Content administration area.

Code

function social_content_import_run_form_submit($form, &$form_state, $social_content_type = NULL) {
  if (isset($form['#storage']) && isset($form['#storage']['social_content_type'])) {
    $social_content_type = $form['#storage']['social_content_type'];
    $settings = social_content_get_settings($social_content_type);
    $result = social_content_run_import($social_content_type, $settings);
    if ($result !== FALSE) {
      $args = array(
        '!social_content_type_name' => $social_content_type['title'],
        '!number' => (int) $result,
      );
      drupal_set_message(t('!social_content_type_name run successfully, imported !number nodes', $args));
    }
    else {
      $args = array(
        '!social_content_type_name' => $social_content_type['title'],
        '!logs_link' => l(t('logs'), 'admin/reports/dblog'),
      );
      if (module_exists('dblog')) {
        $message = t('Errors running !social_content_type_name import.  Please check the !logs_link for more information.', $args);
      }
      else {
        $message = t('Errors running !social_content_type_name import.  Enable the Database logging module to view the errors.', $args);
      }
      drupal_set_message($message, 'error');
    }
  }
}