You are here

function linkchecker_link_edit_form_submit in Link checker 7

Same name and namespace in other branches
  1. 5.2 linkchecker.module \linkchecker_link_edit_form_submit()
  2. 6.2 includes/linkchecker.pages.inc \linkchecker_link_edit_form_submit()

Edit link settings form submit handler.

File

./linkchecker.pages.inc, line 272
User page callbacks for the linkchecker module.

Code

function linkchecker_link_edit_form_submit($form, &$form_state) {

  // Force link re-check asap.
  if ($form_state['values']['recheck']) {
    db_update('linkchecker_link')
      ->condition('lid', $form_state['values']['lid'])
      ->fields(array(
      'last_checked' => 0,
    ))
      ->execute();
    drupal_set_message(t('The link %url will be checked again on the next cron run.', array(
      '%url' => $form_state['values']['url'],
    )));
  }
  if ($form_state['values']['method'] != $form['settings']['method']['#default_value']) {

    // Update settings and reset statistics for a quick re-check.
    db_update('linkchecker_link')
      ->condition('lid', $form_state['values']['lid'])
      ->fields(array(
      'method' => $form_state['values']['method'],
      'fail_count' => 0,
      'last_checked' => 0,
      'status' => $form_state['values']['status'],
    ))
      ->execute();
    drupal_set_message(t('The link settings for %url have been saved and the fail counter has been reset.', array(
      '%url' => $form_state['values']['url'],
    )));
  }
  else {

    // Update setting only.
    db_update('linkchecker_link')
      ->condition('lid', $form_state['values']['lid'])
      ->fields(array(
      'method' => $form_state['values']['method'],
      'status' => $form_state['values']['status'],
    ))
      ->execute();
    drupal_set_message(t('The link settings for %url have been saved.', array(
      '%url' => $form_state['values']['url'],
    )));
  }
}