diff --git a/autoassignrole.module b/autoassignrole.module index 97a9b2f..8364d34 100644 --- a/autoassignrole.module +++ b/autoassignrole.module @@ -442,10 +442,14 @@ function autoassignrole_form_alter(&$form, $form_state, $form_id) { while ($r = db_fetch_object($result)) { $options[$r->rid] = filter_xss_admin("($r->name) $r->path"); } + + $content_profile_settings = variable_get('content_profile_'.$type, array()); + $aar_roles = is_array($content_profile_settings['autoassignrole_use']) ? $content_profile_settings['autoassignrole_use'] : array(); + $form['registration']['autoassignrole_use'] = array( '#type' => 'checkboxes', '#title' => t('Use on Auto Assign Role paths'), - '#default_value' => content_profile_get_settings($type, 'autoassignrole_use'), + '#default_value' => $aar_roles, '#options' => $options, '#description' => t('The Auto Assign Role module gives you the ability to assign paths a user can register from for a role. After associating a path with a role your selection can associate this content type with a path.', array('@aar' => url('admin/user/autoassignrole'))), '#disabled' => count($options) == 0, @@ -454,11 +458,15 @@ function autoassignrole_form_alter(&$form, $form_state, $form_id) { array_unshift($form['#submit'], 'autoassignrole_content_profile_admin_form_submit'); } elseif ($form_id == 'user_register' && module_exists('content_profile_registration')) { + if (implode('/', arg()) != 'user/register' && $rid = autoassignrole_get_active_path_rid()) { // Set the content types which should be shown by the content_profile_registration module $form['#content_profile_registration_use_types'] = array(); foreach (content_profile_get_types('names') as $type => $name) { - if (in_array($rid, content_profile_get_settings($type, 'autoassignrole_use'))) { + $content_profile_settings = variable_get('content_profile_'.$type, array()); + $aar_roles = is_array($content_profile_settings['autoassignrole_use']) ? $content_profile_settings['autoassignrole_use'] : array(); + + if (in_array($rid, $aar_roles)) { $form['#content_profile_registration_use_types'][$type] = $name; } } @@ -467,7 +475,9 @@ function autoassignrole_form_alter(&$form, $form_state, $form_id) { } function autoassignrole_content_profile_admin_form_submit($form, &$form_state) { - $form_state['values']['autoassignrole_use'] = array_keys(array_filter($form_state['values']['autoassignrole_use'])); + $content_profile_settings = variable_get('content_profile_'.$form_state['type'], array()); + $content_profile_settings['autoassignrole_use'] = array_keys(array_filter($form_state['values']['autoassignrole_use'])); + variable_set('content_profile_'.$form_state['type'], $content_profile_settings ); } /**