function uc_roles_feature_settings in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_roles/uc_roles.module \uc_roles_feature_settings()
- 7.3 uc_roles/uc_roles.module \uc_roles_feature_settings()
Form builder for role settings.
1 string reference to 'uc_roles_feature_settings'
- uc_roles_product_feature in uc_roles/
uc_roles.module - Implements hook_product_feature().
File
- uc_roles/
uc_roles.module, line 921
Code
function uc_roles_feature_settings() {
$default_role_choices = user_roles(TRUE);
unset($default_role_choices[DRUPAL_AUTHENTICATED_RID]);
if (!count($default_role_choices)) {
$form['no_roles'] = array(
'#value' => t('You need to <a href="!url">create new roles</a> before any can be added as product features.', array(
'!url' => url('admin/user/roles', array(
'query' => 'destination=admin/store/settings/products/edit/features',
)),
)),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
return $form;
}
foreach (uc_order_status_list('general') as $status) {
$statuses[$status['id']] = $status['title'];
}
$form['uc_roles_default_role'] = array(
'#type' => 'select',
'#title' => t('Default role'),
'#default_value' => variable_get('uc_roles_default_role', NULL),
'#description' => t('The default role Ubercart grants on specified products.'),
'#options' => _uc_roles_get_choices(),
);
$form['uc_roles_default_role_choices'] = array(
'#type' => 'checkboxes',
'#title' => t('Product roles'),
'#default_value' => variable_get('uc_roles_default_role_choices', array()),
'#multiple' => TRUE,
'#description' => t('These are roles that Ubercart can grant to customers who purchase specified products. If you leave all roles unchecked, they will all be eligible for adding to a product.'),
'#options' => $default_role_choices,
);
$form['role_lifetime'] = array(
'#type' => 'fieldset',
'#title' => t('Expiration period'),
);
$form['role_lifetime']['uc_roles_default_end_expiration'] = array(
'#type' => 'select',
'#title' => t('End'),
'#options' => array(
'rel' => t('Relative from activation time'),
'abs' => t('Absolute role ending'),
),
'#default_value' => variable_get('uc_roles_default_end_expiration', 'rel'),
);
$form['role_lifetime']['uc_roles_default_length'] = array(
'#type' => 'textfield',
'#title' => t('Default expiration'),
'#default_value' => variable_get('uc_roles_default_granularity', 'never') == 'never' ? NULL : variable_get('uc_roles_default_length', NULL),
'#size' => 4,
'#maxlength' => 4,
'#prefix' => '<div class="expiration">',
);
$form['role_lifetime']['uc_roles_default_granularity'] = array(
'#type' => 'select',
'#default_value' => variable_get('uc_roles_default_granularity', 'never'),
'#options' => array(
'never' => t('never'),
'day' => t('day(s)'),
'week' => t('week(s)'),
'month' => t('month(s)'),
'year' => t('year(s)'),
),
'#description' => t('The default amount of time a granted Ubercart role will last until it expires.'),
'#suffix' => '</div>',
);
$form['role_lifetime']['uc_roles_default_end_time'] = array(
'#type' => 'date',
'#description' => t('When this expiration period will end.'),
'#default_value' => variable_get('uc_roles_default_end_time', array(
'day' => date('j'),
'month' => date('n'),
'year' => date('Y'),
)),
);
$form['role_lifetime']['uc_roles_default_by_quantity'] = array(
'#type' => 'checkbox',
'#title' => t('Multiply by quantity'),
'#description' => t('Check if the role duration should be multiplied by the quantity purchased.'),
'#default_value' => variable_get('uc_roles_default_by_quantity', FALSE),
);
$form['reminder']['uc_roles_reminder_length'] = array(
'#type' => 'textfield',
'#title' => t('Time before reminder'),
'#default_value' => variable_get('uc_roles_reminder_granularity', 'never') == 'never' ? NULL : variable_get('uc_roles_reminder_length', NULL),
'#size' => 4,
'#maxlength' => 4,
'#prefix' => '<div class="expiration">',
'#suffix' => '</div>',
);
$form['reminder']['uc_roles_reminder_granularity'] = array(
'#type' => 'select',
'#default_value' => variable_get('uc_roles_reminder_granularity', 'never'),
'#options' => array(
'never' => t('never'),
'day' => t('day(s)'),
'week' => t('week(s)'),
'month' => t('month(s)'),
'year' => t('year(s)'),
),
'#description' => t('The amount of time before a role expiration takes place that a customer is notified of its expiration.'),
'#prefix' => '<div class="expiration">',
'#suffix' => '</div>',
);
$form['uc_roles_expiration_display'] = array(
'#type' => 'fieldset',
'#title' => t('Expiration display'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['uc_roles_expiration_display']['uc_roles_default_show_expiration'] = array(
'#type' => 'checkbox',
'#title' => t('Show expirations on user page'),
'#default_value' => variable_get('uc_roles_default_show_expiration', TRUE),
'#description' => t('If users have any role expirations they will be displayed on their account page.'),
);
$form['uc_roles_expiration_display']['uc_roles_default_expiration_header'] = array(
'#type' => 'textfield',
'#title' => t('Header'),
'#default_value' => variable_get('uc_roles_default_expiration_header', uc_get_message('uc_roles_user_expiration_header')),
);
$form['uc_roles_expiration_display']['uc_roles_default_expiration_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => variable_get('uc_roles_default_expiration_title', uc_get_message('uc_roles_user_expiration_title')),
);
$form['uc_roles_expiration_display']['uc_roles_default_expiration_message'] = array(
'#type' => 'textfield',
'#title' => t('Message'),
'#default_value' => variable_get('uc_roles_default_expiration_message', uc_get_message('uc_roles_user_expiration_message')),
'#description' => t('The message, with its accompanying title, and the header displayed above all role expirations. In the <strong>Title</strong> & <strong>Message</strong> fields "!role_name" and "!date" will translate to the corresponding Drupal role name and role expiration date.'),
);
return $form;
}