Commit 4c94e681 authored by webchick's avatar webchick
Browse files

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

parent 822647a1
......@@ -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.');
}
}
}
/**
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment