function theme_privatemsg_view in Privatemsg 5.3
Same name and namespace in other branches
- 5 privatemsg.module \theme_privatemsg_view()
Returns content to view a private message.
Parameters
message:
2 theme calls to theme_privatemsg_view()
File
- ./
privatemsg.module, line 2138
Code
function theme_privatemsg_view($message, $preview = FALSE, $prev = 0, $next = 0) {
$option = variable_get('privatemsg_view_actions', '3');
global $user;
if ($option == '4') {
$links = array();
if ($message->recipient == $user->uid) {
$author = user_load(array(
'uid' => $message->uid,
));
if ($author->uid && $author->privatemsg_allow) {
$links['privatemsg_reply'] = array(
'title' => t('Reply to this message'),
'href' => 'privatemsg/reply/' . $message->id,
);
}
else {
$links['privatemsg_noreply'] = array(
'title' => t('Sender does not accept replies'),
'href' => NULL,
);
}
}
if ($message->recipient == $user->uid || variable_get('privatemsg_sent_status', 1)) {
$links['privatemsg_delete'] = array(
'title' => t('Delete this message'),
'href' => 'privatemsg/delete/' . $message->id,
'attributes' => array(
'onclick' => "return confirm('" . t('Are you sure you want to delete this message?') . "')",
),
);
}
$links['privatemsg_list'] = array(
'title' => t('List messages'),
'href' => $message->recipient == $user->uid && $message->folder ? 'privatemsg/list/' . $message->folder : 'privatemsg',
);
if ($message->id) {
$link_display = '<div class="links">' . theme('links', $links) . '</div>';
}
}
// From row.
if ($preview) {
$pm_from = $user->name;
}
else {
$pm_from = '<div class="pm-username">' . theme('privatemsg_username', $message) . '</div>';
$pm_from .= '<div class="pm-inbox-avatar">' . theme('privatemsg_user_picture', user_load(array(
'uid' => $message->uid,
))) . '</div>';
if ($message->author != $user->uid) {
if (!privatemsg_user_blocked($message->author)) {
$pm_from .= t('<span class="pm-block-link">(<a href="!block-link">Block user</a>)</span>', array(
'!block-link' => url('privatemsg/block/' . $message->author, drupal_get_destination()),
));
}
else {
$pm_from .= t('<span class="pm-block-link">(<a href="!block-link">Unblock user</a>)</span>', array(
'!block-link' => url('privatemsg/block/' . $message->author, drupal_get_destination()),
));
}
}
}
$rows[] = array(
array(
'data' => t('From:'),
'class' => 'title-cell',
'nowrap' => 'nowrap',
),
array(
'data' => $pm_from,
'class' => 'data-cell',
),
);
// To row.
if ($preview) {
$pm_to = $message->recipient;
}
else {
$pm_to = theme('privatemsg_username', user_load(array(
'uid' => $message->recipient,
)));
}
$rows[] = array(
array(
'data' => t('To:'),
'class' => 'title-cell',
'nowrap' => 'nowrap',
),
array(
'data' => $pm_to,
'class' => 'data-cell',
),
);
// Subject row.
$subject = check_plain($message->subject);
$rows[] = array(
array(
'data' => t('Subject:'),
'class' => 'title-cell',
'nowrap' => 'nowrap',
),
array(
'data' => $subject,
'class' => 'data-cell',
),
);
// Date row.
$date = format_date($message->timestamp);
$rows[] = array(
array(
'data' => t('Date:'),
'class' => 'title-cell',
'nowrap' => 'nowrap',
),
array(
'data' => $date,
'class' => 'data-cell',
),
);
// Message body.
$body = '<div class="pm-body">' . check_markup($message->message, $message->format, FALSE) . '</div>';
/* $rows[] = array(
array('data' => $body, 'class' => 'pm-body', 'colspan' => 5),
);*/
if (!$preview && $option < 4) {
$form = drupal_get_form('privatemsg_view_form', $message, $prev, $next);
}
if (!$preview && ($option == '1' || $option == '3')) {
$output .= $form;
}
$output .= theme('table', NULL, $rows, array(
'id' => 'message-' . $message->id,
'class' => 'pm-view-table',
));
$output .= $body;
if (!$preview && ($option == '2' || $option == '3')) {
$output .= $form;
}
if (!$preview && $option == '4') {
$output .= $link_display;
}
return $output;
}