You are here

function biblio_user in Bibliography Module 6

Same name and namespace in other branches
  1. 5 biblio.module \biblio_user()
  2. 6.2 biblio.module \biblio_user()

Implementation of hook_user().

File

./biblio.module, line 491

Code

function biblio_user($type, &$edit, &$account, $category = NULL) {
  global $user;
  if ($type == 'form' && $category == 'account') {
    $form = array();
    include_once drupal_get_path('module', 'biblio') . '/biblio.admin.inc';
    $show_form = variable_get('biblio_show_user_profile_form', '1') || variable_get('biblio_show_crossref_profile_form', '1') || variable_get('biblio_show_openurl_profile_form', '1');
    $admin_show_form = $user->uid == 1 || user_access('administer users') && user_access('administer biblio') ? TRUE : FALSE;
    if ($admin_show_form || $show_form) {
      $form['biblio_fieldset'] = array(
        '#type' => 'fieldset',
        '#title' => t('Biblio settings'),
        '#weight' => 5,
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      if ($admin_show_form || variable_get('biblio_show_user_profile_form', '1')) {
        _biblio_get_user_profile_form($form['biblio_fieldset'], $account);
      }
      if ($admin_show_form || variable_get('biblio_show_openurl_profile_form', '1')) {
        _biblio_get_user_openurl_form($form['biblio_fieldset'], $account);
      }
      if ($admin_show_form || variable_get('biblio_show_crossref_profile_form', '1')) {
        _biblio_get_user_doi_form($form['biblio_fieldset'], $account);
      }
    }
    return $form;
  }
  if ($type == 'validate' && $category == 'account') {

    // TODO: this is not reached at all
    if (($edit['biblio_my_pubs_menu'] || $edit['biblio_show_profile']) && $edit['biblio_contributor_id'] == 0) {
      $message = t('You did not supply an associated biblio author.');
      drupal_set_message($message, 'warning');
    }
  }
  if ($type == 'after_update' && $category == 'account') {
    menu_rebuild();
  }
  if ($type == 'update' && $category == 'account') {
    if (isset($edit['biblio_contributor_id'])) {
      db_query("UPDATE {biblio_contributor_data} SET drupal_uid = 0 WHERE drupal_uid = %d", $account->uid);
      db_query('UPDATE {biblio_contributor_data} set drupal_uid = %d WHERE cid = %d ', $account->uid, $edit['biblio_contributor_id']);
    }
  }
  if ($type == 'categories') {

    //  return array(array('name' => 'account', 'title' => t('Account settings'), 'weight' => 1));
  }
}