blog_page_user
- Versions
- 4.6 – 5
blog_page_user($uid)- 6 – 7
blog_page_user($account)
Menu callback; displays a Drupal page containing recent blog entries of a given user.
Code
modules/blog/blog.pages.inc, line 11
<?php
function blog_page_user($account) {
global $user;
drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);
$items = array();
if (($account->uid == $user->uid) && user_access('create blog content')) {
$items[] = l(t('Post new blog entry.'), "node/add/blog");
}
elseif ($account->uid == $user->uid) {
$items[] = t('You are not allowed to post a new blog entry.');
}
$build['blog_actions'] = array(
'#items' => $items,
'#theme' => 'item_list',
'#weight' => -1,
);
$query = db_select('node', 'n')->extend('PagerDefault');
$nids = $query
->fields('n', array('nid', 'sticky', 'created'))
->condition('type', 'blog')
->condition('uid', $account->uid)
->condition('status', 1)
->orderBy('sticky', 'DESC')
->orderBy('created', 'DESC')
->limit(variable_get('default_nodes_main', 10))
->addTag('node_access')
->execute()
->fetchCol();
if (!empty($nids)) {
$nodes = node_load_multiple($nids);
$build += node_build_multiple($nodes);
$build['pager'] = array(
'#theme' => 'pager',
'#weight' => 5,
);
}
else {
if ($account->uid == $user->uid) {
drupal_set_message(t('You have not created any blog entries.'));
}
else {
drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', array('account' => $account)))));
}
}
drupal_add_feed(url('blog/' . $account->uid . '/feed'), t('RSS - !title', array('!title' => $title)));
return $build;
}
?>Login or register to post comments 