// Loop through all node types for forum vocabulary.
foreach($vocabulary->nodesas$type){
// Check if the current user has the 'create' permission for this node type.
if(node_access('create',$type)){
// Fetch the "General" name of the content type;
// Push the link with title and url to the array.
$forum_types[$type]=array('title'=>t('Post new @node_type',array('@node_type'=>node_get_types('name',$type))),'href'=>"node/add/$type/$tid");
$forum_types[$type]=array('title'=>t('Post new @node_type',array('@node_type'=>node_get_types('name',$type))),'href'=>"node/add/$type/$variables[tid]");
}
}
if(!empty($forum_types)){
// Theme links for the prepared content types data.
$output.=theme('links',$forum_types);
}
else{
$output.='<li>'.t('<a href="@login">Login</a> to post a new forum topic.',array('@login'=>url('user/login',array('query'=>drupal_get_destination())))).'</li>';
if(empty($forum_types)){
// The user is logged-in; but denied access to create any new forum content type.
if($user->uid){
$output.=t('You are not allowed to post new content in forum.');
$forum_types['disallowed']=array('title'=>t('You are not allowed to post new content in forum.'));
}
// The user is not logged-in; and denied access to create any new forum content type.
else{
$output.=t('<a href="@login">Login</a> to post new content in forum.',array('@login'=>url('user/login',array('query'=>drupal_get_destination()))));
$forum_types['login']=array('title'=>t('<a href="@login">Login</a> to post new content in forum.',array('@login'=>url('user/login',array('query'=>drupal_get_destination())))),'html'=>TRUE);