|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package mcp
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
if (!defined('IN_PHPBB'))
|
|
indvdum@0
|
15 |
{
|
|
indvdum@0
|
16 |
exit;
|
|
indvdum@0
|
17 |
}
|
|
indvdum@0
|
18 |
|
|
indvdum@0
|
19 |
/**
|
|
indvdum@0
|
20 |
* MCP Forum View
|
|
indvdum@0
|
21 |
*/
|
|
indvdum@0
|
22 |
function mcp_forum_view($id, $mode, $action, $forum_info)
|
|
indvdum@0
|
23 |
{
|
|
indvdum@0
|
24 |
global $template, $db, $user, $auth, $cache, $module;
|
|
indvdum@0
|
25 |
global $phpEx, $phpbb_root_path, $config;
|
|
indvdum@0
|
26 |
|
|
indvdum@0
|
27 |
$user->add_lang(array('viewtopic', 'viewforum'));
|
|
indvdum@0
|
28 |
|
|
indvdum@0
|
29 |
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
indvdum@0
|
30 |
|
|
indvdum@0
|
31 |
// merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
|
|
indvdum@0
|
32 |
$merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
|
|
indvdum@0
|
33 |
|
|
indvdum@0
|
34 |
if ($merge_select)
|
|
indvdum@0
|
35 |
{
|
|
indvdum@0
|
36 |
// Fixes a "bug" that makes forum_view use the same ordering as topic_view
|
|
indvdum@0
|
37 |
unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']);
|
|
indvdum@0
|
38 |
}
|
|
indvdum@0
|
39 |
|
|
indvdum@0
|
40 |
$forum_id = $forum_info['forum_id'];
|
|
indvdum@0
|
41 |
$start = request_var('start', 0);
|
|
indvdum@0
|
42 |
$topic_id_list = request_var('topic_id_list', array(0));
|
|
indvdum@0
|
43 |
$post_id_list = request_var('post_id_list', array(0));
|
|
indvdum@0
|
44 |
$source_topic_ids = array(request_var('t', 0));
|
|
indvdum@0
|
45 |
$to_topic_id = request_var('to_topic_id', 0);
|
|
indvdum@0
|
46 |
|
|
indvdum@0
|
47 |
$url_extra = '';
|
|
indvdum@0
|
48 |
$url_extra .= ($forum_id) ? "&f=$forum_id" : '';
|
|
indvdum@0
|
49 |
$url_extra .= ($GLOBALS['topic_id']) ? '&t=' . $GLOBALS['topic_id'] : '';
|
|
indvdum@0
|
50 |
$url_extra .= ($GLOBALS['post_id']) ? '&p=' . $GLOBALS['post_id'] : '';
|
|
indvdum@0
|
51 |
$url_extra .= ($GLOBALS['user_id']) ? '&u=' . $GLOBALS['user_id'] : '';
|
|
indvdum@0
|
52 |
|
|
indvdum@0
|
53 |
$url = append_sid("{$phpbb_root_path}mcp.$phpEx?$url_extra");
|
|
indvdum@0
|
54 |
|
|
indvdum@0
|
55 |
// Resync Topics
|
|
indvdum@0
|
56 |
switch ($action)
|
|
indvdum@0
|
57 |
{
|
|
indvdum@0
|
58 |
case 'resync':
|
|
indvdum@0
|
59 |
$topic_ids = request_var('topic_id_list', array(0));
|
|
indvdum@0
|
60 |
mcp_resync_topics($topic_ids);
|
|
indvdum@0
|
61 |
break;
|
|
indvdum@0
|
62 |
|
|
indvdum@0
|
63 |
case 'merge_topics':
|
|
indvdum@0
|
64 |
$source_topic_ids = $topic_id_list;
|
|
indvdum@0
|
65 |
case 'merge_topic':
|
|
indvdum@0
|
66 |
if ($to_topic_id)
|
|
indvdum@0
|
67 |
{
|
|
indvdum@0
|
68 |
merge_topics($forum_id, $source_topic_ids, $to_topic_id);
|
|
indvdum@0
|
69 |
}
|
|
indvdum@0
|
70 |
break;
|
|
indvdum@0
|
71 |
}
|
|
indvdum@0
|
72 |
|
|
indvdum@0
|
73 |
$selected_ids = '';
|
|
indvdum@0
|
74 |
if (sizeof($post_id_list) && $action != 'merge_topics')
|
|
indvdum@0
|
75 |
{
|
|
indvdum@0
|
76 |
foreach ($post_id_list as $num => $post_id)
|
|
indvdum@0
|
77 |
{
|
|
indvdum@0
|
78 |
$selected_ids .= '&post_id_list[' . $num . ']=' . $post_id;
|
|
indvdum@0
|
79 |
}
|
|
indvdum@0
|
80 |
}
|
|
indvdum@0
|
81 |
else if (sizeof($topic_id_list) && $action == 'merge_topics')
|
|
indvdum@0
|
82 |
{
|
|
indvdum@0
|
83 |
foreach ($topic_id_list as $num => $topic_id)
|
|
indvdum@0
|
84 |
{
|
|
indvdum@0
|
85 |
$selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id;
|
|
indvdum@0
|
86 |
}
|
|
indvdum@0
|
87 |
}
|
|
indvdum@0
|
88 |
|
|
indvdum@0
|
89 |
make_jumpbox($url . "&i=$id&action=$action&mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
|
|
indvdum@0
|
90 |
|
|
indvdum@0
|
91 |
$topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
|
|
indvdum@0
|
92 |
|
|
indvdum@0
|
93 |
$sort_days = $total = 0;
|
|
indvdum@0
|
94 |
$sort_key = $sort_dir = '';
|
|
indvdum@0
|
95 |
$sort_by_sql = $sort_order_sql = array();
|
|
indvdum@0
|
96 |
mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
|
|
indvdum@0
|
97 |
|
|
indvdum@0
|
98 |
$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
|
|
indvdum@0
|
99 |
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
|
indvdum@0
|
100 |
|
|
indvdum@0
|
101 |
$template->assign_vars(array(
|
|
indvdum@0
|
102 |
'ACTION' => $action,
|
|
indvdum@0
|
103 |
'FORUM_NAME' => $forum_info['forum_name'],
|
|
indvdum@0
|
104 |
'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']),
|
|
indvdum@0
|
105 |
|
|
indvdum@0
|
106 |
'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
|
|
indvdum@0
|
107 |
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
|
|
indvdum@0
|
108 |
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
|
|
indvdum@0
|
109 |
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
|
indvdum@0
|
110 |
|
|
indvdum@0
|
111 |
'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id),
|
|
indvdum@0
|
112 |
'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id),
|
|
indvdum@0
|
113 |
'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id),
|
|
indvdum@0
|
114 |
'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id),
|
|
indvdum@0
|
115 |
'S_CAN_FORK' => $auth->acl_get('m_', $forum_id),
|
|
indvdum@0
|
116 |
'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id),
|
|
indvdum@0
|
117 |
'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id),
|
|
indvdum@0
|
118 |
'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id),
|
|
indvdum@0
|
119 |
'S_MERGE_SELECT' => ($merge_select) ? true : false,
|
|
indvdum@0
|
120 |
'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', $forum_id),
|
|
indvdum@0
|
121 |
'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id),
|
|
indvdum@0
|
122 |
'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id),
|
|
indvdum@0
|
123 |
|
|
indvdum@0
|
124 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
|
|
indvdum@0
|
125 |
'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) : '',
|
|
indvdum@0
|
126 |
|
|
indvdum@0
|
127 |
'S_MCP_ACTION' => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''),
|
|
indvdum@0
|
128 |
|
|
indvdum@0
|
129 |
'PAGINATION' => generate_pagination($url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start),
|
|
indvdum@0
|
130 |
'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start),
|
|
indvdum@0
|
131 |
'TOTAL_TOPICS' => ($forum_topics == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics),
|
|
indvdum@0
|
132 |
));
|
|
indvdum@0
|
133 |
|
|
indvdum@0
|
134 |
// Grab icons
|
|
indvdum@0
|
135 |
$icons = $cache->obtain_icons();
|
|
indvdum@0
|
136 |
|
|
indvdum@0
|
137 |
$topic_rows = array();
|
|
indvdum@0
|
138 |
|
|
indvdum@0
|
139 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
140 |
{
|
|
indvdum@0
|
141 |
$read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
|
|
indvdum@0
|
142 |
$read_tracking_select = ', tt.mark_time';
|
|
indvdum@0
|
143 |
}
|
|
indvdum@0
|
144 |
else
|
|
indvdum@0
|
145 |
{
|
|
indvdum@0
|
146 |
$read_tracking_join = $read_tracking_select = '';
|
|
indvdum@0
|
147 |
}
|
|
indvdum@0
|
148 |
|
|
indvdum@0
|
149 |
$sql = "SELECT t.topic_id
|
|
indvdum@0
|
150 |
FROM " . TOPICS_TABLE . " t
|
|
indvdum@0
|
151 |
WHERE t.forum_id IN($forum_id, 0)
|
|
indvdum@0
|
152 |
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
|
|
indvdum@0
|
153 |
$limit_time_sql
|
|
indvdum@0
|
154 |
ORDER BY t.topic_type DESC, $sort_order_sql";
|
|
indvdum@0
|
155 |
$result = $db->sql_query_limit($sql, $topics_per_page, $start);
|
|
indvdum@0
|
156 |
|
|
indvdum@0
|
157 |
$topic_list = $topic_tracking_info = array();
|
|
indvdum@0
|
158 |
|
|
indvdum@0
|
159 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
160 |
{
|
|
indvdum@0
|
161 |
$topic_list[] = $row['topic_id'];
|
|
indvdum@0
|
162 |
}
|
|
indvdum@0
|
163 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
164 |
|
|
indvdum@0
|
165 |
$sql = "SELECT t.*$read_tracking_select
|
|
indvdum@0
|
166 |
FROM " . TOPICS_TABLE . " t $read_tracking_join
|
|
indvdum@0
|
167 |
WHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true);
|
|
indvdum@0
|
168 |
|
|
indvdum@0
|
169 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
170 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
171 |
{
|
|
indvdum@0
|
172 |
$topic_rows[$row['topic_id']] = $row;
|
|
indvdum@0
|
173 |
}
|
|
indvdum@0
|
174 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
175 |
|
|
indvdum@0
|
176 |
// If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
|
|
indvdum@0
|
177 |
if (!sizeof($topic_list) && $forum_topics && $start > 0)
|
|
indvdum@0
|
178 |
{
|
|
indvdum@0
|
179 |
redirect($url . "&i=$id&action=$action&mode=$mode");
|
|
indvdum@0
|
180 |
}
|
|
indvdum@0
|
181 |
|
|
indvdum@0
|
182 |
// Get topic tracking info
|
|
indvdum@0
|
183 |
if (sizeof($topic_list))
|
|
indvdum@0
|
184 |
{
|
|
indvdum@0
|
185 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
186 |
{
|
|
indvdum@0
|
187 |
$topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array());
|
|
indvdum@0
|
188 |
}
|
|
indvdum@0
|
189 |
else
|
|
indvdum@0
|
190 |
{
|
|
indvdum@0
|
191 |
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
|
|
indvdum@0
|
192 |
}
|
|
indvdum@0
|
193 |
}
|
|
indvdum@0
|
194 |
|
|
indvdum@0
|
195 |
foreach ($topic_list as $topic_id)
|
|
indvdum@0
|
196 |
{
|
|
indvdum@0
|
197 |
$topic_title = '';
|
|
indvdum@0
|
198 |
|
|
indvdum@0
|
199 |
$row = &$topic_rows[$topic_id];
|
|
indvdum@0
|
200 |
|
|
indvdum@0
|
201 |
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
|
indvdum@0
|
202 |
|
|
indvdum@0
|
203 |
if ($row['topic_status'] == ITEM_MOVED)
|
|
indvdum@0
|
204 |
{
|
|
indvdum@0
|
205 |
$unread_topic = false;
|
|
indvdum@0
|
206 |
}
|
|
indvdum@0
|
207 |
else
|
|
indvdum@0
|
208 |
{
|
|
indvdum@0
|
209 |
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
|
indvdum@0
|
210 |
}
|
|
indvdum@0
|
211 |
|
|
indvdum@0
|
212 |
// Get folder img, topic status/type related information
|
|
indvdum@0
|
213 |
$folder_img = $folder_alt = $topic_type = '';
|
|
indvdum@0
|
214 |
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
|
|
indvdum@0
|
215 |
|
|
indvdum@0
|
216 |
$topic_title = censor_text($row['topic_title']);
|
|
indvdum@0
|
217 |
|
|
indvdum@0
|
218 |
$topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
|
|
indvdum@0
|
219 |
$posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
|
|
indvdum@0
|
220 |
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : '';
|
|
indvdum@0
|
221 |
|
|
indvdum@0
|
222 |
$topic_row = array(
|
|
indvdum@0
|
223 |
'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']) : '',
|
|
indvdum@0
|
224 |
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
|
indvdum@0
|
225 |
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
|
|
indvdum@0
|
226 |
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
|
|
indvdum@0
|
227 |
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
|
|
indvdum@0
|
228 |
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
|
|
indvdum@0
|
229 |
'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
|
|
indvdum@0
|
230 |
|
|
indvdum@0
|
231 |
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
232 |
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
233 |
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
234 |
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
235 |
|
|
indvdum@0
|
236 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
237 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
238 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
239 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
240 |
|
|
indvdum@0
|
241 |
'TOPIC_TYPE' => $topic_type,
|
|
indvdum@0
|
242 |
'TOPIC_TITLE' => $topic_title,
|
|
indvdum@0
|
243 |
'REPLIES' => ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'],
|
|
indvdum@0
|
244 |
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
|
indvdum@0
|
245 |
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
|
indvdum@0
|
246 |
'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
|
|
indvdum@0
|
247 |
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
|
indvdum@0
|
248 |
|
|
indvdum@0
|
249 |
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
|
|
indvdum@0
|
250 |
'S_TOPIC_UNAPPROVED' => $topic_unapproved,
|
|
indvdum@0
|
251 |
'S_POSTS_UNAPPROVED' => $posts_unapproved,
|
|
indvdum@0
|
252 |
'S_UNREAD_TOPIC' => $unread_topic,
|
|
indvdum@0
|
253 |
);
|
|
indvdum@0
|
254 |
|
|
indvdum@0
|
255 |
if ($row['topic_status'] == ITEM_MOVED)
|
|
indvdum@0
|
256 |
{
|
|
indvdum@0
|
257 |
$topic_row = array_merge($topic_row, array(
|
|
indvdum@0
|
258 |
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_moved_id']}"),
|
|
indvdum@0
|
259 |
'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") : '',
|
|
indvdum@0
|
260 |
'S_MOVED_TOPIC' => true,
|
|
indvdum@0
|
261 |
'TOPIC_ID' => $row['topic_moved_id'],
|
|
indvdum@0
|
262 |
));
|
|
indvdum@0
|
263 |
}
|
|
indvdum@0
|
264 |
else
|
|
indvdum@0
|
265 |
{
|
|
indvdum@0
|
266 |
if ($action == 'merge_topic' || $action == 'merge_topics')
|
|
indvdum@0
|
267 |
{
|
|
indvdum@0
|
268 |
$u_select_topic = $url . "&i=$id&mode=forum_view&action=$action&to_topic_id=" . $row['topic_id'] . $selected_ids;
|
|
indvdum@0
|
269 |
}
|
|
indvdum@0
|
270 |
else
|
|
indvdum@0
|
271 |
{
|
|
indvdum@0
|
272 |
$u_select_topic = $url . "&i=$id&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids;
|
|
indvdum@0
|
273 |
}
|
|
indvdum@0
|
274 |
$topic_row = array_merge($topic_row, array(
|
|
indvdum@0
|
275 |
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row['topic_id']}&mode=topic_view"),
|
|
indvdum@0
|
276 |
|
|
indvdum@0
|
277 |
'S_SELECT_TOPIC' => ($merge_select && !in_array($row['topic_id'], $source_topic_ids)) ? true : false,
|
|
indvdum@0
|
278 |
'U_SELECT_TOPIC' => $u_select_topic,
|
|
indvdum@0
|
279 |
'U_MCP_QUEUE' => $u_mcp_queue,
|
|
indvdum@0
|
280 |
'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') : '',
|
|
indvdum@0
|
281 |
'TOPIC_ID' => $row['topic_id'],
|
|
indvdum@0
|
282 |
'S_TOPIC_CHECKED' => ($topic_id_list && in_array($row['topic_id'], $topic_id_list)) ? true : false,
|
|
indvdum@0
|
283 |
));
|
|
indvdum@0
|
284 |
}
|
|
indvdum@0
|
285 |
|
|
indvdum@0
|
286 |
$template->assign_block_vars('topicrow', $topic_row);
|
|
indvdum@0
|
287 |
}
|
|
indvdum@0
|
288 |
unset($topic_rows);
|
|
indvdum@0
|
289 |
}
|
|
indvdum@0
|
290 |
|
|
indvdum@0
|
291 |
/**
|
|
indvdum@0
|
292 |
* Resync topics
|
|
indvdum@0
|
293 |
*/
|
|
indvdum@0
|
294 |
function mcp_resync_topics($topic_ids)
|
|
indvdum@0
|
295 |
{
|
|
indvdum@0
|
296 |
global $auth, $db, $template, $phpEx, $user, $phpbb_root_path;
|
|
indvdum@0
|
297 |
|
|
indvdum@0
|
298 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
299 |
{
|
|
indvdum@0
|
300 |
trigger_error('NO_TOPIC_SELECTED');
|
|
indvdum@0
|
301 |
}
|
|
indvdum@0
|
302 |
|
|
indvdum@0
|
303 |
if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
|
|
indvdum@0
|
304 |
{
|
|
indvdum@0
|
305 |
return;
|
|
indvdum@0
|
306 |
}
|
|
indvdum@0
|
307 |
|
|
indvdum@0
|
308 |
// Sync everything and perform extra checks separately
|
|
indvdum@0
|
309 |
sync('topic_reported', 'topic_id', $topic_ids, false, true);
|
|
indvdum@0
|
310 |
sync('topic_attachment', 'topic_id', $topic_ids, false, true);
|
|
indvdum@0
|
311 |
sync('topic', 'topic_id', $topic_ids, true, false);
|
|
indvdum@0
|
312 |
|
|
indvdum@0
|
313 |
$sql = 'SELECT topic_id, forum_id, topic_title
|
|
indvdum@0
|
314 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
315 |
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
|
indvdum@0
|
316 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
317 |
|
|
indvdum@0
|
318 |
// Log this action
|
|
indvdum@0
|
319 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
320 |
{
|
|
indvdum@0
|
321 |
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);
|
|
indvdum@0
|
322 |
}
|
|
indvdum@0
|
323 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
324 |
|
|
indvdum@0
|
325 |
$msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
|
|
indvdum@0
|
326 |
|
|
indvdum@0
|
327 |
$redirect = request_var('redirect', $user->data['session_page']);
|
|
indvdum@0
|
328 |
|
|
indvdum@0
|
329 |
meta_refresh(3, $redirect);
|
|
indvdum@0
|
330 |
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
|
indvdum@0
|
331 |
|
|
indvdum@0
|
332 |
return;
|
|
indvdum@0
|
333 |
}
|
|
indvdum@0
|
334 |
|
|
indvdum@0
|
335 |
/**
|
|
indvdum@0
|
336 |
* Merge selected topics into selected topic
|
|
indvdum@0
|
337 |
*/
|
|
indvdum@0
|
338 |
function merge_topics($forum_id, $topic_ids, $to_topic_id)
|
|
indvdum@0
|
339 |
{
|
|
indvdum@0
|
340 |
global $db, $template, $user, $phpEx, $phpbb_root_path, $auth;
|
|
indvdum@0
|
341 |
|
|
indvdum@0
|
342 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
343 |
{
|
|
indvdum@0
|
344 |
$template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
|
|
indvdum@0
|
345 |
return;
|
|
indvdum@0
|
346 |
}
|
|
indvdum@0
|
347 |
if (!$to_topic_id)
|
|
indvdum@0
|
348 |
{
|
|
indvdum@0
|
349 |
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
|
|
indvdum@0
|
350 |
return;
|
|
indvdum@0
|
351 |
}
|
|
indvdum@0
|
352 |
|
|
indvdum@0
|
353 |
$topic_data = get_topic_data(array($to_topic_id), 'm_merge');
|
|
indvdum@0
|
354 |
|
|
indvdum@0
|
355 |
if (!sizeof($topic_data))
|
|
indvdum@0
|
356 |
{
|
|
indvdum@0
|
357 |
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
|
|
indvdum@0
|
358 |
return;
|
|
indvdum@0
|
359 |
}
|
|
indvdum@0
|
360 |
|
|
indvdum@0
|
361 |
$topic_data = $topic_data[$to_topic_id];
|
|
indvdum@0
|
362 |
|
|
indvdum@0
|
363 |
$post_id_list = request_var('post_id_list', array(0));
|
|
indvdum@0
|
364 |
$start = request_var('start', 0);
|
|
indvdum@0
|
365 |
|
|
indvdum@0
|
366 |
if (!sizeof($post_id_list) && sizeof($topic_ids))
|
|
indvdum@0
|
367 |
{
|
|
indvdum@0
|
368 |
$sql = 'SELECT post_id
|
|
indvdum@0
|
369 |
FROM ' . POSTS_TABLE . '
|
|
indvdum@0
|
370 |
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
|
indvdum@0
|
371 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
372 |
|
|
indvdum@0
|
373 |
$post_id_list = array();
|
|
indvdum@0
|
374 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
375 |
{
|
|
indvdum@0
|
376 |
$post_id_list[] = $row['post_id'];
|
|
indvdum@0
|
377 |
}
|
|
indvdum@0
|
378 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
379 |
}
|
|
indvdum@0
|
380 |
|
|
indvdum@0
|
381 |
if (!sizeof($post_id_list))
|
|
indvdum@0
|
382 |
{
|
|
indvdum@0
|
383 |
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
|
|
indvdum@0
|
384 |
return;
|
|
indvdum@0
|
385 |
}
|
|
indvdum@0
|
386 |
|
|
indvdum@0
|
387 |
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
|
|
indvdum@0
|
388 |
{
|
|
indvdum@0
|
389 |
return;
|
|
indvdum@0
|
390 |
}
|
|
indvdum@0
|
391 |
|
|
indvdum@0
|
392 |
$redirect = request_var('redirect', build_url(array('quickmod')));
|
|
indvdum@0
|
393 |
|
|
indvdum@0
|
394 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
395 |
'i' => 'main',
|
|
indvdum@0
|
396 |
'f' => $forum_id,
|
|
indvdum@0
|
397 |
'post_id_list' => $post_id_list,
|
|
indvdum@0
|
398 |
'to_topic_id' => $to_topic_id,
|
|
indvdum@0
|
399 |
'mode' => 'forum_view',
|
|
indvdum@0
|
400 |
'action' => 'merge_topics',
|
|
indvdum@0
|
401 |
'start' => $start,
|
|
indvdum@0
|
402 |
'redirect' => $redirect,
|
|
indvdum@0
|
403 |
'topic_id_list' => $topic_ids)
|
|
indvdum@0
|
404 |
);
|
|
indvdum@0
|
405 |
$success_msg = $return_link = '';
|
|
indvdum@0
|
406 |
|
|
indvdum@0
|
407 |
if (confirm_box(true))
|
|
indvdum@0
|
408 |
{
|
|
indvdum@0
|
409 |
$to_forum_id = $topic_data['forum_id'];
|
|
indvdum@0
|
410 |
|
|
indvdum@0
|
411 |
move_posts($post_id_list, $to_topic_id);
|
|
indvdum@0
|
412 |
add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);
|
|
indvdum@0
|
413 |
|
|
indvdum@0
|
414 |
// Message and return links
|
|
indvdum@0
|
415 |
$success_msg = 'POSTS_MERGED_SUCCESS';
|
|
indvdum@0
|
416 |
|
|
indvdum@0
|
417 |
// If the topic no longer exist, we will update the topic watch table.
|
|
indvdum@0
|
418 |
// To not let it error out on users watching both topics, we just return on an error...
|
|
indvdum@0
|
419 |
$db->sql_return_on_error(true);
|
|
indvdum@0
|
420 |
$db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
|
|
indvdum@0
|
421 |
$db->sql_return_on_error(false);
|
|
indvdum@0
|
422 |
|
|
indvdum@0
|
423 |
$db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
|
|
indvdum@0
|
424 |
|
|
indvdum@0
|
425 |
// Link to the new topic
|
|
indvdum@0
|
426 |
$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>');
|
|
indvdum@0
|
427 |
}
|
|
indvdum@0
|
428 |
else
|
|
indvdum@0
|
429 |
{
|
|
indvdum@0
|
430 |
confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);
|
|
indvdum@0
|
431 |
}
|
|
indvdum@0
|
432 |
|
|
indvdum@0
|
433 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
indvdum@0
|
434 |
$redirect = reapply_sid($redirect);
|
|
indvdum@0
|
435 |
|
|
indvdum@0
|
436 |
if (!$success_msg)
|
|
indvdum@0
|
437 |
{
|
|
indvdum@0
|
438 |
return;
|
|
indvdum@0
|
439 |
}
|
|
indvdum@0
|
440 |
else
|
|
indvdum@0
|
441 |
{
|
|
indvdum@0
|
442 |
meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"));
|
|
indvdum@0
|
443 |
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
|
|
indvdum@0
|
444 |
}
|
|
indvdum@0
|
445 |
}
|
|
indvdum@0
|
446 |
|
|
indvdum@0
|
447 |
?> |