function signature_forum_comment_view in Signatures for Forums 7
Implementation of hook_comment_view().
File
- ./
signature_forum.module, line 627 - Tweaks signatures in ways inspired by other traditional forum software:
Code
function signature_forum_comment_view($comment, $view_mode, $langcode) {
if (variable_get('user_signatures') && !empty($comment->uid) && !empty($comment->signature) && !empty($comment->signature_format)) {
// Add signature_forum to the render array.
if (!isset($comment->signature_forum_status) || $comment->signature_forum_status) {
$comment->content['signature_forum'] = array(
'#signature' => check_markup($comment->signature, $comment->signature_format, '', TRUE),
'#theme' => 'user_signature',
'#pre_render' => array(
'signature_forum_pre_render_user_signature',
),
'#user' => user_load($comment->uid),
);
$body = field_get_items('comment', $comment, 'comment_body', $langcode);
if ($body) {
// Some body fields appear not to have a 'safe_value'.
if (!empty($body[0]['safe_value'])) {
$content = $body[0]['safe_value'];
}
else {
$content = $body[0]['value'];
}
$comment->content['signature_forum']['#content_length'] = drupal_strlen(strip_tags($content));
}
else {
$comment->content['signature_forum']['#content_length'] = 0;
}
$comment->content['signature_forum']['#comment'] = $comment;
}
// Unset the core signature.
unset($comment->signature);
unset($comment->signature_format);
}
return $comment;
}