function uc_payment_methods_form in Ubercart 6.2
Same name and namespace in other branches
- 5 payment/uc_payment/uc_payment.module \uc_payment_methods_form()
- 7.3 payment/uc_payment/uc_payment.admin.inc \uc_payment_methods_form()
Displays an overview of the available payment methods.
See also
theme_uc_payment_methods_table()
2 string references to 'uc_payment_methods_form'
- uc_credit_form_alter in payment/
uc_credit/ uc_credit.module - Implements hook_form_alter().
- uc_payment_menu in payment/
uc_payment/ uc_payment.module - Implements hook_menu().
File
- payment/
uc_payment/ uc_payment.admin.inc, line 68 - Payment administration menu items.
Code
function uc_payment_methods_form() {
$methods = _payment_method_list();
$form['pmtable'] = array(
'#theme' => 'uc_payment_method_table',
'#summary callback' => 'summarize_form',
);
if (is_array($methods) && count($methods) > 0) {
foreach ($methods as $method) {
$form['pmtable'][$method['id']]['#summary callback'] = 'summarize_form';
$form['pmtable'][$method['id']]['uc_payment_method_' . $method['id'] . '_checkout'] = array(
'#type' => 'checkbox',
'#title' => $method['name'],
'#summary callback' => 'summarize_checkbox',
'#summary arguments' => array(
t('@payment is enabled for checkout.', array(
'@payment' => $method['name'],
)),
t('@payment is disabled for checkout.', array(
'@payment' => $method['name'],
)),
),
'#default_value' => variable_get('uc_payment_method_' . $method['id'] . '_checkout', $method['checkout']),
);
$form['pmtable'][$method['id']]['uc_payment_method_' . $method['id'] . '_weight'] = array(
'#type' => 'weight',
'#default_value' => variable_get('uc_payment_method_' . $method['id'] . '_weight', $method['weight']),
'#attributes' => array(
'class' => 'uc-payment-method-weight',
),
);
if (isset($method['no_gateway']) && $method['no_gateway'] === TRUE) {
$form['pmtable'][$method['id']]['uc_payment_' . $method['id'] . '_gateway'] = array(
'#value' => '-',
);
}
else {
$gateways = _payment_gateway_list($method['id'], TRUE);
$options = array();
$default = FALSE;
if (is_array($gateways)) {
foreach ($gateways as $gateway) {
if (!$default) {
$default = $gateway['id'];
}
$options[$gateway['id']] = $gateway['title'];
}
}
if (!$default) {
$options = array(
'none' => t('None available.'),
);
}
$form['pmtable'][$method['id']]['uc_payment_' . $method['id'] . '_gateway'] = array(
'#type' => 'select',
'#options' => $options,
'#summary callback' => 'summarize_null',
'#default_value' => variable_get('uc_payment_' . $method['id'] . '_gateway', 'none'),
);
}
$null = NULL;
if (function_exists($method['callback'])) {
$method_settings = $method['callback']('settings', $null);
if (is_array($method_settings)) {
$form['method_' . $method['id']] = array(
'#type' => 'fieldset',
'#summary callback' => 'summarize_null',
'#title' => t('!method settings', array(
'!method' => $method['name'],
'!weight' => $method['weight'],
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['method_' . $method['id']] = array_merge($form['method_' . $method['id']], $method_settings);
}
}
}
}
else {
$form['pmtable'] = array(
'#value' => '<div>' . t('No payment methods are available. Modules providing payment methods must first be enabled on the !modules administration page under the "Ubercart - payment" fieldset.', array(
'!modules' => l(t('Modules'), 'admin/build/modules'),
)) . '</div>',
);
}
return system_settings_form($form);
}