You are here

function pcp_admin_settings_submit in Profile Complete Percent 7

Submit callback.

3 string references to 'pcp_admin_settings_submit'
pcp_form_field_ui_field_edit_form_alter in ./pcp.module
Implements hook_form_FORM_ID_alter().
pcp_form_profile2_type_form_alter in ./pcp.module
Implements hook_form_FORM_ID_alter(). Form builder; Configure PCP fields for profile2 profile types.
pcp_form_user_admin_settings_alter in ./pcp.module
Implements hook_form_FORM_ID_alter().

File

includes/pcp.admin.inc, line 145
Admin interface for the pcp module

Code

function pcp_admin_settings_submit($form, &$form_state) {
  switch ($form['#form_id']) {

    // admin/config/people/accounts
    case 'user_admin_settings':
      variable_set('pcp_enable_user_picture', $form_state['values']['pcp_enable_user_picture']);
      break;

    // admin/config/people/accounts/fields/[field_name]
    case 'field_ui_field_edit_form':
      if ($form['#instance']['entity_type'] == 'profile2') {
        _pcp_disable_field($form['#instance']['entity_type'], $form['#instance']['bundle'], $form['#instance']['field_name']);
        if ($form_state['values']['instance']['pcp_tag']) {
          _pcp_enable_field($form['#instance']['entity_type'], $form['#instance']['bundle'], $form['#instance']['field_name']);
        }
      }
      break;

    // admin/structure/profiles/manage/[profile_type]
    case 'profile2_type_form':

      // Provides the profile2 pcp data
      $profile_type = $form_state['values']['type'];
      variable_set('pcp_profile2_' . $profile_type . '_hide_block_on_complete', $form_state['values']['hide_block_on_complete']);

      // Process the profile fields that have been modified
      if ($form_state['values']['profile_fields']) {
        _pcp_save_profile_fields($form_state['values']['profile_fields']);
      }
      break;

    // admin/config/people/pcp
    default:

      // Provides the General Settings data
      variable_set('pcp_hide_block_on_complete', $form_state['values']['hide_block_on_complete']);
      if (variable_get('user_pictures', 0)) {
        variable_set('pcp_enable_user_picture', $form_state['values']['pcp_enable_user_picture']);
      }

      // Process the profile fields that have been modified
      if (isset($form_state['values']['profile_fields'])) {
        _pcp_save_profile_fields($form_state['values']['profile_fields']);
      }
  }
  if (isset($form_state['values']['pcp_fields_order'])) {
    $profile_fields_order_value = $form_state['values']['pcp_fields_order'];
    variable_set('pcp_fields_order', $profile_fields_order_value);
  }
  if (isset($form_state['values']['pcp_fields_open_option'])) {
    variable_set('pcp_fields_open_option', $form_state['values']['pcp_fields_open_option']);
  }
  if (isset($form_state['values']['pcp_login_message_role'])) {
    variable_set('pcp_login_message_role', $form_state['values']['pcp_login_message_role']);
  }
  if (!empty($form_state['values']['pcp_login_message'])) {
    variable_set('pcp_login_message', $form_state['values']['pcp_login_message']);
  }
}