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