function uc_roles_user_form in Ubercart 6.2
Implements hook_user_form().
1 call to uc_roles_user_form()
- uc_roles_user in uc_roles/
uc_roles.module - Implements hook_user().
File
- uc_roles/
uc_roles.module, line 172
Code
function uc_roles_user_form(&$edit, &$account, $category = NULL) {
if (!user_access('administer users') || $category != 'account') {
return;
}
$role_choices = _uc_roles_get_choices(array_keys($account->roles));
$polarity_widget = array(
'#type' => 'select',
'#options' => array(
'add' => '+',
'remove' => '-',
),
);
$quantity_widget = array(
'#type' => 'textfield',
'#size' => 4,
'#maxlength' => 4,
);
$granularity_widget = array(
'#type' => 'select',
'#options' => array(
'day' => t('day(s)'),
'week' => t('week(s)'),
'month' => t('month(s)'),
'year' => t('year(s)'),
),
);
$form['uc_roles'] = array(
'#type' => 'fieldset',
'#title' => t('Ubercart roles'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 10,
'#theme' => 'uc_roles_user_new',
);
$form['uc_roles']['expirations'] = array(
'#type' => 'fieldset',
'#title' => t('Pending Expirations'),
'#collapsible' => FALSE,
'#weight' => 0,
'#theme' => 'uc_roles_user_expiration',
);
$form['uc_roles']['expirations']['table']['#tree'] = TRUE;
// Create the expirations table.
$expirations = db_query("SELECT * FROM {uc_roles_expirations} WHERE uid = %d", $account->uid);
while ($expiration = db_fetch_object($expirations)) {
$form['uc_roles']['expirations']['table'][$expiration->rid] = array(
'name' => array(
'#type' => 'value',
'#value' => _uc_roles_get_name($expiration->rid),
),
'remove' => array(
'#type' => 'checkbox',
),
'expiration' => array(
'#type' => 'value',
'#value' => $expiration->expiration,
),
'polarity' => $polarity_widget,
'qty' => $quantity_widget,
'granularity' => $granularity_widget,
);
}
// Option to allow temporary roles.
if (!empty($role_choices)) {
$form['uc_roles']['new_role'] = array(
'#type' => 'checkbox',
'#title' => t('Add role'),
);
$form['uc_roles']['new_role_add'] = array(
'#type' => 'select',
'#default_value' => variable_get('uc_roles_default_role', NULL),
'#options' => $role_choices,
);
$form['uc_roles']['new_role_add_for'] = array(
'#value' => t(' for '),
);
$form['uc_roles']['new_role_add_qty'] = $quantity_widget;
$form['uc_roles']['new_role_add_granularity'] = $granularity_widget;
if (($default_granularity = variable_get('uc_roles_default_granularity', 'never')) != 'never') {
$form['uc_roles']['new_role_add_qty'] = $form['uc_roles']['new_role_add_qty'] + array(
'#default_value' => variable_get('uc_roles_default_length', NULL),
);
$form['uc_roles']['new_role_add_granularity'] = $form['uc_roles']['new_role_add_granularity'] + array(
'#default_value' => $default_granularity,
);
}
}
return $form;
}