blog_page_user

modules/blog.module, line 121

Versions
4.6 – 5
blog_page_user($uid)
6 – 7
blog_page_user($account)

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

▾ 1 function calls blog_page_user()

blog_page in modules/blog.module
Menu callback; displays a Drupal page containing recent blog entries.

Code

<?php
function blog_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 blog", array('%name' => check_plain($account->name))));

    if (($account->uid == $user->uid) && user_access('edit own blog')) {
      $output = '<li>'. l(t('Post new blog entry.'), "node/add/blog") .'</li>';
    }
    else if ($account->uid == $user->uid) {
      $output = '<li>'. t('You are not allowed to post a new blog entry.') .'</li>';
    }

    if ($output) {
      $output = '<ul>'. $output .'</ul>';
    }
    else {
      $output = '';
    }

    $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
    while ($node = db_fetch_object($result)) {
      $output .= node_view(node_load(array('nid' => $node->nid)), 1);
    }
    $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
    $output .= theme('xml_icon', url("blog/$account->uid/feed"));

    drupal_add_link(array('rel' => 'alternate',
                          'type' => 'application/rss+xml',
                          'title' => t('RSS - %title', array('%title' => $title)),
                          'href' => url("blog/$account->uid/feed")));
    print theme('page', $output);
  }
  else {
    drupal_not_found();
  }
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.