5
* @version $Id: ucp_pm_viewmessage.php,v 1.66 2007/10/05 14:36:34 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
20
* View private message
22
function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
24
global $user, $template, $auth, $db, $cache;
25
global $phpbb_root_path, $phpEx, $config;
27
$user->add_lang(array('viewtopic', 'memberlist'));
29
$msg_id = (int) $msg_id;
30
$folder_id = (int) $folder_id;
31
$author_id = (int) $message_row['author_id'];
33
// Not able to view message, it was deleted by the sender
34
if ($message_row['pm_deleted'])
36
$meta_info = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&folder=$folder_id");
37
$message = $user->lang['NO_AUTH_READ_REMOVED_MESSAGE'];
39
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $meta_info . '">', '</a>');
40
trigger_error($message);
43
// Do not allow hold messages to be seen
44
if ($folder_id == PRIVMSGS_HOLD_BOX)
46
trigger_error('NO_AUTH_READ_HOLD_MESSAGE');
50
$icons = $cache->obtain_icons();
54
// Instantiate BBCode if need be
55
if ($message_row['bbcode_bitfield'])
57
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
58
$bbcode = new bbcode($message_row['bbcode_bitfield']);
61
// Assign TO/BCC Addresses to template
62
write_pm_addresses(array('to' => $message_row['to_address'], 'bcc' => $message_row['bcc_address']), $author_id);
64
$user_info = get_user_information($author_id, $message_row);
66
// Parse the message and subject
67
$message = censor_text($message_row['message_text']);
69
// Second parse bbcode here
70
if ($message_row['bbcode_bitfield'])
72
$bbcode->bbcode_second_pass($message, $message_row['bbcode_uid'], $message_row['bbcode_bitfield']);
75
// Always process smilies after parsing bbcodes
76
$message = bbcode_nl2br($message);
77
$message = smiley_text($message);
79
// Replace naughty words such as farty pants
80
$message_row['message_subject'] = censor_text($message_row['message_subject']);
82
// Editing information
83
if ($message_row['message_edit_count'] && $config['display_last_edited'])
85
$l_edit_time_total = ($message_row['message_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];
86
$l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, (!$message_row['message_edit_user']) ? $message_row['username'] : $message_row['message_edit_user'], $user->format_date($message_row['message_edit_time']), $message_row['message_edit_count']);
93
// Pull attachment data
94
$display_notice = false;
95
$attachments = array();
97
if ($message_row['message_attachment'] && $config['allow_pm_attach'])
99
if ($auth->acl_get('u_pm_download'))
102
FROM ' . ATTACHMENTS_TABLE . "
103
WHERE post_msg_id = $msg_id
105
ORDER BY filetime DESC, post_msg_id ASC";
106
$result = $db->sql_query($sql);
108
while ($row = $db->sql_fetchrow($result))
110
$attachments[] = $row;
112
$db->sql_freeresult($result);
114
// No attachments exist, but message table thinks they do so go ahead and reset attach flags
115
if (!sizeof($attachments))
117
$sql = 'UPDATE ' . PRIVMSGS_TABLE . "
118
SET message_attachment = 0
119
WHERE msg_id = $msg_id";
120
$db->sql_query($sql);
125
$display_notice = true;
129
// Assign inline attachments
130
if (!empty($attachments))
132
$update_count = array();
133
parse_attachments(false, $message, $attachments, $update_count);
135
// Update the attachment download counts
136
if (sizeof($update_count))
138
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
139
SET download_count = download_count + 1
140
WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));
141
$db->sql_query($sql);
145
$user_info['sig'] = '';
147
$signature = ($message_row['enable_sig'] && $config['allow_sig'] && $auth->acl_get('u_sig') && $user->optionget('viewsigs')) ? $user_info['user_sig'] : '';
149
// End signature parsing, only if needed
152
$signature = censor_text($signature);
154
if ($user_info['user_sig_bbcode_bitfield'])
156
if ($bbcode === false)
158
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
159
$bbcode = new bbcode($user_info['user_sig_bbcode_bitfield']);
162
$bbcode->bbcode_second_pass($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield']);
165
$signature = bbcode_nl2br($signature);
166
$signature = smiley_text($signature);
169
$url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm');
171
$template->assign_vars(array(
172
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
173
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
174
'MESSAGE_AUTHOR' => get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
175
'U_MESSAGE_AUTHOR' => get_username_string('profile', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
177
'RANK_TITLE' => $user_info['rank_title'],
178
'RANK_IMG' => $user_info['rank_image'],
179
'AUTHOR_AVATAR' => (isset($user_info['avatar'])) ? $user_info['avatar'] : '',
180
'AUTHOR_JOINED' => $user->format_date($user_info['user_regdate']),
181
'AUTHOR_POSTS' => (!empty($user_info['user_posts'])) ? $user_info['user_posts'] : '',
182
'AUTHOR_FROM' => (!empty($user_info['user_from'])) ? $user_info['user_from'] : '',
184
'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : ((isset($user_info['online']) && $user_info['online']) ? $user->img('icon_user_online', $user->lang['ONLINE']) : $user->img('icon_user_offline', $user->lang['OFFLINE'])),
185
'S_ONLINE' => (!$config['load_onlinetrack']) ? false : ((isset($user_info['online']) && $user_info['online']) ? true : false),
186
'DELETE_IMG' => $user->img('icon_post_delete', $user->lang['DELETE_MESSAGE']),
187
'INFO_IMG' => $user->img('icon_post_info', $user->lang['VIEW_PM_INFO']),
188
'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['READ_PROFILE']),
189
'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['SEND_EMAIL']),
190
'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['POST_QUOTE_PM']),
191
'REPLY_IMG' => $user->img('button_pm_reply', $user->lang['POST_REPLY_PM']),
192
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']),
193
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']),
195
'SENT_DATE' => $user->format_date($message_row['message_time']),
196
'SUBJECT' => $message_row['message_subject'],
197
'MESSAGE' => $message,
198
'SIGNATURE' => ($message_row['enable_sig']) ? $signature : '',
199
'EDITED_MESSAGE' => $l_edited_by,
200
'MESSAGE_ID' => $message_row['msg_id'],
202
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $author_id) : '',
203
'U_WWW' => (!empty($user_info['user_website'])) ? $user_info['user_website'] : '',
204
'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($user_info['user_icq']) : '',
205
'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $author_id) : '',
206
'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&.src=pg' : '',
207
'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $author_id) : '',
208
'U_JABBER' => ($user_info['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $author_id) : '',
210
'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '',
211
'U_EMAIL' => $user_info['email'],
212
'U_QUOTE' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=$folder_id&p=" . $message_row['msg_id'] : '',
213
'U_EDIT' => (($message_row['message_time'] > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit')) ? "$url&mode=compose&action=edit&f=$folder_id&p=" . $message_row['msg_id'] : '',
214
'U_POST_REPLY_PM' => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $message_row['msg_id'] : '',
215
'U_PREVIOUS_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=previous",
216
'U_NEXT_PM' => "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=next",
218
'S_HAS_ATTACHMENTS' => (sizeof($attachments)) ? true : false,
219
'S_DISPLAY_NOTICE' => $display_notice && $message_row['message_attachment'],
220
'S_AUTHOR_DELETED' => ($author_id == ANONYMOUS) ? true : false,
221
'S_SPECIAL_FOLDER' => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)),
223
'U_PRINT_PM' => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=print" : '',
224
'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '')
227
// Display not already displayed Attachments for this post, we already parsed them. ;)
228
if (isset($attachments) && sizeof($attachments))
230
foreach ($attachments as $attachment)
232
$template->assign_block_vars('attachment', array(
233
'DISPLAY_ATTACHMENT' => $attachment)
238
if (!isset($_REQUEST['view']) || $_REQUEST['view'] != 'print')
241
if (message_history($msg_id, $user->data['user_id'], $message_row, $folder))
243
$template->assign_var('S_DISPLAY_HISTORY', true);
249
* Get user information (only for message display)
251
function get_user_information($user_id, $user_row)
253
global $db, $auth, $user, $cache;
254
global $phpbb_root_path, $phpEx, $config;
261
if (empty($user_row))
264
FROM ' . USERS_TABLE . '
265
WHERE user_id = ' . (int) $user_id;
266
$result = $db->sql_query($sql);
267
$user_row = $db->sql_fetchrow($result);
268
$db->sql_freeresult($result);
271
// Some standard values
272
$user_row['online'] = false;
273
$user_row['rank_title'] = $user_row['rank_image'] = $user_row['rank_image_src'] = $user_row['email'] = '';
275
// Generate online information for user
276
if ($config['load_onlinetrack'])
278
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
279
FROM ' . SESSIONS_TABLE . "
280
WHERE session_user_id = $user_id
281
GROUP BY session_user_id";
282
$result = $db->sql_query_limit($sql, 1);
283
$row = $db->sql_fetchrow($result);
284
$db->sql_freeresult($result);
286
$update_time = $config['load_online_time'] * 60;
289
$user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'])) ? true : false;
293
if (!function_exists('get_user_avatar'))
295
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
298
$user_row['avatar'] = ($user->optionget('viewavatars')) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']) : '';
300
get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']);
302
if (!empty($user_row['user_allow_viewemail']) || $auth->acl_get('a_email'))
304
$user_row['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$user_id") : ((($config['board_hide_emails'] && !$auth->acl_get('a_email')) || empty($user_row['user_email'])) ? '' : 'mailto:' . $user_row['user_email']);
b'\\ No newline at end of file'