You are here

function userpoints_admin_manage in User Points 5

Same name and namespace in other branches
  1. 5.3 userpoints.module \userpoints_admin_manage()
  2. 5.2 userpoints.module \userpoints_admin_manage()
  3. 6 userpoints.module \userpoints_admin_manage()
1 string reference to 'userpoints_admin_manage'
userpoints_menu in ./userpoints.module
Implementation of hook_menu().

File

./userpoints.module, line 383

Code

function userpoints_admin_manage() {
  $header = array(
    array(
      'data' => t('User'),
      'field' => 'uid',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Time stamp'),
      'field' => 'time_stamp',
    ),
    array(
      'data' => t('!Points', userpoints_translation()),
      'field' => 'points',
    ),
    array(
      'data' => t('Event'),
      'field' => 'event',
    ),
    array(
      'data' => t('Operation', userpoints_translation()),
    ),
  );
  $sql = "SELECT t.txn_id, t.uid, t.time_stamp, t.points, t.event, t.status FROM {userpoints_txn} t WHERE t.status = %d";
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, USERPOINTS_PAGE_COUNT, 0, NULL, USERPOINTS_TXN_STATUS_PENDING);
  while ($data = db_fetch_object($result)) {
    $user = user_load(array(
      'uid' => $data->uid,
    ));
    $rows[] = array(
      array(
        'data' => theme('username', $user),
      ),
      array(
        'data' => format_date($data->time_stamp, 'custom', 'Y-m-d H:i'),
      ),
      array(
        'data' => $data->points,
        'align' => 'right',
      ),
      array(
        'data' => $data->event,
      ),
      array(
        'data' => l('approve', "admin/user/userpoints/approve/{$data->txn_id}") . ' ' . l('decline', "admin/user/userpoints/decline/{$data->txn_id}") . ' ' . l('edit', "admin/user/userpoints/edit/{$data->txn_id}"),
      ),
    );
  }
  $output = theme('table', $header, $rows);
  $output .= theme('pager', NULL, 30, 0);
  return $output;
}