You are here

function _biblio_get_user_profile_form in Bibliography Module 6.2

Same name and namespace in other branches
  1. 5 biblio.module \_biblio_get_user_profile_form()
  2. 6 biblio.admin.inc \_biblio_get_user_profile_form()
  3. 7 includes/biblio.admin.inc \_biblio_get_user_profile_form()
  4. 7.2 includes/biblio.admin.inc \_biblio_get_user_profile_form()
2 calls to _biblio_get_user_profile_form()
biblio_admin_settings in includes/biblio.admin.inc
Implements hook_settings().
biblio_user in ./biblio.module
Implements hook_user().

File

includes/biblio.admin.inc, line 1625
Administrative files for the biblio module.

Code

function _biblio_get_user_profile_form(&$form, $profile_user = FALSE) {
  global $user;
  $allow_edit = variable_get('biblio_show_user_profile_form', '1');
  $allow_edit = $allow_edit || user_access('administer biblio');
  $form['biblio_profile'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => isset($profile_user) ? t('My publications') : t('Profile pages'),
  );
  if (!$profile_user) {
    $form['biblio_profile']['biblio_show_user_profile_form'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow users to override these settings on their "My account" page'),
      '#return_value' => 1,
      '#description' => t('If this is selected, a form similar to this section will be available to the user when they edit their own account information.  This will allow them to override the global preferences set here.'),
      '#default_value' => variable_get('biblio_show_user_profile_form', '1'),
    );
  }
  $form['biblio_profile']['biblio_show_profile'] = array(
    '#type' => 'checkbox',
    '#title' => isset($profile_user) ? t('Show my publications on my profile page') : t('Show publications on users profile pages'),
    '#return_value' => 1,
    '#disabled' => !$allow_edit,
    '#description' => isset($profile_user) ? t('Selecting this will create a listing of your publications on your profile page') : t('This sets the site wide default, users may change this in their profile'),
  );
  if ($profile_user) {
    $form['biblio_profile']['biblio_show_profile']['#default_value'] = isset($profile_user->biblio_show_profile) ? $profile_user->biblio_show_profile : variable_get('biblio_show_profile', '0');
  }
  else {
    $form['biblio_profile']['biblio_show_profile']['#default_value'] = variable_get('biblio_show_profile', '0');
  }
  $form['#biblio_show_profile'] = $form['biblio_profile']['biblio_show_profile']['#default_value'];
  $form['biblio_profile']['biblio_my_pubs_menu'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show "My publications" item in the navigation menu'),
    '#disabled' => !$allow_edit,
    '#return_value' => 1,
    '#description' => '',
  );
  if ($profile_user) {
    $form['biblio_profile']['biblio_my_pubs_menu']['#default_value'] = isset($profile_user->biblio_my_pubs_menu) ? $profile_user->biblio_my_pubs_menu : variable_get('biblio_my_pubs_menu', '0');
  }
  else {
    $form['biblio_profile']['biblio_my_pubs_menu']['#default_value'] = variable_get('biblio_my_pubs_menu', '0');
  }
  $form['#biblio_my_pubs_menu'] = $form['biblio_profile']['biblio_my_pubs_menu']['#default_value'];
  if ($profile_user) {
    $db_result = db_query("SELECT cd.lastname, cd.firstname, cd.initials, cd.cid FROM {biblio_contributor_data} cd\n            ORDER by cd.lastname ASC ");
    $options = array();
    $options[0] = t('(None)');
    $cid = isset($profile_user->biblio_contributor_id) ? $profile_user->biblio_contributor_id : '';
    while ($row = db_fetch_object($db_result)) {
      $options[$row->cid] = "{$row->lastname}, {$row->firstname} {$row->initials} ";
      if (empty($cid) && isset($profile_user->biblio_lastname) && !empty($profile_user->biblio_lastname)) {
        if (trim($row->lastname) == trim($profile_user->biblio_lastname)) {
          $cid = $row->cid;
          $profile_user->biblio_lastname = '';
        }
      }
    }
    $form['biblio_profile']['biblio_lastname'] = array(
      '#type' => 'textfield',
      '#title' => t('My last name'),
      '#default_value' => isset($profile_user->biblio_lastname) && !empty($profile_user->biblio_lastname) ? $profile_user->biblio_lastname : '',
      '#description' => t('NOTE: This field is depreciated and you should select your name from the list below.  If you name is not in the list below, then you can enter your last name in this field, and it will be used to select your publications, by doing a string search of author names with this value.'),
    );
    $form['biblio_profile']['biblio_contributor_id'] = array(
      '#type' => 'select',
      '#title' => t('Link My Profile with this Author from the Biblio database'),
      '#default_value' => $cid,
      '#disabled' => !$allow_edit,
      '#options' => $options,
      '#description' => t('This will link your profile to the selected author from the biblio database, then all publications containing this author to be displayed on your "Publications" tab.'),
    );
    $options = array();
    $options['system'] = t('System default');
    $options = array_merge($options, biblio_get_styles());
    $form['biblio_profile']['biblio_user_style'] = array(
      '#type' => 'select',
      '#title' => t('Style'),
      '#default_value' => isset($profile_user->biblio_user_style) ? $profile_user->biblio_user_style : 'system',
      '#options' => $options,
      '#description' => t('Set the bibliographic style of the "list" view.'),
    );
  }
}