#671452 by Rob Loach: Make Blog module add its action link correctly.

merge-requests/26/head
Angie Byron 2010-05-24 04:51:18 +00:00
parent 822647a176
commit 4c94e68159
2 changed files with 16 additions and 14 deletions

View File

@ -137,6 +137,8 @@ function blog_menu() {
* Implements hook_menu_local_tasks_alter().
*/
function blog_menu_local_tasks_alter(&$data, $router_item, $root_path) {
global $user;
// Add action link to 'node/add/blog' on 'blog' page.
if ($root_path == 'blog') {
$item = menu_get_item('node/add/blog');
@ -148,6 +150,19 @@ function blog_menu_local_tasks_alter(&$data, $router_item, $root_path) {
);
}
}
// Provide a helper action link to the author on the 'blog/%' page.
else if ($root_path == 'blog/%' && $router_item['page_arguments'][0]->uid == $user->uid) {
$data['actions']['output']['blog'] = array(
'#theme' => 'menu_local_action',
);
if (user_access('create blog content')) {
$data['actions']['output']['blog']['#link']['title'] = t('Post new blog entry.');
$data['actions']['output']['blog']['#link']['href'] = 'node/add/blog';
}
else {
$data['actions']['output']['blog']['#link']['title'] = t('You are not allowed to post a new blog entry.');
}
}
}
/**

View File

@ -14,20 +14,7 @@ function blog_page_user($account) {
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,
);
$build = array();
$query = db_select('node', 'n')->extend('PagerDefault');
$nids = $query