function advanced_forum_preprocess_forum_submitted in Advanced Forum 5
Same name and namespace in other branches
- 6.2 includes/theme.inc \advanced_forum_preprocess_forum_submitted()
- 6 advanced_forum.module \advanced_forum_preprocess_forum_submitted()
- 7.2 includes/theme.inc \advanced_forum_preprocess_forum_submitted()
Preprocesses template variables for the submitted by/in template.
File
- ./
advanced_forum.module, line 805 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_preprocess_forum_submitted(&$variables) {
if ($variables['topic']->node_title) {
$nid = $variables['topic']->nid;
// Make a fake node object to avoid the node load
$node = new stdClass();
$node->nid = $nid;
$node->type = $variables['topic']->type;
// Find the page of the first unread comment, if any
$num_comments = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = %d', $nid));
$new_replies = comment_num_new($nid);
$query = comment_new_page_count($num_comments, $new_replies, $node);
// Format the node title with a link
$title_length = variable_get('advanced_forum_topic_title_length', 15);
if ($title_length == 0) {
$short_topic_title = $variables['topic']->node_title;
}
else {
$short_topic_title = truncate_utf8($variables['topic']->node_title, $title_length, TRUE, TRUE);
}
$fragment = $new_replies ? 'new' : NULL;
$variables['topic_link'] = l($short_topic_title, "node/{$nid}", NULL, $query, $fragment);
}
// For items posted more than $cutoff hours ago, offer an actual date.
$cutoff = variable_get('advanced_forum_time_ago_cutoff', 48) * 60 * 60;
if (isset($variables['topic']->timestamp)) {
$timestamp = $variables['topic']->timestamp;
if (time() - $timestamp > $cutoff) {
$variables['date_posted'] = format_date($timestamp, 'small');
}
}
}