You are here

function biblio_add_merge_keyword in Bibliography Module 7

Same name and namespace in other branches
  1. 7.2 includes/biblio.admin.inc \biblio_add_merge_keyword()

_state

Parameters

$form:

1 string reference to 'biblio_add_merge_keyword'
biblio_admin_keyword_edit_form in includes/biblio.admin.inc
_state

File

includes/biblio.admin.inc, line 2941
biblio.admin.inc

Code

function biblio_add_merge_keyword($form, &$form_state) {
  if (!empty($form_state['values']['search'])) {
    module_load_include('inc', 'biblio', 'includes/biblio.keywords');
    if ($word = biblio_get_keyword_by_name($form_state['values']['search'])) {

      // We don't want to merge with ourselves :-(.
      if ($word->kid == $form_state['values']['kid']) {
        drupal_set_message(t('You cannot merge a keyword with itself'), 'error');
      }
      elseif (isset($form_state['biblio_add_merge_keywords'][$word->kid])) {
        drupal_set_message(t('Keyword already exists in the merge list'), 'warning');
      }
      else {
        $form_state['biblio_add_merge_keywords'][$word->kid] = $word;
      }
    }
    else {
      drupal_set_message(t('The keyword was not found in the database.  You must select a keyword from the "auto-complete" list of the Keyword search box.'), 'error');
    }
  }
  else {
    drupal_set_message(t('Cannot add an empty value'), 'error');
  }
  $form_state['rebuild'] = TRUE;
}