1 | <?php
|
---|
2 | /**
|
---|
3 | *
|
---|
4 | * @package ucp
|
---|
5 | * @version $Id: ucp_pm_viewmessage.php 9174 2008-12-04 19:58:42Z toonarmy $
|
---|
6 | * @copyright (c) 2005 phpBB Group
|
---|
7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * @ignore
|
---|
13 | */
|
---|
14 | if (!defined('IN_PHPBB'))
|
---|
15 | {
|
---|
16 | exit;
|
---|
17 | }
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * View private message
|
---|
21 | */
|
---|
22 | function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
|
---|
23 | {
|
---|
24 | global $user, $template, $auth, $db, $cache;
|
---|
25 | global $phpbb_root_path, $phpEx, $config;
|
---|
26 |
|
---|
27 | $user->add_lang(array('viewtopic', 'memberlist'));
|
---|
28 |
|
---|
29 | $msg_id = (int) $msg_id;
|
---|
30 | $folder_id = (int) $folder_id;
|
---|
31 | $author_id = (int) $message_row['author_id'];
|
---|
32 |
|
---|
33 | // Not able to view message, it was deleted by the sender
|
---|
34 | if ($message_row['pm_deleted'])
|
---|
35 | {
|
---|
36 | $meta_info = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&folder=$folder_id");
|
---|
37 | $message = $user->lang['NO_AUTH_READ_REMOVED_MESSAGE'];
|
---|
38 |
|
---|
39 | $message .= '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $meta_info . '">', '</a>');
|
---|
40 | trigger_error($message);
|
---|
41 | }
|
---|
42 |
|
---|
43 | // Do not allow hold messages to be seen
|
---|
44 | if ($folder_id == PRIVMSGS_HOLD_BOX)
|
---|
45 | {
|
---|
46 | trigger_error('NO_AUTH_READ_HOLD_MESSAGE');
|
---|
47 | }
|
---|
48 |
|
---|
49 | // Grab icons
|
---|
50 | $icons = $cache->obtain_icons();
|
---|
51 |
|
---|
52 | $bbcode = false;
|
---|
53 |
|
---|
54 | // Instantiate BBCode if need be
|
---|
55 | if ($message_row['bbcode_bitfield'])
|
---|
56 | {
|
---|
57 | include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
---|
58 | $bbcode = new bbcode($message_row['bbcode_bitfield']);
|
---|
59 | }
|
---|
60 |
|
---|
61 | // Assign TO/BCC Addresses to template
|
---|
62 | write_pm_addresses(array('to' => $message_row['to_address'], 'bcc' => $message_row['bcc_address']), $author_id);
|
---|
63 |
|
---|
64 | $user_info = get_user_information($author_id, $message_row);
|
---|
65 |
|
---|
66 | // Parse the message and subject
|
---|
67 | $message = censor_text($message_row['message_text']);
|
---|
68 |
|
---|
69 | // Second parse bbcode here
|
---|
70 | if ($message_row['bbcode_bitfield'])
|
---|
71 | {
|
---|
72 | $bbcode->bbcode_second_pass($message, $message_row['bbcode_uid'], $message_row['bbcode_bitfield']);
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Always process smilies after parsing bbcodes
|
---|
76 | $message = bbcode_nl2br($message);
|
---|
77 | $message = smiley_text($message);
|
---|
78 |
|
---|
79 | // Replace naughty words such as farty pants
|
---|
80 | $message_row['message_subject'] = censor_text($message_row['message_subject']);
|
---|
81 |
|
---|
82 | // Editing information
|
---|
83 | if ($message_row['message_edit_count'] && $config['display_last_edited'])
|
---|
84 | {
|
---|
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'], false, true), $message_row['message_edit_count']);
|
---|
87 | }
|
---|
88 | else
|
---|
89 | {
|
---|
90 | $l_edited_by = '';
|
---|
91 | }
|
---|
92 |
|
---|
93 | // Pull attachment data
|
---|
94 | $display_notice = false;
|
---|
95 | $attachments = array();
|
---|
96 |
|
---|
97 | if ($message_row['message_attachment'] && $config['allow_pm_attach'])
|
---|
98 | {
|
---|
99 | if ($auth->acl_get('u_pm_download'))
|
---|
100 | {
|
---|
101 | $sql = 'SELECT *
|
---|
102 | FROM ' . ATTACHMENTS_TABLE . "
|
---|
103 | WHERE post_msg_id = $msg_id
|
---|
104 | AND in_message = 1
|
---|
105 | ORDER BY filetime DESC, post_msg_id ASC";
|
---|
106 | $result = $db->sql_query($sql);
|
---|
107 |
|
---|
108 | while ($row = $db->sql_fetchrow($result))
|
---|
109 | {
|
---|
110 | $attachments[] = $row;
|
---|
111 | }
|
---|
112 | $db->sql_freeresult($result);
|
---|
113 |
|
---|
114 | // No attachments exist, but message table thinks they do so go ahead and reset attach flags
|
---|
115 | if (!sizeof($attachments))
|
---|
116 | {
|
---|
117 | $sql = 'UPDATE ' . PRIVMSGS_TABLE . "
|
---|
118 | SET message_attachment = 0
|
---|
119 | WHERE msg_id = $msg_id";
|
---|
120 | $db->sql_query($sql);
|
---|
121 | }
|
---|
122 | }
|
---|
123 | else
|
---|
124 | {
|
---|
125 | $display_notice = true;
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | // Assign inline attachments
|
---|
130 | if (!empty($attachments))
|
---|
131 | {
|
---|
132 | $update_count = array();
|
---|
133 | parse_attachments(false, $message, $attachments, $update_count);
|
---|
134 |
|
---|
135 | // Update the attachment download counts
|
---|
136 | if (sizeof($update_count))
|
---|
137 | {
|
---|
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);
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 | $user_info['sig'] = '';
|
---|
146 |
|
---|
147 | $signature = ($message_row['enable_sig'] && $config['allow_sig'] && $auth->acl_get('u_sig') && $user->optionget('viewsigs')) ? $user_info['user_sig'] : '';
|
---|
148 |
|
---|
149 | // End signature parsing, only if needed
|
---|
150 | if ($signature)
|
---|
151 | {
|
---|
152 | $signature = censor_text($signature);
|
---|
153 |
|
---|
154 | if ($user_info['user_sig_bbcode_bitfield'])
|
---|
155 | {
|
---|
156 | if ($bbcode === false)
|
---|
157 | {
|
---|
158 | include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
---|
159 | $bbcode = new bbcode($user_info['user_sig_bbcode_bitfield']);
|
---|
160 | }
|
---|
161 |
|
---|
162 | $bbcode->bbcode_second_pass($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield']);
|
---|
163 | }
|
---|
164 |
|
---|
165 | $signature = bbcode_nl2br($signature);
|
---|
166 | $signature = smiley_text($signature);
|
---|
167 | }
|
---|
168 |
|
---|
169 | $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm');
|
---|
170 |
|
---|
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']),
|
---|
176 |
|
---|
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'] : '',
|
---|
183 |
|
---|
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']),
|
---|
194 |
|
---|
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'],
|
---|
201 |
|
---|
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) : '',
|
---|
209 |
|
---|
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",
|
---|
217 |
|
---|
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)),
|
---|
222 |
|
---|
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_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '')
|
---|
225 | );
|
---|
226 |
|
---|
227 | // Display not already displayed Attachments for this post, we already parsed them. ;)
|
---|
228 | if (isset($attachments) && sizeof($attachments))
|
---|
229 | {
|
---|
230 | foreach ($attachments as $attachment)
|
---|
231 | {
|
---|
232 | $template->assign_block_vars('attachment', array(
|
---|
233 | 'DISPLAY_ATTACHMENT' => $attachment)
|
---|
234 | );
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | if (!isset($_REQUEST['view']) || $_REQUEST['view'] != 'print')
|
---|
239 | {
|
---|
240 | // Message History
|
---|
241 | if (message_history($msg_id, $user->data['user_id'], $message_row, $folder))
|
---|
242 | {
|
---|
243 | $template->assign_var('S_DISPLAY_HISTORY', true);
|
---|
244 | }
|
---|
245 | }
|
---|
246 | }
|
---|
247 |
|
---|
248 | /**
|
---|
249 | * Get user information (only for message display)
|
---|
250 | */
|
---|
251 | function get_user_information($user_id, $user_row)
|
---|
252 | {
|
---|
253 | global $db, $auth, $user, $cache;
|
---|
254 | global $phpbb_root_path, $phpEx, $config;
|
---|
255 |
|
---|
256 | if (!$user_id)
|
---|
257 | {
|
---|
258 | return array();
|
---|
259 | }
|
---|
260 |
|
---|
261 | if (empty($user_row))
|
---|
262 | {
|
---|
263 | $sql = 'SELECT *
|
---|
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);
|
---|
269 | }
|
---|
270 |
|
---|
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'] = '';
|
---|
274 |
|
---|
275 | // Generate online information for user
|
---|
276 | if ($config['load_onlinetrack'])
|
---|
277 | {
|
---|
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);
|
---|
285 |
|
---|
286 | $update_time = $config['load_online_time'] * 60;
|
---|
287 | if ($row)
|
---|
288 | {
|
---|
289 | $user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'])) ? true : false;
|
---|
290 | }
|
---|
291 | }
|
---|
292 |
|
---|
293 | if (!function_exists('get_user_avatar'))
|
---|
294 | {
|
---|
295 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
---|
296 | }
|
---|
297 |
|
---|
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']) : '';
|
---|
299 |
|
---|
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']);
|
---|
301 |
|
---|
302 | if (!empty($user_row['user_allow_viewemail']) || $auth->acl_get('a_email'))
|
---|
303 | {
|
---|
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']);
|
---|
305 | }
|
---|
306 |
|
---|
307 | return $user_row;
|
---|
308 | }
|
---|
309 |
|
---|
310 | ?>
|
---|