function commons_connect_shoutbox_post in Drupal Commons 6.2
Implementation of theme_shoutbox_post()
File
- themes/
commons_connect/ template.php, line 97
Code
function commons_connect_shoutbox_post($shout, $links = array(), $alter_row_color = TRUE) {
global $user;
// Gather moderation links
if ($links) {
foreach ($links as $link) {
$linkattributes = $link['linkattributes'];
$link_html = '<img src="' . $link['img'] . '" width="' . $link['img_width'] . '" height="' . $link['img_height'] . '" alt="' . $link['title'] . '" class="shoutbox-imglink"/>';
$link_url = 'shout/' . $shout->shout_id . '/' . $link['action'];
$img_links = l($link_html, $link_url, array(
'html' => TRUE,
'query' => array(
'destination' => drupal_get_path_alias($_GET['q']),
),
)) . $img_links;
}
}
// Generate user name with link
$user_name = shoutbox_get_user_link($shout);
// Generate title attribute
$title = t('Posted !date at !time by !name', array(
'!date' => format_date($shout->created, 'custom', 'm/d/y'),
'!time' => format_date($shout->created, 'custom', 'h:ia'),
'!name' => $shout->nick,
));
// Add to the shout classes
$shout_classes = array();
$shout_classes[] = 'shoutbox-msg';
// Check for moderation
if ($shout->moderate == 1) {
$shout_classes[] = 'shoutbox-unpublished';
$approval_message = ' (' . t('This shout is waiting for approval by a moderator.') . ')';
}
// Check for specific user class
$user_classes = array();
$user_classes[] = 'shoutbox-user-name';
if ($shout->uid == $user->uid) {
$user_classes[] = 'shoutbox-current-user-name';
}
else {
if ($shout->uid == 0) {
$user_classes[] = 'shoutbox-anonymous-user';
}
}
// Load user image and format
$author_picture = '';
$shout_author = user_load($shout->uid);
if (!$shout_author->picture && variable_get('user_picture_default', '')) {
$shout_author->picture = variable_get('user_picture_default', '');
}
if ($shout_author->picture) {
$author_picture = theme_imagecache('user_picture_meta', $shout_author->picture, $shout_author->name, $shout_author->name);
}
// Time format
$format = variable_get('shoutbox_time_format', 'ago');
switch ($format) {
case 'ago':
$submitted = t('!interval ago', array(
'!interval' => format_interval(time() - $shout->created),
));
break;
case 'small':
case 'medium':
case 'large':
$submitted = format_date($shout->created, $format);
break;
}
// Build the post
$post = '';
$post .= '<div class="' . implode(' ', $shout_classes) . '" title="' . $title . '">';
$post .= '<div class="shoutbox-admin-links">' . $img_links . '</div>';
$post .= '<div class="shoutbox-post-info">' . $author_picture;
$post .= '<span class="shoutbox-user-name ' . implode(' ', $user_classes) . '">' . $user_name . '</span>';
$post .= '<span class="shoutbox-msg-time">' . $submitted . '</span>';
$post .= '</div>';
$post .= '<div class="shout-message">' . $shout->shout . $approval_message . '</div>';
$post .= '</div>' . "\n";
return $post;
}