You are here

function referral_view in User Referral 5

Same name and namespace in other branches
  1. 6 referral.module \referral_view()
  2. 7 referral.module \referral_view()
1 string reference to 'referral_view'
referral_menu in ./referral.module

File

./referral.module, line 333

Code

function referral_view() {
  global $user;

  //$node = node_prepare($node, $teaser);
  if (variable_get(REFERRAL_DISPLAY_MODE, 0)) {
    $output .= '<div class="referral_link">';
    $output .= t('Your referral link: ');
    $output .= url('referral/' . _referral_uid2ref($user->uid), NULL, NULL, TRUE);
    $output .= '</div>';
  }
  $header = array(
    array(
      'data' => t('User'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Roles'),
    ),
    array(
      'data' => t('Flag'),
      'field' => 'r.flag',
    ),
    array(
      'data' => t('Time'),
      'field' => 'r.created',
      'sort' => 'desc',
    ),
  );
  $sql = 'SELECT u.uid, u.name, r.created, r.flag
    FROM {referral} r INNER JOIN {users} u USING(uid)
    WHERE referral_uid = %d
    AND u.status = 1
    ORDER BY r.created DESC';
  $result = pager_query($sql, REFERRAL_PAGE_COUNT, 0, null, $user->uid);
  while ($data = db_fetch_object($result)) {
    $rows[] = array(
      array(
        'data' => l($data->name, "user/{$data->uid}"),
      ),
      array(
        'data' => implode(',', _referral_get_user_roles($data->uid)),
      ),
      array(
        'data' => $data->flag ? 'Yes' : 'No',
      ),
      array(
        'data' => format_date($data->created, 'custom', REFERRAL_DATE_FORMAT),
      ),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No data.'),
        'colspan' => '4',
      ),
    );
  }
  $pager = theme('pager', null, REFERRAL_PAGE_COUNT, 0);
  if (!empty($pager)) {
    $rows[] = array(
      array(
        'data' => $pager,
        'colspan' => '4',
      ),
    );
  }
  print theme('page', $output . theme('table', $header, $rows), t('Referrals Report'));

  /* $node->content['referral'] = array(
  	'#value' => $output . theme('table', $header, $rows),
  	'#title' => t('Referrals Report')
    );
    return $node; */
}