You are here

function linkchecker_admin_settings_form_submit in Link checker 6.2

Same name and namespace in other branches
  1. 5.2 linkchecker.module \linkchecker_admin_settings_form_submit()
  2. 7 linkchecker.admin.inc \linkchecker_admin_settings_form_submit()

File

includes/linkchecker.admin.inc, line 281
Administrative page callbacks for the linkchecker module.

Code

function linkchecker_admin_settings_form_submit($form, &$form_state) {

  // Exclude unnecessary elements.
  unset($form_state['values']['linkchecker_analyze'], $form_state['values']['linkchecker_clear_analyze']);

  // Save form settings.
  system_settings_form_submit($form, $form_state);

  // Re-scan items, if node types or comment or block selection have been changed.
  $additional_nodetypes_selected = array_diff($form_state['values']['linkchecker_scan_nodetypes'], $form['settings']['linkchecker_scan_nodetypes']['#default_value']);
  if (!empty($additional_nodetypes_selected) || $form_state['values']['linkchecker_scan_comments'] > $form['settings']['linkchecker_scan_comments']['#default_value']) {
    $node_types = array_keys(array_filter($form_state['values']['linkchecker_scan_nodetypes']));

    // If one or more node types have been selected.
    if (!empty($node_types)) {
      module_load_include('inc', 'linkchecker', '/includes/linkchecker.batch');
      batch_set(_linkchecker_batch_import_nodes($node_types));

      // If comment scanning of node types has been selected.
      if ($form_state['values']['linkchecker_scan_comments'] > $form['settings']['linkchecker_scan_comments']['#default_value']) {
        batch_set(_linkchecker_batch_import_comments($node_types));
      }
    }
  }

  // If block scanning has been selected.
  if ($form_state['values']['linkchecker_scan_blocks'] > $form['settings']['linkchecker_scan_blocks']['#default_value']) {
    module_load_include('inc', 'linkchecker', '/includes/linkchecker.batch');
    batch_set(_linkchecker_batch_import_boxes());
  }
}