function profile_admin_overview

7.x profile.admin.inc profile_admin_overview($form)
6.x profile.admin.inc profile_admin_overview()

Form builder to display a listing of all editable profile fields.

See also

profile_admin_overview_submit()

Related topics

2 string references to 'profile_admin_overview'
profile_menu in drupal-6.x/modules/profile/profile.module
Implementation of hook_menu().
profile_theme in drupal-6.x/modules/profile/profile.module
Implementation of hook_theme()

File

drupal-6.x/modules/profile/profile.admin.inc, line 14
Administrative page callbacks for the profile module.

Code

function profile_admin_overview() {
  $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_fields} ORDER BY category, weight');

  $form = array();
  $categories = array();
  while ($field = db_fetch_object($result)) {
    // Collect all category information
    $categories[] = $field->category;

    // Save all field information
    $form[$field->fid]['name'] = array('#value' => check_plain($field->name));
    $form[$field->fid]['title'] = array('#value' => check_plain($field->title));
    $form[$field->fid]['type'] = array('#value' => $field->type);
    $form[$field->fid]['category'] = array('#type' => 'select', '#default_value' => $field->category, '#options' => array());
    $form[$field->fid]['weight'] = array('#type' => 'weight', '#default_value' => $field->weight);
    $form[$field->fid]['edit'] = array('#value' => l(t('edit'), "admin/user/profile/edit/$field->fid"));
    $form[$field->fid]['delete'] = array('#value' => l(t('delete'), "admin/user/profile/delete/$field->fid"));
  }

  // Add the cateogory combo boxes
  $categories = array_unique($categories);
  foreach ($form as $fid => $field) {
    foreach ($categories as $cat => $category) {
      $form[$fid]['category']['#options'][$category] = $category;
    }
  }

  // Display the submit button only when there's more than one field
  if (count($form) > 1) {
    $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
  }
  else {
    // Disable combo boxes when there isn't a submit button
    foreach ($form as $fid => $field) {
      unset($form[$fid]['weight']);
      $form[$fid]['category']['#type'] = 'value';
    }
  }
  $form['#tree'] = TRUE;

  $addnewfields = '<h2>' . t('Add new field') . '</h2>';
  $addnewfields .= '<ul>';
  foreach (_profile_field_types() as $key => $value) {
    $addnewfields .= '<li>' . l($value, "admin/user/profile/add/$key") . '</li>';
  }
  $addnewfields .= '</ul>';
  $form['addnewfields'] = array('#value' => $addnewfields);

  return $form;
}