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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
mcp_forum.php
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 * MCP Forum View
024 */
025 function mcp_forum_view($id, $mode, $action, $forum_info)
026 {
027 global $template, $db, $user, $auth, $cache, $module;
028 global $phpEx, $phpbb_root_path, $config;
029 global $request, $phpbb_dispatcher, $phpbb_container;
030
031 $user->add_lang(array('viewtopic', 'viewforum'));
032
033 include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
034
035 // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
036 $merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
037
038 if ($merge_select)
039 {
040 // Fixes a "bug" that makes forum_view use the same ordering as topic_view
041 $request->overwrite('sk', null);
042 $request->overwrite('sd', null);
043 $request->overwrite('sk', null, \phpbb\request\request_interface::POST);
044 $request->overwrite('sd', null, \phpbb\request\request_interface::POST);
045 }
046
047 $forum_id = $forum_info['forum_id'];
048 $start = request_var('start', 0);
049 $topic_id_list = request_var('topic_id_list', array(0));
050 $post_id_list = request_var('post_id_list', array(0));
051 $source_topic_ids = array(request_var('t', 0));
052 $to_topic_id = request_var('to_topic_id', 0);
053
054 $url_extra = '';
055 $url_extra .= ($forum_id) ? "&f=$forum_id" : '';
056 $url_extra .= ($GLOBALS['topic_id']) ? '&t=' . $GLOBALS['topic_id'] : '';
057 $url_extra .= ($GLOBALS['post_id']) ? '&p=' . $GLOBALS['post_id'] : '';
058 $url_extra .= ($GLOBALS['user_id']) ? '&u=' . $GLOBALS['user_id'] : '';
059
060 $url = append_sid("{$phpbb_root_path}mcp.$phpEx?$url_extra");
061
062 // Resync Topics
063 switch ($action)
064 {
065 case 'resync':
066 $topic_ids = request_var('topic_id_list', array(0));
067 mcp_resync_topics($topic_ids);
068 break;
069
070 case 'merge_topics':
071 $source_topic_ids = $topic_id_list;
072 case 'merge_topic':
073 if ($to_topic_id)
074 {
075 merge_topics($forum_id, $source_topic_ids, $to_topic_id);
076 }
077 break;
078 }
079
080 $pagination = $phpbb_container->get('pagination');
081
082 $selected_ids = '';
083 if (sizeof($post_id_list) && $action != 'merge_topics')
084 {
085 foreach ($post_id_list as $num => $post_id)
086 {
087 $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id;
088 }
089 }
090 else if (sizeof($topic_id_list) && $action == 'merge_topics')
091 {
092 foreach ($topic_id_list as $num => $topic_id)
093 {
094 $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id;
095 }
096 }
097
098 make_jumpbox($url . "&i=$id&action=$action&mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
099
100 $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
101
102 $sort_days = $total = 0;
103 $sort_key = $sort_dir = '';
104 $sort_by_sql = $sort_order_sql = array();
105 phpbb_mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
106
107 $forum_topics = ($total == -1) ? $forum_info['forum_topics_approved'] : $total;
108 $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
109
110 $base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : '');
111 $pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);
112
113 $template->assign_vars(array(
114 'ACTION' => $action,
115 'FORUM_NAME' => $forum_info['forum_name'],
116 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']),
117
118 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
119 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
120 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
121 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
122
123 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id),
124 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id),
125 'S_CAN_RESTORE' => $auth->acl_get('m_approve', $forum_id),
126 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id),
127 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id),
128 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id),
129 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id),
130 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id),
131 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
132 'S_MERGE_SELECT' => ($merge_select) ? true : false,
133 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', $forum_id),
134 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id),
135 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),
136
137 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
138 'U_VIEW_FORUM_LOGS' => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=forum_logs&f=' . $forum_id) : '',
139
140 'S_MCP_ACTION' => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''),
141
142 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),
143 ));
144
145 // Grab icons
146 $icons = $cache->obtain_icons();
147
148 $topic_rows = array();
149
150 if ($config['load_db_lastread'])
151 {
152 $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
153 $read_tracking_select = ', tt.mark_time';
154 }
155 else
156 {
157 $read_tracking_join = $read_tracking_select = '';
158 }
159
160 $phpbb_content_visibility = $phpbb_container->get('content.visibility');
161
162 $sql = 'SELECT t.topic_id
163 FROM ' . TOPICS_TABLE . ' t
164 WHERE t.forum_id = ' . $forum_id . '
165 AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "
166 $limit_time_sql
167 ORDER BY t.topic_type DESC, $sort_order_sql";
168 $result = $db->sql_query_limit($sql, $topics_per_page, $start);
169
170 $topic_list = $topic_tracking_info = array();
171
172 while ($row = $db->sql_fetchrow($result))
173 {
174 $topic_list[] = $row['topic_id'];
175 }
176 $db->sql_freeresult($result);
177
178 $sql = "SELECT t.*$read_tracking_select
179 FROM " . TOPICS_TABLE . " t $read_tracking_join
180 WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
181
182 $result = $db->sql_query($sql);
183 while ($row = $db->sql_fetchrow($result))
184 {
185 $topic_rows[$row['topic_id']] = $row;
186 }
187 $db->sql_freeresult($result);
188
189 // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
190 if (!sizeof($topic_list) && $forum_topics && $start > 0)
191 {
192 redirect($url . "&i=$id&action=$action&mode=$mode");
193 }
194
195 // Get topic tracking info
196 if (sizeof($topic_list))
197 {
198 if ($config['load_db_lastread'])
199 {
200 $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']));
201 }
202 else
203 {
204 $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list);
205 }
206 }
207
208 foreach ($topic_list as $topic_id)
209 {
210 $topic_title = '';
211
212 $row = &$topic_rows[$topic_id];
213
214 $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1;
215
216 if ($row['topic_status'] == ITEM_MOVED)
217 {
218 $unread_topic = false;
219 }
220 else
221 {
222 $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
223 }
224
225 // Get folder img, topic status/type related information
226 $folder_img = $folder_alt = $topic_type = '';
227 topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
228
229 $topic_title = censor_text($row['topic_title']);
230
231 $topic_unapproved = (($row['topic_visibility'] == ITEM_UNAPPROVED || $row['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
232 $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
233 $topic_deleted = $row['topic_visibility'] == ITEM_DELETED;
234 $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : '';
235 $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue;
236
237 $topic_row = array(
238 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
239 'TOPIC_IMG_STYLE' => $folder_img,
240 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
241 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
242 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
243 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
244 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
245 'DELETED_IMG' => ($topic_deleted) ? $user->img('icon_topic_deleted', 'POSTS_DELETED') : '',
246
247 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
248 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
249 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
250 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
251
252 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
253 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
254 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
255 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
256
257 'TOPIC_TYPE' => $topic_type,
258 'TOPIC_TITLE' => $topic_title,
259 'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1,
260 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
261 'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
262 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
263 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
264
265 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
266 'S_TOPIC_UNAPPROVED' => $topic_unapproved,
267 'S_POSTS_UNAPPROVED' => $posts_unapproved,
268 'S_TOPIC_DELETED' => $topic_deleted,
269 'S_UNREAD_TOPIC' => $unread_topic,
270 );
271
272 if ($row['topic_status'] == ITEM_MOVED)
273 {
274 $topic_row = array_merge($topic_row, array(
275 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_moved_id']}"),
276 'U_DELETE_TOPIC' => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&topic_id_list[]={$row['topic_id']}&mode=forum_view&action=delete_topic") : '',
277 'S_MOVED_TOPIC' => true,
278 'TOPIC_ID' => $row['topic_moved_id'],
279 ));
280 }
281 else
282 {
283 if ($action == 'merge_topic' || $action == 'merge_topics')
284 {
285 $u_select_topic = $url . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row['topic_id'] . $selected_ids;
286 }
287 else
288 {
289 $u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids;
290 }
291 $topic_row = array_merge($topic_row, array(
292 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row['topic_id']}&mode=topic_view"),
293
294 'S_SELECT_TOPIC' => ($merge_select && !in_array($row['topic_id'], $source_topic_ids)) ? true : false,
295 'U_SELECT_TOPIC' => $u_select_topic,
296 'U_MCP_QUEUE' => $u_mcp_queue,
297 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&t=' . $row['topic_id'] . '&action=reports') : '',
298 'TOPIC_ID' => $row['topic_id'],
299 'S_TOPIC_CHECKED' => ($topic_id_list && in_array($row['topic_id'], $topic_id_list)) ? true : false,
300 ));
301 }
302
303 /**
304 * Modify the topic data before it is assigned to the template in MCP
305 *
306 * @event core.mcp_view_forum_modify_topicrow
307 * @var array row Array with topic data
308 * @var array topic_row Template array with topic data
309 * @since 3.1.0-a1
310 */
311 $vars = array('row', 'topic_row');
312 extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));
313
314 $template->assign_block_vars('topicrow', $topic_row);
315 }
316 unset($topic_rows);
317 }
318
319 /**
320 * Resync topics
321 */
322 function mcp_resync_topics($topic_ids)
323 {
324 global $auth, $db, $template, $phpEx, $user, $phpbb_root_path;
325
326 if (!sizeof($topic_ids))
327 {
328 trigger_error('NO_TOPIC_SELECTED');
329 }
330
331 if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
332 {
333 return;
334 }
335
336 // Sync everything and perform extra checks separately
337 sync('topic_reported', 'topic_id', $topic_ids, false, true);
338 sync('topic_attachment', 'topic_id', $topic_ids, false, true);
339 sync('topic', 'topic_id', $topic_ids, true, false);
340
341 $sql = 'SELECT topic_id, forum_id, topic_title
342 FROM ' . TOPICS_TABLE . '
343 WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
344 $result = $db->sql_query($sql);
345
346 // Log this action
347 while ($row = $db->sql_fetchrow($result))
348 {
349 add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);
350 }
351 $db->sql_freeresult($result);
352
353 $msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
354
355 $redirect = request_var('redirect', $user->data['session_page']);
356
357 meta_refresh(3, $redirect);
358 trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
359
360 return;
361 }
362
363 /**
364 * Merge selected topics into selected topic
365 */
366 function merge_topics($forum_id, $topic_ids, $to_topic_id)
367 {
368 global $db, $template, $user, $phpEx, $phpbb_root_path, $auth;
369
370 if (!sizeof($topic_ids))
371 {
372 $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
373 return;
374 }
375 if (!$to_topic_id)
376 {
377 $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
378 return;
379 }
380
381 $sync_topics = array_merge($topic_ids, array($to_topic_id));
382
383 $topic_data = phpbb_get_topic_data($sync_topics, 'm_merge');
384
385 if (!sizeof($topic_data) || empty($topic_data[$to_topic_id]))
386 {
387 $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
388 return;
389 }
390
391 $sync_forums = array();
392 foreach ($topic_data as $data)
393 {
394 $sync_forums[$data['forum_id']] = $data['forum_id'];
395 }
396
397 $topic_data = $topic_data[$to_topic_id];
398
399 $post_id_list = request_var('post_id_list', array(0));
400 $start = request_var('start', 0);
401
402 if (!sizeof($post_id_list) && sizeof($topic_ids))
403 {
404 $sql = 'SELECT post_id
405 FROM ' . POSTS_TABLE . '
406 WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
407 $result = $db->sql_query($sql);
408
409 $post_id_list = array();
410 while ($row = $db->sql_fetchrow($result))
411 {
412 $post_id_list[] = $row['post_id'];
413 }
414 $db->sql_freeresult($result);
415 }
416
417 if (!sizeof($post_id_list))
418 {
419 $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
420 return;
421 }
422
423 if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
424 {
425 return;
426 }
427
428 $redirect = request_var('redirect', build_url(array('quickmod')));
429
430 $s_hidden_fields = build_hidden_fields(array(
431 'i' => 'main',
432 'f' => $forum_id,
433 'post_id_list' => $post_id_list,
434 'to_topic_id' => $to_topic_id,
435 'mode' => 'forum_view',
436 'action' => 'merge_topics',
437 'start' => $start,
438 'redirect' => $redirect,
439 'topic_id_list' => $topic_ids)
440 );
441 $success_msg = $return_link = '';
442
443 if (confirm_box(true))
444 {
445 $to_forum_id = $topic_data['forum_id'];
446
447 move_posts($post_id_list, $to_topic_id, false);
448 add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);
449
450 // Message and return links
451 $success_msg = 'POSTS_MERGED_SUCCESS';
452
453 if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
454 {
455 include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
456 }
457
458 // Update the topic watch table.
459 phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
460
461 // Update the bookmarks table.
462 phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_ids, $to_topic_id);
463
464 // Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts()
465 sync('topic_reported', 'topic_id', $sync_topics);
466 sync('topic_attachment', 'topic_id', $sync_topics);
467 sync('topic', 'topic_id', $sync_topics, true);
468 sync('forum', 'forum_id', $sync_forums, true, true);
469
470 // Link to the new topic
471 $return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
472 $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id");
473 $redirect = reapply_sid($redirect);
474
475 meta_refresh(3, $redirect);
476 trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
477 }
478 else
479 {
480 confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);
481 }
482 }
483