You are here

function uc_roles_expiration in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_roles/uc_roles.module \uc_roles_expiration()
  2. 6.2 uc_roles/uc_roles.admin.inc \uc_roles_expiration()

Menu callback for viewing expirations.

3 string references to 'uc_roles_expiration'
uc_roles_menu in uc_roles/uc_roles.module
Implements hook_menu().
uc_roles_rules_action_info in uc_roles/uc_roles.rules.inc
Implements hook_rules_action_info().
uc_roles_rules_event_info in uc_roles/uc_roles.rules.inc
Implements hook_rules_event_info().

File

uc_roles/uc_roles.admin.inc, line 23
Roles administration menu items.

Code

function uc_roles_expiration($form, &$form_state) {

  // Create the header for the pager.
  $header = _uc_roles_expiration_header();

  // Grab all the info to build the pager.
  $query = db_select('uc_roles_expirations', 'e')
    ->extend('PagerDefault')
    ->extend('TableSort')
    ->fields('e')
    ->limit(50)
    ->orderByHeader($header);
  $query
    ->join('users', 'u', 'e.uid = u.uid');
  $query
    ->fields('u');
  $result = $query
    ->execute();

  // Stick the expirations into the form.
  foreach ($result as $row) {
    $account = user_load($row->uid);
    $name = check_plain(format_username($account));
    $form['name'][$row->uid . ' ' . $row->rid] = array(
      '#theme' => 'username',
      '#account' => $account,
      '#name' => $name,
    );
    $form['role'][$row->uid . ' ' . $row->rid] = array(
      '#markup' => check_plain(_uc_roles_get_name($row->rid)),
    );
    $form['expiration'][$row->uid . ' ' . $row->rid] = array(
      '#markup' => format_date($row->expiration, 'short'),
    );
    $form['edit'][$row->uid . ' ' . $row->rid] = array(
      '#markup' => l(t('edit'), 'user/' . $row->uid . '/edit', array(
        'fragment' => 'role-expiration-' . $row->rid,
        'query' => array(
          'destination' => 'admin/people/expiration',
        ),
      )),
    );
    $form['delete'][$row->uid . ' ' . $row->rid] = array(
      '#markup' => l(t('delete'), 'admin/people/expiration/delete/' . $row->uid . '/' . $row->rid),
    );
  }
  return $form;
}