You are here

function linkchecker_admin_settings_form_validate in Link checker 6.2

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

File

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

Code

function linkchecker_admin_settings_form_validate($form, &$form_state) {
  $form_state['values']['linkchecker_disable_link_check_for_urls'] = trim($form_state['values']['linkchecker_disable_link_check_for_urls']);
  $form_state['values']['linkchecker_ignore_response_codes'] = trim($form_state['values']['linkchecker_ignore_response_codes']);
  $ignore_response_codes = preg_split('/(\\r\\n?|\\n)/', $form_state['values']['linkchecker_ignore_response_codes']);
  foreach ($ignore_response_codes as $ignore_response_code) {
    if (!_linkchecker_isvalid_response_code($ignore_response_code)) {
      form_set_error('linkchecker_ignore_response_codes', t('Invalid response code %code found.', array(
        '%code' => $ignore_response_code,
      )));
    }
  }

  // Prevent the removal of RFC documentation domains. This are the official and
  // reserved documentation domains and not "example" hostnames!
  $linkchecker_disable_link_check_for_urls = array_filter(preg_split('/(\\r\\n?|\\n)/', $form_state['values']['linkchecker_disable_link_check_for_urls']));
  $form_state['values']['linkchecker_disable_link_check_for_urls'] = implode("\n", array_unique(array_merge(explode("\n", LINKCHECKER_RESERVED_DOCUMENTATION_DOMAINS), $linkchecker_disable_link_check_for_urls)));

  // Validate impersonation user name.
  $linkchecker_impersonate_user = user_load(array(
    'name' => $form_state['values']['linkchecker_impersonate_user'],
  ));
  if (empty($linkchecker_impersonate_user->uid)) {
    form_set_error('linkchecker_impersonate_user', t('User account %name cannot found.', array(
      '%name' => $form_state['values']['linkchecker_impersonate_user'],
    )));
  }
}