Index: profile.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v retrieving revision 1.1 diff -u -r1.1 profile.admin.inc --- profile.admin.inc 13 Nov 2007 12:28:36 -0000 1.1 +++ profile.admin.inc 21 Nov 2007 00:15:55 -0000 @@ -9,12 +9,40 @@ /** * Menu callback; display a listing of all editable profile fields. */ -function profile_admin_overview() { +function profile_admin_overview(&$form_state, $arg = NULL) { - $result = db_query('SELECT title, name, type, category, fid FROM {profile_fields} ORDER BY category, weight'); + $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_fields} ORDER BY category, weight'); + + + while ($field = db_fetch_object($result)) { + $form['names'][$field->fid] = array('#value' => $field->name); + $form['titles'][$field->fid] = array('#value' => $field->title); + $form['types'][$field->fid] = array('#value' => $field->type); + $form['categories'][$field->fid] = array('#value' => $field->category); + $form['weights'][$field->fid] = array('#type' => 'weight', '#default_value' => $field->weight); + $form['edit'][$field->fid] = array('#type' => 'markup', '#value' => l(t('Edit'), "admin/user/profile/edit/$field->fid")); + $form['delete'][$field->fid] = array('#type' => 'markup', '#value' => l(t('Delete'), "admin/user/profile/delete/$field->fid")); + } + $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); + + $addnewfields = '

'. t('Add new field') .'

'; + $addnewfields .= ''; + $form['addnewfields'] = array('#type' => 'markup', '#value' => $addnewfields); + + return $form; + + + $rows = array(); while ($field = db_fetch_object($result)) { - $rows[] = array(check_plain($field->title), $field->name, _profile_field_types($field->type), $field->category, l(t('edit'), "admin/user/profile/edit/$field->fid"), l(t('delete'), "admin/user/profile/delete/$field->fid")); + $rows[] = array(check_plain($field->title), $field->name, _profile_field_types($field->type), $field->category, l(t('edit'), "admin/user/profile/edit/$field->fid"), l(t('Delete'), "admin/user/profile/delete/$field->fid")); } if (count($rows) == 0) { $rows[] = array(array('data' => t('No fields defined.'), 'colspan' => '6')); @@ -33,6 +61,37 @@ return $output; } + +function theme_profile_admin_overview($form) { + $header = array(t('Title'), t('Name'), t('Type'), t('Category'), t('Weight'), t('Edit'), t('Delete')); + $rows = array(); + foreach (element_children($form['names']) as $id) { + // Don't take form control structures. + if (is_array($form['names'][$id])) { + $form['weights'][$id]['#attributes']['class'] = 'profile-admin-overview-weight'; + $rows[] = array( + 'data' => array( + drupal_render($form['titles'][$id]), + drupal_render($form['names'][$id]), + drupal_render($form['types'][$id]), + drupal_render($form['categories'][$id]), + drupal_render($form['weights'][$id]), + drupal_render($form['edit'][$id]), + drupal_render($form['delete'][$id]), + ), + 'class' => 'draggable', + ); + } + } + + $output = theme('table', $header, $rows, array('id' => 'profile-admin-overview')); + $output .= drupal_render($form); + + drupal_add_tabledrag('profile-admin-overview', 'order', 'sibling', 'profile-admin-overview-weight', NULL, NULL, FALSE); + + return $output; +} + /** * Menu callback: Generate a form to add/edit a user profile field. * Index: profile.module =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v retrieving revision 1.225 diff -u -r1.225 profile.module --- profile.module 20 Nov 2007 11:39:48 -0000 1.225 +++ profile.module 20 Nov 2007 23:59:57 -0000 @@ -67,6 +67,10 @@ 'profile_wrapper' => array( 'arguments' => array('content' => NULL), 'template' => 'profile-wrapper', + ), + 'profile_admin_overview' => array( + 'arguments' => array('form' => NULL), + 'file' => 'profile.admin.inc', ) ); } @@ -85,7 +89,8 @@ $items['admin/user/profile'] = array( 'title' => 'Profiles', 'description' => 'Create customizable fields for your users.', - 'page callback' => 'profile_admin_overview', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('profile_admin_overview'), 'file' => 'profile.admin.inc', ); $items['admin/user/profile/add'] = array(