You are here

function biblio_user_presave in Bibliography Module 7

Same name and namespace in other branches
  1. 7.2 biblio.module \biblio_user_presave()

File

./biblio.module, line 1254
Bibliography Module for Drupal.

Code

function biblio_user_presave(&$edit, $account, $catagory) {
  $keys = array_keys($edit);
  foreach ($keys as $key) {
    if (strpos($key, 'biblio_') !== FALSE && isset($edit[$key])) {
      if (isset($account->data['biblio_id_change_count']) && $account->data['biblio_id_change_count'] > 2 && $key == 'biblio_contributor_id' && $edit[$key] != 0) {
        $edit[$key] = 0;
      }
      $edit['data'][$key] = $edit[$key];
      if ($key == 'biblio_contributor_id') {
        if ($edit[$key] != 0 && $edit[$key] != $account->data[$key]) {
          $edit['biblio_id_change_count']++;
        }
        db_update('biblio_contributor_data')
          ->condition('drupal_uid', $account->uid)
          ->fields(array(
          'drupal_uid' => 0,
        ))
          ->execute();
        db_update('biblio_contributor_data')
          ->condition('cid', $edit['biblio_contributor_id'])
          ->fields(array(
          'drupal_uid' => $account->uid,
        ))
          ->execute();
      }
    }
  }
}