diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 5e09d50dbe3..b728e439a24 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -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.'); + } + } } /** diff --git a/modules/blog/blog.pages.inc b/modules/blog/blog.pages.inc index 35556008e23..587fbbf29ba 100644 --- a/modules/blog/blog.pages.inc +++ b/modules/blog/blog.pages.inc @@ -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