You are here

function uc_roles_expiration in Ubercart 5

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

Menu callback for viewing expirations

1 string reference to 'uc_roles_expiration'
uc_roles_menu in uc_roles/uc_roles.module
Implementation of hook_menu().

File

uc_roles/uc_roles.module, line 481
Grants roles upon accepted payment of products

Code

function uc_roles_expiration() {
  $header = array(
    array(
      'data' => t('Username'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Role'),
      'field' => 'e.rid',
    ),
    array(
      'data' => t('Expiration date'),
      'field' => 'e.expiration',
      'sort' => 'asc',
    ),
    t('Operations'),
  );
  $sql = 'SELECT * FROM {uc_roles_expirations} AS e INNER JOIN {users} AS u ON e.uid = u.uid';
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, 50, 0, NULL);
  while ($row = db_fetch_object($result)) {
    $form['name'][$row->uid . ' ' . $row->rid] = array(
      '#value' => theme('username', $row),
    );
    $form['role'][$row->uid . ' ' . $row->rid] = array(
      '#value' => _get_role_name($row->rid),
    );
    $form['expiration'][$row->uid . ' ' . $row->rid] = array(
      '#value' => format_date($row->expiration, 'small'),
    );
    $form['operations'][$row->uid . ' ' . $row->rid] = array(
      '#value' => l(t('delete'), 'admin/user/user/expiration/delete/' . $row->uid . '/' . $row->rid) . ' ' . l(t('edit'), 'user/' . $row->uid . '/edit', array(), 'destination=admin%2Fuser%2Fuser%2Fexpiration'),
    );
  }
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}