You are here

function biblio_admin_author_edit_form_merge_link in Bibliography Module 7

_state

Parameters

array $form:

1 call to biblio_admin_author_edit_form_merge_link()
biblio_admin_author_edit_form_submit in includes/biblio.admin.inc
_state

File

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

Code

function biblio_admin_author_edit_form_merge_link($form_state) {
  $op = $form_state['triggering_element']['#value'];
  $merge_authors = array();
  $cid = $form_state['values']['cid'];
  foreach ($form_state['values']['candidates'] as $ccid => $options) {
    if ($options['link']) {
      db_update('biblio_contributor_data')
        ->fields(array(
        'aka' => $options['link'],
        'alt_form' => 0,
      ))
        ->condition('cid', $ccid)
        ->execute();
    }
    else {
      db_update('biblio_contributor_data')
        ->fields(array(
        'aka' => 0,
        'alt_form' => 0,
      ))
        ->condition(db_or()
        ->condition('cid', $cid)
        ->condition('cid', $ccid))
        ->execute();
    }
    if ($options['merge']) {
      db_update('biblio_contributor')
        ->fields(array(
        'cid' => $cid,
        'merge_cid' => $ccid,
      ))
        ->condition('cid', $ccid)
        ->execute();
    }
    else {
      db_update('biblio_contributor')
        ->fields(array(
        'cid' => $ccid,
        'merge_cid' => 0,
      ))
        ->condition('merge_cid', $ccid)
        ->execute();
    }
    if ($options['merge'] && $options['retain']) {
      db_update('biblio_contributor_data')
        ->fields(array(
        'alt_form' => $options['retain'] ? $options['retain'] : 0,
        'aka' => $options['retain'] ? $cid : 0,
      ))
        ->condition('cid', $ccid)
        ->execute();
    }
    elseif ($options['merge'] && !$options['retain']) {
      db_delete('biblio_contributor_data')
        ->condition('cid', $ccid)
        ->execute();
    }
  }
}