You are here

function vote_storylink_page_user in Vote Up/Down 5

Displays a Drupal page containing recent storylink entries of a given user.

1 call to vote_storylink_page_user()
vote_storylink_page in ./vote_storylink.module
Menu callback; displays a Drupal page containing recent story links entries.

File

./vote_storylink.module, line 444

Code

function vote_storylink_page_user($uid) {
  global $user;
  $account = user_load(array(
    is_numeric($uid) ? 'uid' : 'name' => $uid,
    'status' => 1,
  ));
  if ($account->uid) {
    drupal_set_title($title = t("@name's story links", array(
      '@name' => $account->name,
    )));
    $sql = db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE type = 'storylink' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC");
    $result = pager_query($sql, variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
    while ($node = db_fetch_object($result)) {
      $output .= node_view(node_load($node->nid), 1);
    }
    $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
    $output .= theme('feed_icon', url("storylink/{$account->uid}/feed"));
    $feed_url = url("storylink/{$account->uid}/feed", NULL, NULL, TRUE);
    drupal_add_feed($feed_url, t('RSS - @title', array(
      '@title' => $title,
    )));
    return $output;
  }
  else {
    drupal_not_found();
  }
}