function _onepageprofile_get_categories in One page profile 6
Same name and namespace in other branches
- 7 onepageprofile.module \_onepageprofile_get_categories()
Load the user edit form and grab all of the fieldsets
2 calls to _onepageprofile_get_categories()
- onepageprofile_profile_alter in ./
onepageprofile.module - Implements hook_profile_alter().
- onepageprofile_settings in ./
onepageprofile.module - Admin page to change category weights
File
- ./
onepageprofile.module, line 315
Code
function _onepageprofile_get_categories() {
module_load_include('inc', 'user', 'user.pages');
$form_state = array();
$account = $GLOBALS['user'];
$form = user_profile_form($form_state, $account);
$categories = array();
foreach (element_children($form) as $field) {
// Special check for theme_select
if ($field == 'theme_select' && isset($form[$field])) {
$categories[$field] = array(
'#weight' => $form[$field]['#weight'],
'#title' => $form[$field]['themes']['#title'],
);
continue;
}
// Operate only on fieldsets
if (!isset($form[$field]['#type']) || $form[$field]['#type'] !== 'fieldset') {
continue;
}
// Build a list of categories
$categories[$field] = array(
'#weight' => $form[$field]['#weight'],
'#title' => $form[$field]['#title'],
);
// Apply the saved weights
foreach (variable_get('onepageprofile_weights', array()) as $field => $weight) {
if (isset($categories[$field])) {
$categories[$field]['#weight'] = $weight;
}
}
}
uasort($categories, 'element_sort');
return $categories;
}