Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ucp_pm_viewmessage.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 15.15 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  /**
015  * @ignore
016  */
017  if (!defined('IN_PHPBB'))
018  {
019      exit;
020  }
021   
022  /**
023  * View private message
024  */
025  function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
026  {
027      global $user, $template, $auth, $db, $cache, $phpbb_container;
028      global $phpbb_root_path, $request, $phpEx, $config, $phpbb_dispatcher;
029   
030      $user->add_lang(array('viewtopic', 'memberlist'));
031   
032      $msg_id        = (int) $msg_id;
033      $folder_id    = (int) $folder_id;
034      $author_id    = (int) $message_row['author_id'];
035      $view        = request_var('view', '');
036   
037      // Not able to view message, it was deleted by the sender
038      if ($message_row['pm_deleted'])
039      {
040          $meta_info = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;folder=$folder_id");
041          $message = $user->lang['NO_AUTH_READ_REMOVED_MESSAGE'];
042   
043          $message .= '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $meta_info . '">', '</a>');
044          trigger_error($message);
045      }
046   
047      // Do not allow hold messages to be seen
048      if ($folder_id == PRIVMSGS_HOLD_BOX)
049      {
050          trigger_error('NO_AUTH_READ_HOLD_MESSAGE');
051      }
052   
053      // Grab icons
054      $icons = $cache->obtain_icons();
055   
056      $bbcode = false;
057   
058      // Instantiate BBCode if need be
059      if ($message_row['bbcode_bitfield'])
060      {
061          include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
062          $bbcode = new bbcode($message_row['bbcode_bitfield']);
063      }
064   
065      // Load the custom profile fields
066      if ($config['load_cpf_pm'])
067      {
068          $cp = $phpbb_container->get('profilefields.manager');
069   
070          $profile_fields = $cp->grab_profile_fields_data($author_id);
071      }
072   
073      // Assign TO/BCC Addresses to template
074      write_pm_addresses(array('to' => $message_row['to_address'], 'bcc' => $message_row['bcc_address']), $author_id);
075   
076      $user_info = get_user_information($author_id, $message_row);
077   
078      // Parse the message and subject
079      $parse_flags = ($message_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
080      $message = generate_text_for_display($message_row['message_text'], $message_row['bbcode_uid'], $message_row['bbcode_bitfield'], $parse_flags, true);
081   
082      // Replace naughty words such as farty pants
083      $message_row['message_subject'] = censor_text($message_row['message_subject']);
084   
085      // Editing information
086      if ($message_row['message_edit_count'] && $config['display_last_edited'])
087      {
088          if (!$message_row['message_edit_user'])
089          {
090              $display_username = get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour']);
091          }
092          else
093          {
094              $edit_user_info = get_user_information($message_row['message_edit_user'], false);
095              $display_username = get_username_string('full', $message_row['message_edit_user'], $edit_user_info['username'], $edit_user_info['user_colour']);
096          }
097          $l_edited_by = '<br /><br />' . $user->lang('EDITED_TIMES_TOTAL', (int) $message_row['message_edit_count'], $display_username, $user->format_date($message_row['message_edit_time'], false, true));
098      }
099      else
100      {
101          $l_edited_by = '';
102      }
103   
104      // Pull attachment data
105      $display_notice = false;
106      $attachments = array();
107   
108      if ($message_row['message_attachment'] && $config['allow_pm_attach'])
109      {
110          if ($auth->acl_get('u_pm_download'))
111          {
112              $sql = 'SELECT *
113                  FROM ' . ATTACHMENTS_TABLE . "
114                  WHERE post_msg_id = $msg_id
115                      AND in_message = 1
116                  ORDER BY filetime DESC, post_msg_id ASC";
117              $result = $db->sql_query($sql);
118   
119              while ($row = $db->sql_fetchrow($result))
120              {
121                  $attachments[] = $row;
122              }
123              $db->sql_freeresult($result);
124   
125              // No attachments exist, but message table thinks they do so go ahead and reset attach flags
126              if (!sizeof($attachments))
127              {
128                  $sql = 'UPDATE ' . PRIVMSGS_TABLE . "
129                      SET message_attachment = 0
130                      WHERE msg_id = $msg_id";
131                  $db->sql_query($sql);
132              }
133          }
134          else
135          {
136              $display_notice = true;
137          }
138      }
139   
140      // Assign inline attachments
141      if (!empty($attachments))
142      {
143          $update_count = array();
144          parse_attachments(false, $message, $attachments, $update_count);
145   
146          // Update the attachment download counts
147          if (sizeof($update_count))
148          {
149              $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
150                  SET download_count = download_count + 1
151                  WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));
152              $db->sql_query($sql);
153          }
154      }
155   
156      $user_info['sig'] = '';
157   
158      $signature = ($message_row['enable_sig'] && $config['allow_sig'] && $auth->acl_get('u_sig') && $user->optionget('viewsigs')) ? $user_info['user_sig'] : '';
159   
160      // End signature parsing, only if needed
161      if ($signature)
162      {
163          $parse_flags = ($user_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
164          $signature = generate_text_for_display($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield'], $parse_flags, true);
165      }
166   
167      $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm');
168   
169      // Number of "to" recipients
170      $num_recipients = (int) preg_match_all('/:?(u|g)_([0-9]+):?/', $message_row['to_address'], $match);
171   
172      $bbcode_status    = ($config['allow_bbcode'] && $config['auth_bbcode_pm'] && $auth->acl_get('u_pm_bbcode')) ? true : false;
173   
174      // Get the profile fields template data
175      $cp_row = array();
176      if ($config['load_cpf_pm'] && isset($profile_fields[$author_id]))
177      {
178          // Filter the fields we don't want to show
179          foreach ($profile_fields[$author_id] as $used_ident => $profile_field)
180          {
181              if (!$profile_field['data']['field_show_on_pm'])
182              {
183                  unset($profile_fields[$author_id][$used_ident]);
184              }
185          }
186   
187          if (isset($profile_fields[$author_id]))
188          {
189              $cp_row = $cp->generate_profile_fields_template_data($profile_fields[$author_id]);
190          }
191      }
192   
193      $u_pm = $u_jabber = '';
194   
195      if ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')))
196      {
197          $u_pm = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $author_id);
198      }
199   
200      if ($user_info['user_jabber'] && $auth->acl_get('u_sendim'))
201      {
202          $u_jabber = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=jabber&amp;u=' . $author_id);
203      }
204   
205      $msg_data = array(
206          'MESSAGE_AUTHOR_FULL'        => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
207          'MESSAGE_AUTHOR_COLOUR'        => get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
208          'MESSAGE_AUTHOR'            => get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
209          'U_MESSAGE_AUTHOR'            => get_username_string('profile', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
210   
211          'RANK_TITLE'        => $user_info['rank_title'],
212          'RANK_IMG'            => $user_info['rank_image'],
213          'AUTHOR_AVATAR'        => (isset($user_info['avatar'])) ? $user_info['avatar'] : '',
214          'AUTHOR_JOINED'        => $user->format_date($user_info['user_regdate']),
215          'AUTHOR_POSTS'        => (int) $user_info['user_posts'],
216          'CONTACT_USER'        => $user->lang('CONTACT_USER', get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username'])),
217   
218          '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'])),
219          'S_ONLINE'            => (!$config['load_onlinetrack']) ? false : ((isset($user_info['online']) && $user_info['online']) ? true : false),
220          'DELETE_IMG'        => $user->img('icon_post_delete', $user->lang['DELETE_MESSAGE']),
221          'INFO_IMG'            => $user->img('icon_post_info', $user->lang['VIEW_PM_INFO']),
222          'PROFILE_IMG'        => $user->img('icon_user_profile', $user->lang['READ_PROFILE']),
223          'EMAIL_IMG'            => $user->img('icon_contact_email', $user->lang['SEND_EMAIL']),
224          'QUOTE_IMG'            => $user->img('icon_post_quote', $user->lang['POST_QUOTE_PM']),
225          'REPLY_IMG'            => $user->img('button_pm_reply', $user->lang['POST_REPLY_PM']),
226          'REPORT_IMG'        => $user->img('icon_post_report', 'REPORT_PM'),
227          'EDIT_IMG'            => $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']),
228          'MINI_POST_IMG'        => $user->img('icon_post_target', $user->lang['PM']),
229   
230          'SENT_DATE'            => ($view == 'print') ? $user->format_date($message_row['message_time'], false, true) : $user->format_date($message_row['message_time']),
231          'SUBJECT'            => $message_row['message_subject'],
232          'MESSAGE'            => $message,
233          'SIGNATURE'            => ($message_row['enable_sig']) ? $signature : '',
234          'EDITED_MESSAGE'    => $l_edited_by,
235          'MESSAGE_ID'        => $message_row['msg_id'],
236   
237          'U_PM'            =>  $u_pm,
238          'U_JABBER'        =>  $u_jabber,
239   
240          'U_DELETE'            => ($auth->acl_get('u_pm_delete')) ? "$url&amp;mode=compose&amp;action=delete&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
241          'U_EMAIL'            => $user_info['email'],
242          'U_REPORT'            => ($config['allow_pm_report']) ? append_sid("{$phpbb_root_path}report.$phpEx", "pm=" . $message_row['msg_id']) : '',
243          'U_QUOTE'            => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=quote&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
244          '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&amp;mode=compose&amp;action=edit&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
245          'U_POST_REPLY_PM'    => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
246          'U_POST_REPLY_ALL'    => ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;reply_to_all=1&amp;p=" . $message_row['msg_id'] : '',
247          'U_PREVIOUS_PM'        => "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=previous",
248          'U_NEXT_PM'            => "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=next",
249   
250          'U_PM_ACTION'        => $url . '&amp;mode=compose&amp;f=' . $folder_id . '&amp;p=' . $message_row['msg_id'],
251   
252          'S_HAS_ATTACHMENTS'    => (sizeof($attachments)) ? true : false,
253          'S_DISPLAY_NOTICE'    => $display_notice && $message_row['message_attachment'],
254          'S_AUTHOR_DELETED'    => ($author_id == ANONYMOUS) ? true : false,
255          'S_SPECIAL_FOLDER'    => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)),
256          'S_PM_RECIPIENTS'    => $num_recipients,
257          'S_BBCODE_ALLOWED'    => ($bbcode_status) ? 1 : 0,
258          'S_CUSTOM_FIELDS'    => (!empty($cp_row['row'])) ? true : false,
259   
260          'U_PRINT_PM'        => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=print" : '',
261          'U_FORWARD_PM'        => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&amp;mode=compose&amp;action=forward&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
262      );
263   
264      /**
265      * Modify pm and sender data before it is assigned to the template
266      *
267      * @event core.ucp_pm_view_messsage
268      * @var    mixed    id            Active module category (can be int or string)
269      * @var    string    mode        Active module
270      * @var    int        folder_id    ID of the folder the message is in
271      * @var    int        msg_id        ID of the private message
272      * @var    array    folder        Array with data of user's message folders
273      * @var    array    message_row    Array with message data
274      * @var    array    cp_row        Array with senders custom profile field data
275      * @var    array    msg_data    Template array with message data
276      * @since 3.1.0-a1
277      */
278      $vars = array(
279          'id',
280          'mode',
281          'folder_id',
282          'msg_id',
283          'folder',
284          'message_row',
285          'cp_row',
286          'msg_data',
287      );
288      extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_messsage', compact($vars)));
289   
290      $template->assign_vars($msg_data);
291   
292      $contact_fields = array(
293          array(
294              'ID'        => 'pm',
295              'NAME'        => $user->lang['SEND_PRIVATE_MESSAGE'],
296              'U_CONTACT' => $u_pm,
297          ),
298          array(
299              'ID'        => 'email',
300              'NAME'        => $user->lang['SEND_EMAIL'],
301              'U_CONTACT'    => $user_info['email'],
302          ),
303          array(
304              'ID'        => 'jabber',
305              'NAME'        => $user->lang['JABBER'],
306              'U_CONTACT'    => $u_jabber,
307          ),
308      );
309   
310      foreach ($contact_fields as $field)
311      {
312          if ($field['U_CONTACT'])
313          {
314              $template->assign_block_vars('contact', $field);
315          }
316      }
317   
318      // Display the custom profile fields
319      if (!empty($cp_row['row']))
320      {
321          $template->assign_vars($cp_row['row']);
322   
323          foreach ($cp_row['blockrow'] as $cp_block_row)
324          {
325              $template->assign_block_vars('custom_fields', $cp_block_row);
326   
327              if ($cp_block_row['S_PROFILE_CONTACT'])
328              {
329                  $template->assign_block_vars('contact', array(
330                      'ID'        => $cp_block_row['PROFILE_FIELD_IDENT'],
331                      'NAME'        => $cp_block_row['PROFILE_FIELD_NAME'],
332                      'U_CONTACT'    => $cp_block_row['PROFILE_FIELD_CONTACT'],
333                  ));
334              }
335          }
336      }
337   
338      // Display not already displayed Attachments for this post, we already parsed them. ;)
339      if (isset($attachments) && sizeof($attachments))
340      {
341          foreach ($attachments as $attachment)
342          {
343              $template->assign_block_vars('attachment', array(
344                  'DISPLAY_ATTACHMENT'    => $attachment)
345              );
346          }
347      }
348   
349      if (!isset($_REQUEST['view']) || $request->variable('view', '') != 'print')
350      {
351          // Message History
352          if (message_history($msg_id, $user->data['user_id'], $message_row, $folder))
353          {
354              $template->assign_var('S_DISPLAY_HISTORY', true);
355          }
356      }
357  }
358   
359  /**
360  * Get user information (only for message display)
361  */
362  function get_user_information($user_id, $user_row)
363  {
364      global $db, $auth, $user, $cache;
365      global $phpbb_root_path, $phpEx, $config;
366   
367      if (!$user_id)
368      {
369          return array();
370      }
371   
372      if (empty($user_row))
373      {
374          $sql = 'SELECT *
375              FROM ' . USERS_TABLE . '
376              WHERE user_id = ' . (int) $user_id;
377          $result = $db->sql_query($sql);
378          $user_row = $db->sql_fetchrow($result);
379          $db->sql_freeresult($result);
380      }
381   
382      // Some standard values
383      $user_row['online'] = false;
384      $user_row['rank_title'] = $user_row['rank_image'] = $user_row['rank_image_src'] = $user_row['email'] = '';
385   
386      // Generate online information for user
387      if ($config['load_onlinetrack'])
388      {
389          $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
390              FROM ' . SESSIONS_TABLE . "
391              WHERE session_user_id = $user_id
392              GROUP BY session_user_id";
393          $result = $db->sql_query_limit($sql, 1);
394          $row = $db->sql_fetchrow($result);
395          $db->sql_freeresult($result);
396   
397          $update_time = $config['load_online_time'] * 60;
398          if ($row)
399          {
400              $user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? true : false;
401          }
402      }
403   
404      $user_row['avatar'] = ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($user_row) : '';
405   
406      if (!function_exists('phpbb_get_user_rank'))
407      {
408          include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
409      }
410   
411      $user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']);
412      $user_row['rank_title'] = $user_rank_data['title'];
413      $user_row['rank_image'] = $user_rank_data['img'];
414      $user_row['rank_image_src'] = $user_rank_data['img_src'];
415   
416      if ((!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
417      {
418          $user_row['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;u=$user_id") : ((($config['board_hide_emails'] && !$auth->acl_get('a_email')) || empty($user_row['user_email'])) ? '' : 'mailto:' . $user_row['user_email']);
419      }
420   
421      return $user_row;
422  }
423