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.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 12.45 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  * Private Message Class
024  *
025  * $_REQUEST['folder'] display folder with the id used
026  * $_REQUEST['folder'] inbox|outbox|sentbox display folder with the associated name
027  *
028  *    Display Messages (default to inbox) - mode=view
029  *    Display single message - mode=view&p=[msg_id] or &p=[msg_id] (short linkage)
030  *
031  *    if the folder id with (&f=[folder_id]) is used when displaying messages, one query will be saved. If it is not used, phpBB needs to grab
032  *    the folder id first in order to display the input boxes and folder names and such things. ;) phpBB always checks this against the database to make
033  *    sure the user is able to view the message.
034  *
035  *    Composing Messages (mode=compose):
036  *        To specific user (u=[user_id])
037  *        To specific group (g=[group_id])
038  *        Quoting a post (action=quotepost&p=[post_id])
039  *        Quoting a PM (action=quote&p=[msg_id])
040  *        Forwarding a PM (action=forward&p=[msg_id])
041  */
042  class ucp_pm
043  {
044      var $u_action;
045   
046      function main($id, $mode)
047      {
048          global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config, $request;
049   
050          if (!$user->data['is_registered'])
051          {
052              trigger_error('NO_MESSAGE');
053          }
054   
055          // Is PM disabled?
056          if (!$config['allow_privmsg'])
057          {
058              trigger_error('PM_DISABLED');
059          }
060   
061          $user->add_lang('posting');
062          $template->assign_var('S_PRIVMSGS', true);
063   
064          // Folder directly specified?
065          $folder_specified = $request->variable('folder', '');
066   
067          if (!in_array($folder_specified, array('inbox', 'outbox', 'sentbox')))
068          {
069              $folder_specified = (int) $folder_specified;
070          }
071          else
072          {
073              $folder_specified = ($folder_specified == 'inbox') ? PRIVMSGS_INBOX : (($folder_specified == 'outbox') ? PRIVMSGS_OUTBOX : PRIVMSGS_SENTBOX);
074          }
075   
076          if (!$folder_specified)
077          {
078              $mode = (!$mode) ? $request->variable('mode', 'view') : $mode;
079          }
080          else
081          {
082              $mode = 'view';
083          }
084   
085          include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
086   
087          switch ($mode)
088          {
089              // Compose message
090              case 'compose':
091                  $action = $request->variable('action', 'post');
092   
093                  $user_folders = get_folder($user->data['user_id']);
094   
095                  if ($action != 'delete' && !$auth->acl_get('u_sendpm'))
096                  {
097                      // trigger_error('NO_AUTH_SEND_MESSAGE');
098                      $template->assign_vars(array(
099                          'S_NO_AUTH_SEND_MESSAGE'    => true,
100                          'S_COMPOSE_PM_VIEW'            => true,
101                      ));
102   
103                      $tpl_file = 'ucp_pm_viewfolder';
104                      break;
105                  }
106   
107                  include($phpbb_root_path . 'includes/ucp/ucp_pm_compose.' . $phpEx);
108                  compose_pm($id, $mode, $action, $user_folders);
109   
110                  $tpl_file = 'posting_body';
111              break;
112   
113              case 'options':
114                  set_user_message_limit();
115                  get_folder($user->data['user_id']);
116   
117                  include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx);
118                  message_options($id, $mode, $global_privmsgs_rules, $global_rule_conditions);
119   
120                  $tpl_file = 'ucp_pm_options';
121              break;
122   
123              case 'drafts':
124   
125                  get_folder($user->data['user_id']);
126                  $this->p_name = 'pm';
127   
128                  // Call another module... please do not try this at home... Hoochie Coochie Man
129                  include($phpbb_root_path . 'includes/ucp/ucp_main.' . $phpEx);
130   
131                  $module = new ucp_main($this);
132                  $module->u_action = $this->u_action;
133                  $module->main($id, $mode);
134   
135                  $this->tpl_name = $module->tpl_name;
136                  $this->page_title = 'UCP_PM_DRAFTS';
137   
138                  unset($module);
139                  return;
140   
141              break;
142   
143              case 'view':
144   
145                  set_user_message_limit();
146   
147                  if ($folder_specified)
148                  {
149                      $folder_id = $folder_specified;
150                      $action = 'view_folder';
151                  }
152                  else
153                  {
154                      $folder_id = $request->variable('f', PRIVMSGS_NO_BOX);
155                      $action = $request->variable('action', 'view_folder');
156                  }
157   
158                  $msg_id = $request->variable('p', 0);
159                  $view    = $request->variable('view', '');
160   
161                  // View message if specified
162                  if ($msg_id)
163                  {
164                      $action = 'view_message';
165                  }
166   
167                  if (!$auth->acl_get('u_readpm'))
168                  {
169                      send_status_line(403, 'Forbidden');
170                      trigger_error('NO_AUTH_READ_MESSAGE');
171                  }
172   
173                  // Do not allow hold messages to be seen
174                  if ($folder_id == PRIVMSGS_HOLD_BOX)
175                  {
176                      trigger_error('NO_AUTH_READ_HOLD_MESSAGE');
177                  }
178   
179                  // First Handle Mark actions and moving messages
180                  $submit_mark    = (isset($_POST['submit_mark'])) ? true : false;
181                  $move_pm        = (isset($_POST['move_pm'])) ? true : false;
182                  $mark_option    = $request->variable('mark_option', '');
183                  $dest_folder    = $request->variable('dest_folder', PRIVMSGS_NO_BOX);
184   
185                  // Is moving PM triggered through mark options?
186                  if (!in_array($mark_option, array('mark_important', 'delete_marked')) && $submit_mark)
187                  {
188                      $move_pm = true;
189                      $dest_folder = (int) $mark_option;
190                      $submit_mark = false;
191                  }
192   
193                  // Move PM
194                  if ($move_pm)
195                  {
196                      $move_msg_ids    = (isset($_POST['marked_msg_id'])) ? $request->variable('marked_msg_id', array(0)) : array();
197                      $cur_folder_id    = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);
198   
199                      if (move_pm($user->data['user_id'], $user->data['message_limit'], $move_msg_ids, $dest_folder, $cur_folder_id))
200                      {
201                          // Return to folder view if single message moved
202                          if ($action == 'view_message')
203                          {
204                              $msg_id        = 0;
205                              $folder_id    = $request->variable('cur_folder_id', PRIVMSGS_NO_BOX);
206                              $action        = 'view_folder';
207                          }
208                      }
209                  }
210   
211                  // Message Mark Options
212                  if ($submit_mark)
213                  {
214                      handle_mark_actions($user->data['user_id'], $mark_option);
215                  }
216   
217                  // If new messages arrived, place them into the appropriate folder
218                  $num_not_moved = $num_removed = 0;
219                  $release = $request->variable('release', 0);
220   
221                  if ($user->data['user_new_privmsg'] && ($action == 'view_folder' || $action == 'view_message'))
222                  {
223                      $return = place_pm_into_folder($global_privmsgs_rules, $release);
224                      $num_not_moved = $return['not_moved'];
225                      $num_removed = $return['removed'];
226                  }
227   
228                  if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX)
229                  {
230                      $folder_id = PRIVMSGS_INBOX;
231                  }
232                  else if ($msg_id && $folder_id == PRIVMSGS_NO_BOX)
233                  {
234                      $sql = 'SELECT folder_id
235                          FROM ' . PRIVMSGS_TO_TABLE . "
236                          WHERE msg_id = $msg_id
237                              AND folder_id <> " . PRIVMSGS_NO_BOX . '
238                              AND user_id = ' . $user->data['user_id'];
239                      $result = $db->sql_query($sql);
240                      $row = $db->sql_fetchrow($result);
241                      $db->sql_freeresult($result);
242   
243                      if (!$row)
244                      {
245                          trigger_error('NO_MESSAGE');
246                      }
247                      $folder_id = (int) $row['folder_id'];
248                  }
249   
250                  if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_pms_read'))
251                  {
252                      mark_folder_read($user->data['user_id'], $folder_id);
253   
254                      meta_refresh(3, $this->u_action);
255                      $message = $user->lang['PM_MARK_ALL_READ_SUCCESS'];
256   
257                      if ($request->is_ajax())
258                      {
259                          $json_response = new \phpbb\json_response();
260                          $json_response->send(array(
261                              'MESSAGE_TITLE'    => $user->lang['INFORMATION'],
262                              'MESSAGE_TEXT'    => $message,
263                              'success'        => true,
264                          ));
265                      }
266                      $message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
267   
268                      trigger_error($message);
269                  }
270   
271                  $message_row = array();
272                  if ($action == 'view_message' && $msg_id)
273                  {
274                      // Get Message user want to see
275                      if ($view == 'next' || $view == 'previous')
276                      {
277                          $sql_condition = ($view == 'next') ? '>' : '<';
278                          $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
279   
280                          $sql = 'SELECT t.msg_id
281                              FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TABLE . " p2
282                              WHERE p2.msg_id = $msg_id
283                                  AND t.folder_id = $folder_id
284                                  AND t.user_id = " . $user->data['user_id'] . "
285                                  AND t.msg_id = p.msg_id
286                                  AND p.message_time $sql_condition p2.message_time
287                              ORDER BY p.message_time $sql_ordering";
288                          $result = $db->sql_query_limit($sql, 1);
289                          $row = $db->sql_fetchrow($result);
290                          $db->sql_freeresult($result);
291   
292                          if (!$row)
293                          {
294                              $message = ($view == 'next') ? 'NO_NEWER_PM' : 'NO_OLDER_PM';
295                              trigger_error($message);
296                          }
297                          else
298                          {
299                              $msg_id = $row['msg_id'];
300                          }
301                      }
302   
303                      $sql = 'SELECT t.*, p.*, u.*
304                          FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
305                          WHERE t.user_id = ' . $user->data['user_id'] . "
306                              AND p.author_id = u.user_id
307                              AND t.folder_id = $folder_id
308                              AND t.msg_id = p.msg_id
309                              AND p.msg_id = $msg_id";
310                      $result = $db->sql_query($sql);
311                      $message_row = $db->sql_fetchrow($result);
312                      $db->sql_freeresult($result);
313   
314                      if (!$message_row)
315                      {
316                          trigger_error('NO_MESSAGE');
317                      }
318   
319                      // Update unread status
320                      update_unread_status($message_row['pm_unread'], $message_row['msg_id'], $user->data['user_id'], $folder_id);
321                  }
322   
323                  $folder = get_folder($user->data['user_id'], $folder_id);
324   
325                  $s_folder_options = $s_to_folder_options = '';
326                  foreach ($folder as $f_id => $folder_ary)
327                  {
328                      $option = '<option' . ((!in_array($f_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX))) ? ' class="sep"' : '') . ' value="' . $f_id . '"' . (($f_id == $folder_id) ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . '</option>';
329   
330                      $s_to_folder_options .= ($f_id != PRIVMSGS_OUTBOX && $f_id != PRIVMSGS_SENTBOX) ? $option : '';
331                      $s_folder_options .= $option;
332                  }
333                  clean_sentbox($folder[PRIVMSGS_SENTBOX]['num_messages']);
334   
335                  // Header for message view - folder and so on
336                  $folder_status = get_folder_status($folder_id, $folder);
337   
338                  $template->assign_vars(array(
339                      'CUR_FOLDER_ID'            => $folder_id,
340                      'CUR_FOLDER_NAME'        => $folder_status['folder_name'],
341                      'NUM_NOT_MOVED'            => $num_not_moved,
342                      'NUM_REMOVED'            => $num_removed,
343                      'RELEASE_MESSAGE_INFO'    => sprintf($user->lang['RELEASE_MESSAGES'], '<a href="' . $this->u_action . '&amp;folder=' . $folder_id . '&amp;release=1">', '</a>'),
344                      'NOT_MOVED_MESSAGES'    => $user->lang('NOT_MOVED_MESSAGES', (int) $num_not_moved),
345                      'RULE_REMOVED_MESSAGES'    => $user->lang('RULE_REMOVED_MESSAGES', (int) $num_removed),
346   
347                      'S_FOLDER_OPTIONS'        => $s_folder_options,
348                      'S_TO_FOLDER_OPTIONS'    => $s_to_folder_options,
349                      'S_FOLDER_ACTION'        => $this->u_action . '&amp;action=view_folder',
350                      'S_PM_ACTION'            => $this->u_action . '&amp;action=' . $action,
351   
352                      'U_INBOX'                => $this->u_action . '&amp;folder=inbox',
353                      'U_OUTBOX'                => $this->u_action . '&amp;folder=outbox',
354                      'U_SENTBOX'                => $this->u_action . '&amp;folder=sentbox',
355                      'U_CREATE_FOLDER'        => $this->u_action . '&amp;mode=options',
356                      'U_CURRENT_FOLDER'        => $this->u_action . '&amp;folder=' . $folder_id,
357                      'U_MARK_ALL'            => $this->u_action . '&amp;folder=' . $folder_id . '&amp;mark=all&amp;token=' . generate_link_hash('mark_all_pms_read'),
358   
359                      'S_IN_INBOX'            => ($folder_id == PRIVMSGS_INBOX) ? true : false,
360                      'S_IN_OUTBOX'            => ($folder_id == PRIVMSGS_OUTBOX) ? true : false,
361                      'S_IN_SENTBOX'            => ($folder_id == PRIVMSGS_SENTBOX) ? true : false,
362   
363                      'FOLDER_STATUS'                => $folder_status['message'],
364                      'FOLDER_MAX_MESSAGES'        => $folder_status['max'],
365                      'FOLDER_CUR_MESSAGES'        => $folder_status['cur'],
366                      'FOLDER_REMAINING_MESSAGES'    => $folder_status['remaining'],
367                      'FOLDER_PERCENT'            => $folder_status['percent'])
368                  );
369   
370                  if ($action == 'view_folder')
371                  {
372                      include($phpbb_root_path . 'includes/ucp/ucp_pm_viewfolder.' . $phpEx);
373                      view_folder($id, $mode, $folder_id, $folder);
374   
375                      $tpl_file = 'ucp_pm_viewfolder';
376                  }
377                  else if ($action == 'view_message')
378                  {
379                      $template->assign_vars(array(
380                          'S_VIEW_MESSAGE'        => true,
381                          'L_RETURN_TO_FOLDER'    => $user->lang('RETURN_TO', $folder_status['folder_name']),
382                          'MSG_ID'                => $msg_id,
383                      ));
384   
385                      if (!$msg_id)
386                      {
387                          trigger_error('NO_MESSAGE');
388                      }
389   
390                      include($phpbb_root_path . 'includes/ucp/ucp_pm_viewmessage.' . $phpEx);
391                      view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row);
392   
393                      $tpl_file = ($view == 'print') ? 'ucp_pm_viewmessage_print' : 'ucp_pm_viewmessage';
394                  }
395   
396              break;
397   
398              default:
399                  trigger_error('NO_ACTION_MODE', E_USER_ERROR);
400              break;
401          }
402   
403          $template->assign_vars(array(
404              'L_TITLE'            => $user->lang['UCP_PM_' . strtoupper($mode)],
405              'S_UCP_ACTION'        => $this->u_action . ((isset($action)) ? "&amp;action=$action" : ''))
406          );
407   
408          // Set desired template
409          $this->tpl_name = $tpl_file;
410          $this->page_title = 'UCP_PM_' . strtoupper($mode);
411      }
412  }
413