I have come up with a small module that helps me to customize the local menu tabs a bit. My objective is to redirect an anonymous user to the login page when the link is clicked. The registered users should be able to see the review add form.
Here are the steps.
1) The menu_alter was modified with following:
function remove_tab_menu_alter(&$items) {
$items['node/%node_add_review/addreview']['page callback'] = 'remove_tab_addreview_load';
}
2) The callback function was added in the same module:
function remove_tab_addreview_load() {
global $user;
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
}
if ($user->uid) {
return drupal_get_form('nodereview_node_form');
}
else{
return drupal_goto('user','destination=node/'.urlencode($node->nid) .'/addreview');
}
drupal_not_found();
}
3) Template.php with some add review form customization:
function analytic_nodereview_node_form($form) {
$form['teaser']['#title']='Описание';
$form['title']['#access'] = false;
$form['title']['#required'] = FALSE;
unset($form['teaser']['#description']);
unset($form['filter']);
unset($form['buttons']['preview']);
$form['buttons']['submit']['#prefix'] = '
';