function autoassignrole_form_alter in Auto Assign Role 6.2
Same name and namespace in other branches
- 5.2 autoassignrole.module \autoassignrole_form_alter()
- 5 autoassignrole.module \autoassignrole_form_alter()
- 6 autoassignrole.module \autoassignrole_form_alter()
Implementation of hook_form_alter().
Integrate with content profile's registration integration
File
- ./
autoassignrole.module, line 438 - The main autoassignrole.module file
Code
function autoassignrole_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'content_profile_admin_settings') {
$type = $form_state['type'];
$result = db_query("SELECT ar.path, ar.rid, r.name FROM {autoassignrole_page} ar INNER JOIN {role} r ON ar.rid = r.rid");
$options = array();
while ($r = db_fetch_object($result)) {
$options[$r->rid] = filter_xss_admin("({$r->name}) {$r->path}");
}
$form['registration']['autoassignrole_use'] = array(
'#type' => 'checkboxes',
'#title' => t('Use on Auto Assign Role paths'),
'#default_value' => content_profile_get_settings($type, 'autoassignrole_use'),
'#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 <a href="@aar">path with a role</a> your selection can associate this content type with a path.', array(
'@aar' => url('admin/user/autoassignrole'),
)),
'#disabled' => count($options) == 0,
'#weight' => 3,
);
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) {
$cp_settings = content_profile_get_settings($type, 'autoassignrole_use');
if (is_array($cp_settings) && in_array($rid, array(
$cp_settings,
))) {
$form['#content_profile_registration_use_types'][$type] = $name;
}
}
}
}
}