Index: modules/profile/profile.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v retrieving revision 1.2 diff -u -r1.2 profile.admin.inc --- modules/profile/profile.admin.inc 26 Nov 2007 08:30:19 -0000 1.2 +++ modules/profile/profile.admin.inc 26 Nov 2007 21:16:23 -0000 @@ -9,27 +9,90 @@ /** * Menu callback; display a listing of all editable profile fields. */ -function profile_admin_overview() { - - $result = db_query('SELECT title, name, type, category, fid FROM {profile_fields} ORDER BY category, weight'); - $rows = array(); +function profile_admin_overview(&$form_state) { + $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_fields} ORDER BY category, weight'); + + $form = 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")); + // 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]['operations'] = array('#value' => l(t('edit'), "admin/user/profile/edit/$field->fid") .' '. l(t('delete'), "admin/user/profile/delete/$field->fid")); + } + + // Format the categories correctly for the category selection + $categories = array_unique($categories); + foreach($form as $fid => $field) { + foreach($categories as $cat => $category) { + $form[$fid]['category']['#options'][$category] = $category; + } } - if (count($rows) == 0) { - $rows[] = array(array('data' => t('No fields defined.'), 'colspan' => '6')); + + $form['#tree'] = TRUE; + $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); + + $addnewfields = '

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

'; + $addnewfields .= ''; + $form['addnewfields'] = array('#value' => $addnewfields); - $header = array(t('Title'), t('Name'), t('Type'), t('Category'), array('data' => t('Operations'), 'colspan' => '2')); + return $form; +} - $output = theme('table', $header, $rows); - $output .= '

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

'; - $output .= ''; + $header = array(t('Title'), t('Name'), t('Type'), t('Category'), t('Weight'), t('Operations')); + $output = theme('table', $header, $rows, array('id' => 'profile-admin-overview')); + $output .= drupal_render($form); + return $output; } Index: modules/profile/profile.module =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v retrieving revision 1.225 diff -u -r1.225 profile.module --- modules/profile/profile.module 20 Nov 2007 11:39:48 -0000 1.225 +++ modules/profile/profile.module 26 Nov 2007 18:42:23 -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(