Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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