You are here

function uc_payment_methods_form in Ubercart 7.3

Same name and namespace in other branches
  1. 5 payment/uc_payment/uc_payment.module \uc_payment_methods_form()
  2. 6.2 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()

1 string reference to 'uc_payment_methods_form'
uc_payment_menu in payment/uc_payment/uc_payment.module
Implements hook_menu().

File

payment/uc_payment/uc_payment.admin.inc, line 13
Payment administration menu items.

Code

function uc_payment_methods_form($form, &$form_state) {
  $methods = _uc_payment_method_list();
  $form['pmtable'] = array(
    '#theme' => 'uc_payment_method_table',
  );
  foreach ($methods as $id => $method) {
    $form['pmtable'][$id]['uc_payment_method_' . $id . '_checkout'] = array(
      '#type' => 'checkbox',
      '#title' => check_plain($method['name']),
      '#default_value' => variable_get('uc_payment_method_' . $id . '_checkout', $method['checkout']),
    );
    $form['pmtable'][$id]['uc_payment_method_' . $id . '_weight'] = array(
      '#type' => 'weight',
      '#default_value' => variable_get('uc_payment_method_' . $id . '_weight', $method['weight']),
      '#attributes' => array(
        'class' => array(
          'uc-payment-method-weight',
        ),
      ),
    );
    if (empty($method['no_gateway'])) {
      $gateways = _uc_payment_gateway_list($id, TRUE);
      $options = array();
      foreach ($gateways as $gateway_id => $gateway) {
        $options[$gateway_id] = $gateway['title'];
      }
      if ($options) {
        $form['pmtable'][$id]['uc_payment_method_' . $id . '_checkout']['#title'] .= ' (' . t('includes %gateways', array(
          '%gateways' => implode(', ', $options),
        )) . ')';
      }
    }
    $links = array();
    $null = NULL;
    $method_settings = $method['callback']('settings', $null, array(), $form_state);
    if (is_array($method_settings)) {
      $links['settings'] = array(
        'title' => t('settings'),
        'href' => 'admin/store/settings/payment/method/' . $id,
      );
    }
    $links['conditions'] = array(
      'title' => t('conditions'),
      'href' => 'admin/store/settings/payment/manage/uc_payment_method_' . $id,
    );
    $form['pmtable'][$id]['settings'] = array(
      '#theme' => 'links',
      '#links' => $links,
      '#attributes' => array(
        'class' => array(
          'links',
          'inline',
        ),
      ),
    );
  }
  return system_settings_form($form);
}