function advanced_forum_get_reply_link in Advanced Forum 7.2
Same name and namespace in other branches
- 6.2 advanced_forum.module \advanced_forum_get_reply_link()
Calculating links - New, Last, Etc.
1 call to advanced_forum_get_reply_link()
- theme_advanced_forum_reply_link in includes/
theme.inc - Theme function to format the reply link at the top/bottom of topic.
File
- ./
advanced_forum.module, line 857 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_get_reply_link($node) {
$reply_link = array();
$comment_setting = $node->comment;
if ($comment_setting == COMMENT_NODE_OPEN) {
$allowed = FALSE;
if (module_exists('forum_access')) {
// Get tid.
if (!empty($node->taxonomy_forums)) {
reset($node->taxonomy_forums);
$langcode = key($node->taxonomy_forums);
if (!empty($node->taxonomy_forums[$langcode])) {
$tid = $node->taxonomy_forums[$langcode][0]['tid'];
if (forum_access_access('create', $tid)) {
$allowed = TRUE;
}
}
}
}
else {
$allowed = user_access('post comments');
}
if ($allowed) {
$fragment = $node->content['comments']['comment_form']['#id'];
if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
// Reply form is on separate page. Grab the href from the node links
// so it's automatically corrected for Node Comments if needed.
$reply_link['href'] = "comment/reply/{$node->nid}";
$reply_link['options']['fragment'] = $fragment;
$reply_link['class'] = 'reply-allowed';
$reply_link['title'] = t('Post reply');
return $reply_link;
}
else {
// Reply form is on same page. The reply button should jump down to it
// rather than going to a new page.
$reply_link['href'] = $_GET['q'];
$reply_link['options']['fragment'] = $fragment;
$current_page = isset($_GET['page']) ? $_GET['page'] : 0;
if ($current_page) {
$reply_link['options']['query'] = array(
'page' => $current_page,
);
}
$reply_link['class'] = 'reply-allowed';
$reply_link['title'] = t('Quick reply');
return $reply_link;
}
}
else {
// User does not have access to post replies on this node.
return 'reply-forbidden';
}
}
else {
// Topic is locked.
return 'reply-locked';
}
}