function pcp_admin_settings in Profile Complete Percent 7
Same name and namespace in other branches
- 5 pcp.module \pcp_admin_settings()
- 6.2 pcp.module \pcp_admin_settings()
- 6 pcp.module \pcp_admin_settings()
Form builder; Configure PCP fields for core profile.
1 string reference to 'pcp_admin_settings'
- pcp_menu in ./
pcp.module - Implements hook_menu().
File
- includes/
pcp.admin.inc, line 13 - Admin interface for the pcp module
Code
function pcp_admin_settings($form, &$form_state) {
$form['general_settings'] = array(
'#type' => 'fieldset',
'#title' => t('General Settings'),
);
$form['general_settings']['hide_block_on_complete'] = array(
'#type' => 'checkbox',
'#title' => t('Hide Block When Complete'),
'#default_value' => variable_get('pcp_hide_block_on_complete', 0),
'#description' => t('When a user reaches 100% complete of their profile, do you want the profile complete percent block to go away? If so, check this box on.'),
);
if (variable_get('user_pictures', 0)) {
$form['general_settings']['pcp_enable_user_picture'] = array(
'#type' => 'checkbox',
'#title' => t('Enable User Picture Support'),
'#default_value' => variable_get('pcp_enable_user_picture', 0),
'#description' => t('Picture support has been turned on, do you want to make it required as part of Profile Complete Percent? Checking this box will make it required.'),
);
}
$form['profile_field_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Core Profile Field Settings'),
'#description' => t('Checking a profile field below will add that field to the logic of the complete percentage. Please note that these are simply core profile fields, not fields attached to Profile2 profiles.'),
);
$field_order_options = array(
'0' => t('Random'),
'1' => t('Weight'),
);
$form['profile_field_settings']['pcp_fields_order'] = array(
'#type' => 'radios',
'#title' => t('Profile Fields Order'),
'#description' => t('Select to show which field come first.'),
'#options' => $field_order_options,
'#default_value' => variable_get('pcp_fields_order', 0),
);
$field_open_options = array(
'_self' => t('Same Window'),
'_blank' => t('New Window'),
);
$form['profile_field_settings']['pcp_fields_open_option'] = array(
'#type' => 'radios',
'#title' => t('Profile Fields Open Link'),
'#description' => t('Select to open field link in browser.'),
'#options' => $field_open_options,
'#default_value' => variable_get('pcp_fields_open_option', '_self'),
);
$user_roles = user_roles();
// Remove anonymous user role from the list,
// we only need the roles that can login to the site.
unset($user_roles[DRUPAL_ANONYMOUS_RID]);
$form['profile_field_settings']['pcp_login_message_role'] = array(
'#type' => 'checkboxes',
'#title' => t('Show profile message on login'),
'#description' => t('Select the roles for which the message is shown.'),
'#options' => $user_roles,
'#default_value' => variable_get('pcp_login_message_role', array()),
);
// Deafult message shown after login.
$pcp_default_text = t("Your Profile is not complete. Filling out remaining fields will make it 100%. Now you've reached [pcp-user:pcp-user]%.");
$form['profile_field_settings']['pcp_login_message'] = array(
'#type' => 'textarea',
'#description' => t('Write a message which will show after login'),
'#default_value' => variable_get('pcp_login_message', $pcp_default_text),
);
$form['profile_field_settings']['token_help'] = array(
'#theme' => 'token_tree',
'#global_type' => FALSE,
'#dialog' => TRUE,
);
$options = array();
$settings = pcp_admin_settings_form_data('user');
foreach ($settings['profile_fields_options'] as $fiid => $field_name) {
$field_info = field_info_instance('user', $field_name, 'user');
$options[$fiid] = $field_info['label'];
}
$profile_fields_description = empty($options) ? t('There are no profile fields enabled. Please !link first', array(
'!link' => l(t('add some profile fields'), 'admin/config/people/accounts/fields'),
)) : t('Checking a profile field below will add that field to the logic of the complete percentage.');
$form['profile_field_settings']['profile_fields'] = array(
'#title' => t('Profile Fields'),
'#description' => filter_xss($profile_fields_description),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => array_flip($settings['default_values']),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}