function advanced_forum_node_type_create_list in Advanced Forum 7.2
Same name and namespace in other branches
- 6.2 advanced_forum.module \advanced_forum_node_type_create_list()
Generate a list of node creation links for a forum.
This is used on the forum list, allowing us to have direct links to create new nodes in the forum.
1 call to advanced_forum_node_type_create_list()
- theme_advanced_forum_node_type_create_list in includes/
theme.inc - Theme function to show list of types that can be posted in forum.
File
- ./
advanced_forum.module, line 1172 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_node_type_create_list($tid) {
$allowed_types = advanced_forum_allowed_node_types($tid);
// Ensure "new topic" is first.
if (isset($allowed_types['forum'])) {
unset($allowed_types['forum']);
array_unshift($allowed_types, 'forum');
}
// Loop through all node types allowed in this forum.
foreach ($allowed_types as $type) {
// Check if this node type can be created by current user.
if (node_access('create', $type)) {
// Fetch the "General" name of the content type.
$node_type = t(node_type_get_name($type));
// Remove the word "Forum" out of "Forum topic" to shorten it.
// @TODO: this is a little dodgy and may not work right with
// translations. Should be replaced if there's a better way.
$node_type = str_replace('Forum', '', $node_type);
// Push the link with title and url to the array.
$forum_types[$type] = array(
'name' => $node_type,
'href' => 'node/add/' . str_replace('_', '-', $type) . '/' . $tid,
);
}
}
if (empty($forum_types)) {
// The user is logged-in; but denied access to create any new forum content type.
global $user;
if ($user->uid) {
return t('You are not allowed to post new content in the forum.');
}
else {
return t('<a href="@login">Log in</a> to post new content in the forum.', array(
'@login' => url('user/login', array(
'query' => drupal_get_destination(),
)),
));
}
}
else {
return $forum_types;
}
}