You are here

function theme_uc_roles_user_expiration in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_roles/uc_roles.theme.inc \theme_uc_roles_user_expiration()

Themes the role expiration table within the roles dialog on the account edit page.

1 theme call to theme_uc_roles_user_expiration()
uc_roles_user_form in uc_roles/uc_roles.module
Implements hook_user_form().

File

uc_roles/uc_roles.module, line 297

Code

function theme_uc_roles_user_expiration($form) {
  $output = '';
  $header = array(
    array(
      'data' => t('Make permanent'),
    ),
    array(
      'data' => t('Role'),
    ),
    array(
      'data' => t('Expiration'),
    ),
    array(
      'data' => t('Add/remove time'),
    ),
  );
  $rows = array();

  // The expiration table.
  foreach ((array) $form['table'] as $rid => $expiration) {

    // We only want numeric rid's
    if (!is_numeric($rid)) {
      continue;
    }

    // Make sure the renders actually touch the elements.
    $data =& $form['table'][$rid];
    $rows[] = array(
      array(
        'data' => drupal_render($data['remove']),
      ),
      array(
        'data' => check_plain($data['name']['#value']),
      ),
      array(
        'data' => format_date($data['expiration']['#value'], 'small'),
      ),
      // Options to adjust the expiration.
      array(
        'data' => '<a name="role-expiration-' . $rid . '">' . '<div class="expiration">' . drupal_render($data['polarity']) . drupal_render($data['qty']) . drupal_render($data['granularity']) . '</div></a>',
      ),
    );
  }
  if (!count($rows)) {
    $rows[] = array(
      array(
        'data' => t('There are no pending expirations for roles this user.'),
        'colspan' => 4,
      ),
    );
  }
  $output .= theme('table', $header, $rows, array(), t('Below you can add or remove time to the expiration dates of the following roles.'));
  $output .= drupal_render($form);
  return $output;
}