|
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_main
|
|
indvdum@0
|
21 |
* Handling mcp actions
|
|
indvdum@0
|
22 |
* @package mcp
|
|
indvdum@0
|
23 |
*/
|
|
indvdum@0
|
24 |
class mcp_main
|
|
indvdum@0
|
25 |
{
|
|
indvdum@0
|
26 |
var $p_master;
|
|
indvdum@0
|
27 |
var $u_action;
|
|
indvdum@0
|
28 |
|
|
indvdum@0
|
29 |
function mcp_main(&$p_master)
|
|
indvdum@0
|
30 |
{
|
|
indvdum@0
|
31 |
$this->p_master = &$p_master;
|
|
indvdum@0
|
32 |
}
|
|
indvdum@0
|
33 |
|
|
indvdum@0
|
34 |
function main($id, $mode)
|
|
indvdum@0
|
35 |
{
|
|
indvdum@0
|
36 |
global $auth, $db, $user, $template, $action;
|
|
indvdum@0
|
37 |
global $config, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
38 |
|
|
indvdum@0
|
39 |
$quickmod = ($mode == 'quickmod') ? true : false;
|
|
indvdum@0
|
40 |
|
|
indvdum@0
|
41 |
switch ($action)
|
|
indvdum@0
|
42 |
{
|
|
indvdum@0
|
43 |
case 'lock':
|
|
indvdum@0
|
44 |
case 'unlock':
|
|
indvdum@0
|
45 |
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
|
|
indvdum@0
|
46 |
|
|
indvdum@0
|
47 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
48 |
{
|
|
indvdum@0
|
49 |
trigger_error('NO_TOPIC_SELECTED');
|
|
indvdum@0
|
50 |
}
|
|
indvdum@0
|
51 |
|
|
indvdum@0
|
52 |
lock_unlock($action, $topic_ids);
|
|
indvdum@0
|
53 |
break;
|
|
indvdum@0
|
54 |
|
|
indvdum@0
|
55 |
case 'lock_post':
|
|
indvdum@0
|
56 |
case 'unlock_post':
|
|
indvdum@0
|
57 |
|
|
indvdum@0
|
58 |
$post_ids = (!$quickmod) ? request_var('post_id_list', array(0)) : array(request_var('p', 0));
|
|
indvdum@0
|
59 |
|
|
indvdum@0
|
60 |
if (!sizeof($post_ids))
|
|
indvdum@0
|
61 |
{
|
|
indvdum@0
|
62 |
trigger_error('NO_POST_SELECTED');
|
|
indvdum@0
|
63 |
}
|
|
indvdum@0
|
64 |
|
|
indvdum@0
|
65 |
lock_unlock($action, $post_ids);
|
|
indvdum@0
|
66 |
break;
|
|
indvdum@0
|
67 |
|
|
indvdum@0
|
68 |
case 'make_announce':
|
|
indvdum@0
|
69 |
case 'make_sticky':
|
|
indvdum@0
|
70 |
case 'make_global':
|
|
indvdum@0
|
71 |
case 'make_normal':
|
|
indvdum@0
|
72 |
|
|
indvdum@0
|
73 |
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
|
|
indvdum@0
|
74 |
|
|
indvdum@0
|
75 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
76 |
{
|
|
indvdum@0
|
77 |
trigger_error('NO_TOPIC_SELECTED');
|
|
indvdum@0
|
78 |
}
|
|
indvdum@0
|
79 |
|
|
indvdum@0
|
80 |
change_topic_type($action, $topic_ids);
|
|
indvdum@0
|
81 |
break;
|
|
indvdum@0
|
82 |
|
|
indvdum@0
|
83 |
case 'move':
|
|
indvdum@0
|
84 |
$user->add_lang('viewtopic');
|
|
indvdum@0
|
85 |
|
|
indvdum@0
|
86 |
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
|
|
indvdum@0
|
87 |
|
|
indvdum@0
|
88 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
89 |
{
|
|
indvdum@0
|
90 |
trigger_error('NO_TOPIC_SELECTED');
|
|
indvdum@0
|
91 |
}
|
|
indvdum@0
|
92 |
|
|
indvdum@0
|
93 |
mcp_move_topic($topic_ids);
|
|
indvdum@0
|
94 |
break;
|
|
indvdum@0
|
95 |
|
|
indvdum@0
|
96 |
case 'fork':
|
|
indvdum@0
|
97 |
$user->add_lang('viewtopic');
|
|
indvdum@0
|
98 |
|
|
indvdum@0
|
99 |
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
|
|
indvdum@0
|
100 |
|
|
indvdum@0
|
101 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
102 |
{
|
|
indvdum@0
|
103 |
trigger_error('NO_TOPIC_SELECTED');
|
|
indvdum@0
|
104 |
}
|
|
indvdum@0
|
105 |
|
|
indvdum@0
|
106 |
mcp_fork_topic($topic_ids);
|
|
indvdum@0
|
107 |
break;
|
|
indvdum@0
|
108 |
|
|
indvdum@0
|
109 |
case 'delete_topic':
|
|
indvdum@0
|
110 |
$user->add_lang('viewtopic');
|
|
indvdum@0
|
111 |
|
|
indvdum@0
|
112 |
$topic_ids = (!$quickmod) ? request_var('topic_id_list', array(0)) : array(request_var('t', 0));
|
|
indvdum@0
|
113 |
|
|
indvdum@0
|
114 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
115 |
{
|
|
indvdum@0
|
116 |
trigger_error('NO_TOPIC_SELECTED');
|
|
indvdum@0
|
117 |
}
|
|
indvdum@0
|
118 |
|
|
indvdum@0
|
119 |
mcp_delete_topic($topic_ids);
|
|
indvdum@0
|
120 |
break;
|
|
indvdum@0
|
121 |
|
|
indvdum@0
|
122 |
case 'delete_post':
|
|
indvdum@0
|
123 |
$user->add_lang('posting');
|
|
indvdum@0
|
124 |
|
|
indvdum@0
|
125 |
$post_ids = (!$quickmod) ? request_var('post_id_list', array(0)) : array(request_var('p', 0));
|
|
indvdum@0
|
126 |
|
|
indvdum@0
|
127 |
if (!sizeof($post_ids))
|
|
indvdum@0
|
128 |
{
|
|
indvdum@0
|
129 |
trigger_error('NO_POST_SELECTED');
|
|
indvdum@0
|
130 |
}
|
|
indvdum@0
|
131 |
|
|
indvdum@0
|
132 |
mcp_delete_post($post_ids);
|
|
indvdum@0
|
133 |
break;
|
|
indvdum@0
|
134 |
}
|
|
indvdum@0
|
135 |
|
|
indvdum@0
|
136 |
switch ($mode)
|
|
indvdum@0
|
137 |
{
|
|
indvdum@0
|
138 |
case 'front':
|
|
indvdum@0
|
139 |
include($phpbb_root_path . 'includes/mcp/mcp_front.' . $phpEx);
|
|
indvdum@0
|
140 |
|
|
indvdum@0
|
141 |
$user->add_lang('acp/common');
|
|
indvdum@0
|
142 |
|
|
indvdum@0
|
143 |
mcp_front_view($id, $mode, $action);
|
|
indvdum@0
|
144 |
|
|
indvdum@0
|
145 |
$this->tpl_name = 'mcp_front';
|
|
indvdum@0
|
146 |
$this->page_title = 'MCP_MAIN';
|
|
indvdum@0
|
147 |
break;
|
|
indvdum@0
|
148 |
|
|
indvdum@0
|
149 |
case 'forum_view':
|
|
indvdum@0
|
150 |
include($phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx);
|
|
indvdum@0
|
151 |
|
|
indvdum@0
|
152 |
$user->add_lang('viewforum');
|
|
indvdum@0
|
153 |
|
|
indvdum@0
|
154 |
$forum_id = request_var('f', 0);
|
|
indvdum@0
|
155 |
|
|
indvdum@0
|
156 |
$forum_info = get_forum_data($forum_id, 'm_', true);
|
|
indvdum@0
|
157 |
|
|
indvdum@0
|
158 |
if (!sizeof($forum_info))
|
|
indvdum@0
|
159 |
{
|
|
indvdum@0
|
160 |
$this->main('main', 'front');
|
|
indvdum@0
|
161 |
return;
|
|
indvdum@0
|
162 |
}
|
|
indvdum@0
|
163 |
|
|
indvdum@0
|
164 |
$forum_info = $forum_info[$forum_id];
|
|
indvdum@0
|
165 |
|
|
indvdum@0
|
166 |
mcp_forum_view($id, $mode, $action, $forum_info);
|
|
indvdum@0
|
167 |
|
|
indvdum@0
|
168 |
$this->tpl_name = 'mcp_forum';
|
|
indvdum@0
|
169 |
$this->page_title = 'MCP_MAIN_FORUM_VIEW';
|
|
indvdum@0
|
170 |
break;
|
|
indvdum@0
|
171 |
|
|
indvdum@0
|
172 |
case 'topic_view':
|
|
indvdum@0
|
173 |
include($phpbb_root_path . 'includes/mcp/mcp_topic.' . $phpEx);
|
|
indvdum@0
|
174 |
|
|
indvdum@0
|
175 |
mcp_topic_view($id, $mode, $action);
|
|
indvdum@0
|
176 |
|
|
indvdum@0
|
177 |
$this->tpl_name = 'mcp_topic';
|
|
indvdum@0
|
178 |
$this->page_title = 'MCP_MAIN_TOPIC_VIEW';
|
|
indvdum@0
|
179 |
break;
|
|
indvdum@0
|
180 |
|
|
indvdum@0
|
181 |
case 'post_details':
|
|
indvdum@0
|
182 |
include($phpbb_root_path . 'includes/mcp/mcp_post.' . $phpEx);
|
|
indvdum@0
|
183 |
|
|
indvdum@0
|
184 |
mcp_post_details($id, $mode, $action);
|
|
indvdum@0
|
185 |
|
|
indvdum@0
|
186 |
$this->tpl_name = ($action == 'whois') ? 'mcp_whois' : 'mcp_post';
|
|
indvdum@0
|
187 |
$this->page_title = 'MCP_MAIN_POST_DETAILS';
|
|
indvdum@0
|
188 |
break;
|
|
indvdum@0
|
189 |
|
|
indvdum@0
|
190 |
default:
|
|
indvdum@0
|
191 |
trigger_error('NO_MODE', E_USER_ERROR);
|
|
indvdum@0
|
192 |
break;
|
|
indvdum@0
|
193 |
}
|
|
indvdum@0
|
194 |
}
|
|
indvdum@0
|
195 |
}
|
|
indvdum@0
|
196 |
|
|
indvdum@0
|
197 |
/**
|
|
indvdum@0
|
198 |
* Lock/Unlock Topic/Post
|
|
indvdum@0
|
199 |
*/
|
|
indvdum@0
|
200 |
function lock_unlock($action, $ids)
|
|
indvdum@0
|
201 |
{
|
|
indvdum@0
|
202 |
global $auth, $user, $db, $phpEx, $phpbb_root_path;
|
|
indvdum@0
|
203 |
|
|
indvdum@0
|
204 |
if ($action == 'lock' || $action == 'unlock')
|
|
indvdum@0
|
205 |
{
|
|
indvdum@0
|
206 |
$table = TOPICS_TABLE;
|
|
indvdum@0
|
207 |
$sql_id = 'topic_id';
|
|
indvdum@0
|
208 |
$set_id = 'topic_status';
|
|
indvdum@0
|
209 |
$l_prefix = 'TOPIC';
|
|
indvdum@0
|
210 |
}
|
|
indvdum@0
|
211 |
else
|
|
indvdum@0
|
212 |
{
|
|
indvdum@0
|
213 |
$table = POSTS_TABLE;
|
|
indvdum@0
|
214 |
$sql_id = 'post_id';
|
|
indvdum@0
|
215 |
$set_id = 'post_edit_locked';
|
|
indvdum@0
|
216 |
$l_prefix = 'POST';
|
|
indvdum@0
|
217 |
}
|
|
indvdum@0
|
218 |
|
|
indvdum@0
|
219 |
$orig_ids = $ids;
|
|
indvdum@0
|
220 |
|
|
indvdum@0
|
221 |
if (!check_ids($ids, $table, $sql_id, array('m_lock')))
|
|
indvdum@0
|
222 |
{
|
|
indvdum@0
|
223 |
// Make sure that for f_user_lock only the lock action is triggered.
|
|
indvdum@0
|
224 |
if ($action != 'lock')
|
|
indvdum@0
|
225 |
{
|
|
indvdum@0
|
226 |
return;
|
|
indvdum@0
|
227 |
}
|
|
indvdum@0
|
228 |
|
|
indvdum@0
|
229 |
$ids = $orig_ids;
|
|
indvdum@0
|
230 |
|
|
indvdum@0
|
231 |
if (!check_ids($ids, $table, $sql_id, array('f_user_lock')))
|
|
indvdum@0
|
232 |
{
|
|
indvdum@0
|
233 |
return;
|
|
indvdum@0
|
234 |
}
|
|
indvdum@0
|
235 |
}
|
|
indvdum@0
|
236 |
unset($orig_ids);
|
|
indvdum@0
|
237 |
|
|
indvdum@0
|
238 |
$redirect = request_var('redirect', build_url(array('action', 'quickmod')));
|
|
indvdum@0
|
239 |
|
|
indvdum@0
|
240 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
241 |
$sql_id . '_list' => $ids,
|
|
indvdum@0
|
242 |
'action' => $action,
|
|
indvdum@0
|
243 |
'redirect' => $redirect)
|
|
indvdum@0
|
244 |
);
|
|
indvdum@0
|
245 |
$success_msg = '';
|
|
indvdum@0
|
246 |
|
|
indvdum@0
|
247 |
if (confirm_box(true))
|
|
indvdum@0
|
248 |
{
|
|
indvdum@0
|
249 |
$sql = "UPDATE $table
|
|
indvdum@0
|
250 |
SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . '
|
|
indvdum@0
|
251 |
WHERE ' . $db->sql_in_set($sql_id, $ids);
|
|
indvdum@0
|
252 |
$db->sql_query($sql);
|
|
indvdum@0
|
253 |
|
|
indvdum@0
|
254 |
$data = ($action == 'lock' || $action == 'unlock') ? get_topic_data($ids) : get_post_data($ids);
|
|
indvdum@0
|
255 |
|
|
indvdum@0
|
256 |
foreach ($data as $id => $row)
|
|
indvdum@0
|
257 |
{
|
|
indvdum@0
|
258 |
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_' . strtoupper($action), $row['topic_title']);
|
|
indvdum@0
|
259 |
}
|
|
indvdum@0
|
260 |
|
|
indvdum@0
|
261 |
$success_msg = $l_prefix . ((sizeof($ids) == 1) ? '' : 'S') . '_' . (($action == 'lock' || $action == 'lock_post') ? 'LOCKED' : 'UNLOCKED') . '_SUCCESS';
|
|
indvdum@0
|
262 |
}
|
|
indvdum@0
|
263 |
else
|
|
indvdum@0
|
264 |
{
|
|
indvdum@0
|
265 |
confirm_box(false, strtoupper($action) . '_' . $l_prefix . ((sizeof($ids) == 1) ? '' : 'S'), $s_hidden_fields);
|
|
indvdum@0
|
266 |
}
|
|
indvdum@0
|
267 |
|
|
indvdum@0
|
268 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
indvdum@0
|
269 |
$redirect = reapply_sid($redirect);
|
|
indvdum@0
|
270 |
|
|
indvdum@0
|
271 |
if (!$success_msg)
|
|
indvdum@0
|
272 |
{
|
|
indvdum@0
|
273 |
redirect($redirect);
|
|
indvdum@0
|
274 |
}
|
|
indvdum@0
|
275 |
else
|
|
indvdum@0
|
276 |
{
|
|
indvdum@0
|
277 |
meta_refresh(2, $redirect);
|
|
indvdum@0
|
278 |
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
|
indvdum@0
|
279 |
}
|
|
indvdum@0
|
280 |
}
|
|
indvdum@0
|
281 |
|
|
indvdum@0
|
282 |
/**
|
|
indvdum@0
|
283 |
* Change Topic Type
|
|
indvdum@0
|
284 |
*/
|
|
indvdum@0
|
285 |
function change_topic_type($action, $topic_ids)
|
|
indvdum@0
|
286 |
{
|
|
indvdum@0
|
287 |
global $auth, $user, $db, $phpEx, $phpbb_root_path;
|
|
indvdum@0
|
288 |
|
|
indvdum@0
|
289 |
switch ($action)
|
|
indvdum@0
|
290 |
{
|
|
indvdum@0
|
291 |
case 'make_announce':
|
|
indvdum@0
|
292 |
$new_topic_type = POST_ANNOUNCE;
|
|
indvdum@0
|
293 |
$check_acl = 'f_announce';
|
|
indvdum@0
|
294 |
$l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_ANNOUNCEMENT' : 'MCP_MAKE_ANNOUNCEMENTS';
|
|
indvdum@0
|
295 |
break;
|
|
indvdum@0
|
296 |
|
|
indvdum@0
|
297 |
case 'make_global':
|
|
indvdum@0
|
298 |
$new_topic_type = POST_GLOBAL;
|
|
indvdum@0
|
299 |
$check_acl = 'f_announce';
|
|
indvdum@0
|
300 |
$l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_GLOBAL' : 'MCP_MAKE_GLOBALS';
|
|
indvdum@0
|
301 |
break;
|
|
indvdum@0
|
302 |
|
|
indvdum@0
|
303 |
case 'make_sticky':
|
|
indvdum@0
|
304 |
$new_topic_type = POST_STICKY;
|
|
indvdum@0
|
305 |
$check_acl = 'f_sticky';
|
|
indvdum@0
|
306 |
$l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_STICKY' : 'MCP_MAKE_STICKIES';
|
|
indvdum@0
|
307 |
break;
|
|
indvdum@0
|
308 |
|
|
indvdum@0
|
309 |
default:
|
|
indvdum@0
|
310 |
$new_topic_type = POST_NORMAL;
|
|
indvdum@0
|
311 |
$check_acl = false;
|
|
indvdum@0
|
312 |
$l_new_type = (sizeof($topic_ids) == 1) ? 'MCP_MAKE_NORMAL' : 'MCP_MAKE_NORMALS';
|
|
indvdum@0
|
313 |
break;
|
|
indvdum@0
|
314 |
}
|
|
indvdum@0
|
315 |
|
|
indvdum@0
|
316 |
$forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', $check_acl, true);
|
|
indvdum@0
|
317 |
|
|
indvdum@0
|
318 |
if ($forum_id === false)
|
|
indvdum@0
|
319 |
{
|
|
indvdum@0
|
320 |
return;
|
|
indvdum@0
|
321 |
}
|
|
indvdum@0
|
322 |
|
|
indvdum@0
|
323 |
$redirect = request_var('redirect', build_url(array('action', 'quickmod')));
|
|
indvdum@0
|
324 |
|
|
indvdum@0
|
325 |
$s_hidden_fields = array(
|
|
indvdum@0
|
326 |
'topic_id_list' => $topic_ids,
|
|
indvdum@0
|
327 |
'f' => $forum_id,
|
|
indvdum@0
|
328 |
'action' => $action,
|
|
indvdum@0
|
329 |
'redirect' => $redirect,
|
|
indvdum@0
|
330 |
);
|
|
indvdum@0
|
331 |
$success_msg = '';
|
|
indvdum@0
|
332 |
|
|
indvdum@0
|
333 |
if (confirm_box(true))
|
|
indvdum@0
|
334 |
{
|
|
indvdum@0
|
335 |
if ($new_topic_type != POST_GLOBAL)
|
|
indvdum@0
|
336 |
{
|
|
indvdum@0
|
337 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
indvdum@0
|
338 |
SET topic_type = $new_topic_type
|
|
indvdum@0
|
339 |
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
|
|
indvdum@0
|
340 |
AND forum_id <> 0';
|
|
indvdum@0
|
341 |
$db->sql_query($sql);
|
|
indvdum@0
|
342 |
|
|
indvdum@0
|
343 |
// Reset forum id if a global topic is within the array
|
|
indvdum@0
|
344 |
$to_forum_id = request_var('to_forum_id', 0);
|
|
indvdum@0
|
345 |
|
|
indvdum@0
|
346 |
if ($to_forum_id)
|
|
indvdum@0
|
347 |
{
|
|
indvdum@0
|
348 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
indvdum@0
|
349 |
SET topic_type = $new_topic_type, forum_id = $to_forum_id
|
|
indvdum@0
|
350 |
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
|
|
indvdum@0
|
351 |
AND forum_id = 0';
|
|
indvdum@0
|
352 |
$db->sql_query($sql);
|
|
indvdum@0
|
353 |
|
|
indvdum@0
|
354 |
// Update forum_ids for all posts
|
|
indvdum@0
|
355 |
$sql = 'UPDATE ' . POSTS_TABLE . "
|
|
indvdum@0
|
356 |
SET forum_id = $to_forum_id
|
|
indvdum@0
|
357 |
WHERE " . $db->sql_in_set('topic_id', $topic_ids) . '
|
|
indvdum@0
|
358 |
AND forum_id = 0';
|
|
indvdum@0
|
359 |
$db->sql_query($sql);
|
|
indvdum@0
|
360 |
|
|
indvdum@0
|
361 |
// Do a little forum sync stuff
|
|
indvdum@0
|
362 |
$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
|
|
indvdum@0
|
363 |
FROM ' . TOPICS_TABLE . ' t
|
|
indvdum@0
|
364 |
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);
|
|
indvdum@0
|
365 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
366 |
$row_data = $db->sql_fetchrow($result);
|
|
indvdum@0
|
367 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
368 |
|
|
indvdum@0
|
369 |
$sync_sql = array();
|
|
indvdum@0
|
370 |
|
|
indvdum@0
|
371 |
if ($row_data['topic_posts'])
|
|
indvdum@0
|
372 |
{
|
|
indvdum@0
|
373 |
$sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts'];
|
|
indvdum@0
|
374 |
}
|
|
indvdum@0
|
375 |
|
|
indvdum@0
|
376 |
if ($row_data['topics_authed'])
|
|
indvdum@0
|
377 |
{
|
|
indvdum@0
|
378 |
$sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $row_data['topics_authed'];
|
|
indvdum@0
|
379 |
}
|
|
indvdum@0
|
380 |
|
|
indvdum@0
|
381 |
$sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) sizeof($topic_ids);
|
|
indvdum@0
|
382 |
|
|
indvdum@0
|
383 |
foreach ($sync_sql as $forum_id_key => $array)
|
|
indvdum@0
|
384 |
{
|
|
indvdum@0
|
385 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
386 |
SET ' . implode(', ', $array) . '
|
|
indvdum@0
|
387 |
WHERE forum_id = ' . $forum_id_key;
|
|
indvdum@0
|
388 |
$db->sql_query($sql);
|
|
indvdum@0
|
389 |
}
|
|
indvdum@0
|
390 |
|
|
indvdum@0
|
391 |
sync('forum', 'forum_id', $to_forum_id);
|
|
indvdum@0
|
392 |
}
|
|
indvdum@0
|
393 |
}
|
|
indvdum@0
|
394 |
else
|
|
indvdum@0
|
395 |
{
|
|
indvdum@0
|
396 |
// Get away with those topics already being a global announcement by re-calculating $topic_ids
|
|
indvdum@0
|
397 |
$sql = 'SELECT topic_id
|
|
indvdum@0
|
398 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
399 |
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
|
|
indvdum@0
|
400 |
AND forum_id <> 0';
|
|
indvdum@0
|
401 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
402 |
|
|
indvdum@0
|
403 |
$topic_ids = array();
|
|
indvdum@0
|
404 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
405 |
{
|
|
indvdum@0
|
406 |
$topic_ids[] = $row['topic_id'];
|
|
indvdum@0
|
407 |
}
|
|
indvdum@0
|
408 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
409 |
|
|
indvdum@0
|
410 |
if (sizeof($topic_ids))
|
|
indvdum@0
|
411 |
{
|
|
indvdum@0
|
412 |
// Delete topic shadows for global announcements
|
|
indvdum@0
|
413 |
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
414 |
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
|
|
indvdum@0
|
415 |
$db->sql_query($sql);
|
|
indvdum@0
|
416 |
|
|
indvdum@0
|
417 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
indvdum@0
|
418 |
SET topic_type = $new_topic_type, forum_id = 0
|
|
indvdum@0
|
419 |
WHERE " . $db->sql_in_set('topic_id', $topic_ids);
|
|
indvdum@0
|
420 |
$db->sql_query($sql);
|
|
indvdum@0
|
421 |
|
|
indvdum@0
|
422 |
// Update forum_ids for all posts
|
|
indvdum@0
|
423 |
$sql = 'UPDATE ' . POSTS_TABLE . '
|
|
indvdum@0
|
424 |
SET forum_id = 0
|
|
indvdum@0
|
425 |
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
|
indvdum@0
|
426 |
$db->sql_query($sql);
|
|
indvdum@0
|
427 |
|
|
indvdum@0
|
428 |
// Do a little forum sync stuff
|
|
indvdum@0
|
429 |
$sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts, COUNT(t.topic_approved) as topics_authed
|
|
indvdum@0
|
430 |
FROM ' . TOPICS_TABLE . ' t
|
|
indvdum@0
|
431 |
WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids);
|
|
indvdum@0
|
432 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
433 |
$row_data = $db->sql_fetchrow($result);
|
|
indvdum@0
|
434 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
435 |
|
|
indvdum@0
|
436 |
$sync_sql = array();
|
|
indvdum@0
|
437 |
|
|
indvdum@0
|
438 |
if ($row_data['topic_posts'])
|
|
indvdum@0
|
439 |
{
|
|
indvdum@0
|
440 |
$sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts'];
|
|
indvdum@0
|
441 |
}
|
|
indvdum@0
|
442 |
|
|
indvdum@0
|
443 |
if ($row_data['topics_authed'])
|
|
indvdum@0
|
444 |
{
|
|
indvdum@0
|
445 |
$sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $row_data['topics_authed'];
|
|
indvdum@0
|
446 |
}
|
|
indvdum@0
|
447 |
|
|
indvdum@0
|
448 |
$sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) sizeof($topic_ids);
|
|
indvdum@0
|
449 |
|
|
indvdum@0
|
450 |
foreach ($sync_sql as $forum_id_key => $array)
|
|
indvdum@0
|
451 |
{
|
|
indvdum@0
|
452 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
453 |
SET ' . implode(', ', $array) . '
|
|
indvdum@0
|
454 |
WHERE forum_id = ' . $forum_id_key;
|
|
indvdum@0
|
455 |
$db->sql_query($sql);
|
|
indvdum@0
|
456 |
}
|
|
indvdum@0
|
457 |
|
|
indvdum@0
|
458 |
sync('forum', 'forum_id', $forum_id);
|
|
indvdum@0
|
459 |
}
|
|
indvdum@0
|
460 |
}
|
|
indvdum@0
|
461 |
|
|
indvdum@0
|
462 |
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED';
|
|
indvdum@0
|
463 |
|
|
indvdum@0
|
464 |
if (sizeof($topic_ids))
|
|
indvdum@0
|
465 |
{
|
|
indvdum@0
|
466 |
$data = get_topic_data($topic_ids);
|
|
indvdum@0
|
467 |
|
|
indvdum@0
|
468 |
foreach ($data as $topic_id => $row)
|
|
indvdum@0
|
469 |
{
|
|
indvdum@0
|
470 |
add_log('mod', $forum_id, $topic_id, 'LOG_TOPIC_TYPE_CHANGED', $row['topic_title']);
|
|
indvdum@0
|
471 |
}
|
|
indvdum@0
|
472 |
}
|
|
indvdum@0
|
473 |
}
|
|
indvdum@0
|
474 |
else
|
|
indvdum@0
|
475 |
{
|
|
indvdum@0
|
476 |
// Global topic involved?
|
|
indvdum@0
|
477 |
$global_involved = false;
|
|
indvdum@0
|
478 |
|
|
indvdum@0
|
479 |
if ($new_topic_type != POST_GLOBAL)
|
|
indvdum@0
|
480 |
{
|
|
indvdum@0
|
481 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
482 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
483 |
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
|
|
indvdum@0
|
484 |
AND forum_id = 0';
|
|
indvdum@0
|
485 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
486 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
487 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
488 |
|
|
indvdum@0
|
489 |
if ($row)
|
|
indvdum@0
|
490 |
{
|
|
indvdum@0
|
491 |
$global_involved = true;
|
|
indvdum@0
|
492 |
}
|
|
indvdum@0
|
493 |
}
|
|
indvdum@0
|
494 |
|
|
indvdum@0
|
495 |
if ($global_involved)
|
|
indvdum@0
|
496 |
{
|
|
indvdum@0
|
497 |
global $template;
|
|
indvdum@0
|
498 |
|
|
indvdum@0
|
499 |
$template->assign_vars(array(
|
|
indvdum@0
|
500 |
'S_FORUM_SELECT' => make_forum_select(request_var('f', $forum_id), false, false, true, true),
|
|
indvdum@0
|
501 |
'S_CAN_LEAVE_SHADOW' => false,
|
|
indvdum@0
|
502 |
'ADDITIONAL_MSG' => (sizeof($topic_ids) == 1) ? $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENT'] : $user->lang['SELECT_FORUM_GLOBAL_ANNOUNCEMENTS'])
|
|
indvdum@0
|
503 |
);
|
|
indvdum@0
|
504 |
|
|
indvdum@0
|
505 |
confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields), 'mcp_move.html');
|
|
indvdum@0
|
506 |
}
|
|
indvdum@0
|
507 |
else
|
|
indvdum@0
|
508 |
{
|
|
indvdum@0
|
509 |
confirm_box(false, $l_new_type, build_hidden_fields($s_hidden_fields));
|
|
indvdum@0
|
510 |
}
|
|
indvdum@0
|
511 |
}
|
|
indvdum@0
|
512 |
|
|
indvdum@0
|
513 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
indvdum@0
|
514 |
$redirect = reapply_sid($redirect);
|
|
indvdum@0
|
515 |
|
|
indvdum@0
|
516 |
if (!$success_msg)
|
|
indvdum@0
|
517 |
{
|
|
indvdum@0
|
518 |
redirect($redirect);
|
|
indvdum@0
|
519 |
}
|
|
indvdum@0
|
520 |
else
|
|
indvdum@0
|
521 |
{
|
|
indvdum@0
|
522 |
meta_refresh(2, $redirect);
|
|
indvdum@0
|
523 |
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
|
indvdum@0
|
524 |
}
|
|
indvdum@0
|
525 |
}
|
|
indvdum@0
|
526 |
|
|
indvdum@0
|
527 |
/**
|
|
indvdum@0
|
528 |
* Move Topic
|
|
indvdum@0
|
529 |
*/
|
|
indvdum@0
|
530 |
function mcp_move_topic($topic_ids)
|
|
indvdum@0
|
531 |
{
|
|
indvdum@0
|
532 |
global $auth, $user, $db, $template;
|
|
indvdum@0
|
533 |
global $phpEx, $phpbb_root_path;
|
|
indvdum@0
|
534 |
|
|
indvdum@0
|
535 |
// Here we limit the operation to one forum only
|
|
indvdum@0
|
536 |
$forum_id = check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_move'), true);
|
|
indvdum@0
|
537 |
|
|
indvdum@0
|
538 |
if ($forum_id === false)
|
|
indvdum@0
|
539 |
{
|
|
indvdum@0
|
540 |
return;
|
|
indvdum@0
|
541 |
}
|
|
indvdum@0
|
542 |
|
|
indvdum@0
|
543 |
$to_forum_id = request_var('to_forum_id', 0);
|
|
indvdum@0
|
544 |
$redirect = request_var('redirect', build_url(array('action', 'quickmod')));
|
|
indvdum@0
|
545 |
$additional_msg = $success_msg = '';
|
|
indvdum@0
|
546 |
|
|
indvdum@0
|
547 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
548 |
'topic_id_list' => $topic_ids,
|
|
indvdum@0
|
549 |
'f' => $forum_id,
|
|
indvdum@0
|
550 |
'action' => 'move',
|
|
indvdum@0
|
551 |
'redirect' => $redirect)
|
|
indvdum@0
|
552 |
);
|
|
indvdum@0
|
553 |
|
|
indvdum@0
|
554 |
if ($to_forum_id)
|
|
indvdum@0
|
555 |
{
|
|
indvdum@0
|
556 |
$forum_data = get_forum_data($to_forum_id, 'f_post');
|
|
indvdum@0
|
557 |
|
|
indvdum@0
|
558 |
if (!sizeof($forum_data))
|
|
indvdum@0
|
559 |
{
|
|
indvdum@0
|
560 |
$additional_msg = $user->lang['FORUM_NOT_EXIST'];
|
|
indvdum@0
|
561 |
}
|
|
indvdum@0
|
562 |
else
|
|
indvdum@0
|
563 |
{
|
|
indvdum@0
|
564 |
$forum_data = $forum_data[$to_forum_id];
|
|
indvdum@0
|
565 |
|
|
indvdum@0
|
566 |
if ($forum_data['forum_type'] != FORUM_POST)
|
|
indvdum@0
|
567 |
{
|
|
indvdum@0
|
568 |
$additional_msg = $user->lang['FORUM_NOT_POSTABLE'];
|
|
indvdum@0
|
569 |
}
|
|
indvdum@0
|
570 |
else if (!$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id)))
|
|
indvdum@0
|
571 |
{
|
|
indvdum@0
|
572 |
$additional_msg = $user->lang['USER_CANNOT_POST'];
|
|
indvdum@0
|
573 |
}
|
|
indvdum@0
|
574 |
else if ($forum_id == $to_forum_id)
|
|
indvdum@0
|
575 |
{
|
|
indvdum@0
|
576 |
$additional_msg = $user->lang['CANNOT_MOVE_SAME_FORUM'];
|
|
indvdum@0
|
577 |
}
|
|
indvdum@0
|
578 |
}
|
|
indvdum@0
|
579 |
}
|
|
indvdum@0
|
580 |
else if (isset($_POST['confirm']))
|
|
indvdum@0
|
581 |
{
|
|
indvdum@0
|
582 |
$additional_msg = $user->lang['FORUM_NOT_EXIST'];
|
|
indvdum@0
|
583 |
}
|
|
indvdum@0
|
584 |
|
|
indvdum@0
|
585 |
if (!$to_forum_id || $additional_msg)
|
|
indvdum@0
|
586 |
{
|
|
indvdum@0
|
587 |
unset($_POST['confirm']);
|
|
indvdum@0
|
588 |
unset($_REQUEST['confirm_key']);
|
|
indvdum@0
|
589 |
}
|
|
indvdum@0
|
590 |
|
|
indvdum@0
|
591 |
if (confirm_box(true))
|
|
indvdum@0
|
592 |
{
|
|
indvdum@0
|
593 |
$topic_data = get_topic_data($topic_ids);
|
|
indvdum@0
|
594 |
$leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false;
|
|
indvdum@0
|
595 |
|
|
indvdum@0
|
596 |
$forum_sync_data = array();
|
|
indvdum@0
|
597 |
|
|
indvdum@0
|
598 |
$forum_sync_data[$forum_id] = current($topic_data);
|
|
indvdum@0
|
599 |
$forum_sync_data[$to_forum_id] = $forum_data;
|
|
indvdum@0
|
600 |
|
|
indvdum@0
|
601 |
// Real topics added to target forum
|
|
indvdum@0
|
602 |
$topics_moved = sizeof($topic_data);
|
|
indvdum@0
|
603 |
|
|
indvdum@0
|
604 |
// Approved topics added to target forum
|
|
indvdum@0
|
605 |
$topics_authed_moved = 0;
|
|
indvdum@0
|
606 |
|
|
indvdum@0
|
607 |
// Posts (topic replies + topic post if approved) added to target forum
|
|
indvdum@0
|
608 |
$topic_posts_added = 0;
|
|
indvdum@0
|
609 |
|
|
indvdum@0
|
610 |
// Posts (topic replies + topic post if approved and not global announcement) removed from source forum
|
|
indvdum@0
|
611 |
$topic_posts_removed = 0;
|
|
indvdum@0
|
612 |
|
|
indvdum@0
|
613 |
// Real topics removed from source forum (all topics without global announcements)
|
|
indvdum@0
|
614 |
$topics_removed = 0;
|
|
indvdum@0
|
615 |
|
|
indvdum@0
|
616 |
// Approved topics removed from source forum (except global announcements)
|
|
indvdum@0
|
617 |
$topics_authed_removed = 0;
|
|
indvdum@0
|
618 |
|
|
indvdum@0
|
619 |
foreach ($topic_data as $topic_id => $topic_info)
|
|
indvdum@0
|
620 |
{
|
|
indvdum@0
|
621 |
if ($topic_info['topic_approved'])
|
|
indvdum@0
|
622 |
{
|
|
indvdum@0
|
623 |
$topics_authed_moved++;
|
|
indvdum@0
|
624 |
$topic_posts_added++;
|
|
indvdum@0
|
625 |
}
|
|
indvdum@0
|
626 |
|
|
indvdum@0
|
627 |
$topic_posts_added += $topic_info['topic_replies'];
|
|
indvdum@0
|
628 |
|
|
indvdum@0
|
629 |
if ($topic_info['topic_type'] != POST_GLOBAL)
|
|
indvdum@0
|
630 |
{
|
|
indvdum@0
|
631 |
$topics_removed++;
|
|
indvdum@0
|
632 |
$topic_posts_removed += $topic_info['topic_replies'];
|
|
indvdum@0
|
633 |
|
|
indvdum@0
|
634 |
if ($topic_info['topic_approved'])
|
|
indvdum@0
|
635 |
{
|
|
indvdum@0
|
636 |
$topics_authed_removed++;
|
|
indvdum@0
|
637 |
$topic_posts_removed++;
|
|
indvdum@0
|
638 |
}
|
|
indvdum@0
|
639 |
}
|
|
indvdum@0
|
640 |
}
|
|
indvdum@0
|
641 |
|
|
indvdum@0
|
642 |
$db->sql_transaction('begin');
|
|
indvdum@0
|
643 |
|
|
indvdum@0
|
644 |
$sync_sql = array();
|
|
indvdum@0
|
645 |
|
|
indvdum@0
|
646 |
if ($topic_posts_added)
|
|
indvdum@0
|
647 |
{
|
|
indvdum@0
|
648 |
$sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . $topic_posts_added;
|
|
indvdum@0
|
649 |
}
|
|
indvdum@0
|
650 |
|
|
indvdum@0
|
651 |
if ($topics_authed_moved)
|
|
indvdum@0
|
652 |
{
|
|
indvdum@0
|
653 |
$sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $topics_authed_moved;
|
|
indvdum@0
|
654 |
}
|
|
indvdum@0
|
655 |
|
|
indvdum@0
|
656 |
$sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) $topics_moved;
|
|
indvdum@0
|
657 |
|
|
indvdum@0
|
658 |
// Move topics, but do not resync yet
|
|
indvdum@0
|
659 |
move_topics($topic_ids, $to_forum_id, false);
|
|
indvdum@0
|
660 |
|
|
indvdum@0
|
661 |
$forum_ids = array($to_forum_id);
|
|
indvdum@0
|
662 |
foreach ($topic_data as $topic_id => $row)
|
|
indvdum@0
|
663 |
{
|
|
indvdum@0
|
664 |
// Get the list of forums to resync, add a log entry
|
|
indvdum@0
|
665 |
$forum_ids[] = $row['forum_id'];
|
|
indvdum@0
|
666 |
add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']);
|
|
indvdum@0
|
667 |
|
|
indvdum@0
|
668 |
// If we have moved a global announcement, we need to correct the topic type
|
|
indvdum@0
|
669 |
if ($row['topic_type'] == POST_GLOBAL)
|
|
indvdum@0
|
670 |
{
|
|
indvdum@0
|
671 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
indvdum@0
|
672 |
SET topic_type = ' . POST_ANNOUNCE . '
|
|
indvdum@0
|
673 |
WHERE topic_id = ' . (int) $row['topic_id'];
|
|
indvdum@0
|
674 |
$db->sql_query($sql);
|
|
indvdum@0
|
675 |
}
|
|
indvdum@0
|
676 |
|
|
indvdum@0
|
677 |
// Leave a redirection if required and only if the topic is visible to users
|
|
indvdum@0
|
678 |
if ($leave_shadow && $row['topic_approved'] && $row['topic_type'] != POST_GLOBAL)
|
|
indvdum@0
|
679 |
{
|
|
indvdum@0
|
680 |
$shadow = array(
|
|
indvdum@0
|
681 |
'forum_id' => (int) $row['forum_id'],
|
|
indvdum@0
|
682 |
'icon_id' => (int) $row['icon_id'],
|
|
indvdum@0
|
683 |
'topic_attachment' => (int) $row['topic_attachment'],
|
|
indvdum@0
|
684 |
'topic_approved' => 1, // a shadow topic is always approved
|
|
indvdum@0
|
685 |
'topic_reported' => 0, // a shadow topic is never reported
|
|
indvdum@0
|
686 |
'topic_title' => (string) $row['topic_title'],
|
|
indvdum@0
|
687 |
'topic_poster' => (int) $row['topic_poster'],
|
|
indvdum@0
|
688 |
'topic_time' => (int) $row['topic_time'],
|
|
indvdum@0
|
689 |
'topic_time_limit' => (int) $row['topic_time_limit'],
|
|
indvdum@0
|
690 |
'topic_views' => (int) $row['topic_views'],
|
|
indvdum@0
|
691 |
'topic_replies' => (int) $row['topic_replies'],
|
|
indvdum@0
|
692 |
'topic_replies_real' => (int) $row['topic_replies_real'],
|
|
indvdum@0
|
693 |
'topic_status' => ITEM_MOVED,
|
|
indvdum@0
|
694 |
'topic_type' => POST_NORMAL,
|
|
indvdum@0
|
695 |
'topic_first_post_id' => (int) $row['topic_first_post_id'],
|
|
indvdum@0
|
696 |
'topic_first_poster_colour'=>(string) $row['topic_first_poster_colour'],
|
|
indvdum@0
|
697 |
'topic_first_poster_name'=> (string) $row['topic_first_poster_name'],
|
|
indvdum@0
|
698 |
'topic_last_post_id' => (int) $row['topic_last_post_id'],
|
|
indvdum@0
|
699 |
'topic_last_poster_id' => (int) $row['topic_last_poster_id'],
|
|
indvdum@0
|
700 |
'topic_last_poster_colour'=>(string) $row['topic_last_poster_colour'],
|
|
indvdum@0
|
701 |
'topic_last_poster_name'=> (string) $row['topic_last_poster_name'],
|
|
indvdum@0
|
702 |
'topic_last_post_subject'=> (string) $row['topic_last_post_subject'],
|
|
indvdum@0
|
703 |
'topic_last_post_time' => (int) $row['topic_last_post_time'],
|
|
indvdum@0
|
704 |
'topic_last_view_time' => (int) $row['topic_last_view_time'],
|
|
indvdum@0
|
705 |
'topic_moved_id' => (int) $row['topic_id'],
|
|
indvdum@0
|
706 |
'topic_bumped' => (int) $row['topic_bumped'],
|
|
indvdum@0
|
707 |
'topic_bumper' => (int) $row['topic_bumper'],
|
|
indvdum@0
|
708 |
'poll_title' => (string) $row['poll_title'],
|
|
indvdum@0
|
709 |
'poll_start' => (int) $row['poll_start'],
|
|
indvdum@0
|
710 |
'poll_length' => (int) $row['poll_length'],
|
|
indvdum@0
|
711 |
'poll_max_options' => (int) $row['poll_max_options'],
|
|
indvdum@0
|
712 |
'poll_last_vote' => (int) $row['poll_last_vote']
|
|
indvdum@0
|
713 |
);
|
|
indvdum@0
|
714 |
|
|
indvdum@0
|
715 |
$db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow));
|
|
indvdum@0
|
716 |
|
|
indvdum@0
|
717 |
// Shadow topics only count on new "topics" and not posts... a shadow topic alone has 0 posts
|
|
indvdum@0
|
718 |
$topics_removed--;
|
|
indvdum@0
|
719 |
$topics_authed_removed--;
|
|
indvdum@0
|
720 |
}
|
|
indvdum@0
|
721 |
}
|
|
indvdum@0
|
722 |
unset($topic_data);
|
|
indvdum@0
|
723 |
|
|
indvdum@0
|
724 |
if ($topic_posts_removed)
|
|
indvdum@0
|
725 |
{
|
|
indvdum@0
|
726 |
$sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . $topic_posts_removed;
|
|
indvdum@0
|
727 |
}
|
|
indvdum@0
|
728 |
|
|
indvdum@0
|
729 |
if ($topics_removed)
|
|
indvdum@0
|
730 |
{
|
|
indvdum@0
|
731 |
$sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) $topics_removed;
|
|
indvdum@0
|
732 |
}
|
|
indvdum@0
|
733 |
|
|
indvdum@0
|
734 |
if ($topics_authed_removed)
|
|
indvdum@0
|
735 |
{
|
|
indvdum@0
|
736 |
$sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $topics_authed_removed;
|
|
indvdum@0
|
737 |
}
|
|
indvdum@0
|
738 |
|
|
indvdum@0
|
739 |
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';
|
|
indvdum@0
|
740 |
|
|
indvdum@0
|
741 |
foreach ($sync_sql as $forum_id_key => $array)
|
|
indvdum@0
|
742 |
{
|
|
indvdum@0
|
743 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
744 |
SET ' . implode(', ', $array) . '
|
|
indvdum@0
|
745 |
WHERE forum_id = ' . $forum_id_key;
|
|
indvdum@0
|
746 |
$db->sql_query($sql);
|
|
indvdum@0
|
747 |
}
|
|
indvdum@0
|
748 |
|
|
indvdum@0
|
749 |
$db->sql_transaction('commit');
|
|
indvdum@0
|
750 |
|
|
indvdum@0
|
751 |
sync('forum', 'forum_id', array($forum_id, $to_forum_id));
|
|
indvdum@0
|
752 |
}
|
|
indvdum@0
|
753 |
else
|
|
indvdum@0
|
754 |
{
|
|
indvdum@0
|
755 |
$template->assign_vars(array(
|
|
indvdum@0
|
756 |
'S_FORUM_SELECT' => make_forum_select($to_forum_id, $forum_id, false, true, true, true),
|
|
indvdum@0
|
757 |
'S_CAN_LEAVE_SHADOW' => true,
|
|
indvdum@0
|
758 |
'ADDITIONAL_MSG' => $additional_msg)
|
|
indvdum@0
|
759 |
);
|
|
indvdum@0
|
760 |
|
|
indvdum@0
|
761 |
confirm_box(false, 'MOVE_TOPIC' . ((sizeof($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
|
|
indvdum@0
|
762 |
}
|
|
indvdum@0
|
763 |
|
|
indvdum@0
|
764 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
indvdum@0
|
765 |
$redirect = reapply_sid($redirect);
|
|
indvdum@0
|
766 |
|
|
indvdum@0
|
767 |
if (!$success_msg)
|
|
indvdum@0
|
768 |
{
|
|
indvdum@0
|
769 |
redirect($redirect);
|
|
indvdum@0
|
770 |
}
|
|
indvdum@0
|
771 |
else
|
|
indvdum@0
|
772 |
{
|
|
indvdum@0
|
773 |
meta_refresh(3, $redirect);
|
|
indvdum@0
|
774 |
|
|
indvdum@0
|
775 |
$message = $user->lang[$success_msg];
|
|
indvdum@0
|
776 |
$message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
|
|
indvdum@0
|
777 |
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id") . '">', '</a>');
|
|
indvdum@0
|
778 |
$message .= '<br /><br />' . sprintf($user->lang['RETURN_NEW_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$to_forum_id") . '">', '</a>');
|
|
indvdum@0
|
779 |
|
|
indvdum@0
|
780 |
trigger_error($message);
|
|
indvdum@0
|
781 |
}
|
|
indvdum@0
|
782 |
}
|
|
indvdum@0
|
783 |
|
|
indvdum@0
|
784 |
/**
|
|
indvdum@0
|
785 |
* Delete Topics
|
|
indvdum@0
|
786 |
*/
|
|
indvdum@0
|
787 |
function mcp_delete_topic($topic_ids)
|
|
indvdum@0
|
788 |
{
|
|
indvdum@0
|
789 |
global $auth, $user, $db, $phpEx, $phpbb_root_path;
|
|
indvdum@0
|
790 |
|
|
indvdum@0
|
791 |
if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_delete')))
|
|
indvdum@0
|
792 |
{
|
|
indvdum@0
|
793 |
return;
|
|
indvdum@0
|
794 |
}
|
|
indvdum@0
|
795 |
|
|
indvdum@0
|
796 |
$redirect = request_var('redirect', build_url(array('action', 'quickmod')));
|
|
indvdum@0
|
797 |
$forum_id = request_var('f', 0);
|
|
indvdum@0
|
798 |
|
|
indvdum@0
|
799 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
800 |
'topic_id_list' => $topic_ids,
|
|
indvdum@0
|
801 |
'f' => $forum_id,
|
|
indvdum@0
|
802 |
'action' => 'delete_topic',
|
|
indvdum@0
|
803 |
'redirect' => $redirect)
|
|
indvdum@0
|
804 |
);
|
|
indvdum@0
|
805 |
$success_msg = '';
|
|
indvdum@0
|
806 |
|
|
indvdum@0
|
807 |
if (confirm_box(true))
|
|
indvdum@0
|
808 |
{
|
|
indvdum@0
|
809 |
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_DELETED_SUCCESS' : 'TOPICS_DELETED_SUCCESS';
|
|
indvdum@0
|
810 |
|
|
indvdum@0
|
811 |
$data = get_topic_data($topic_ids);
|
|
indvdum@0
|
812 |
|
|
indvdum@0
|
813 |
foreach ($data as $topic_id => $row)
|
|
indvdum@0
|
814 |
{
|
|
indvdum@0
|
815 |
if ($row['topic_moved_id'])
|
|
indvdum@0
|
816 |
{
|
|
indvdum@0
|
817 |
add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_SHADOW_TOPIC', $row['topic_title']);
|
|
indvdum@0
|
818 |
}
|
|
indvdum@0
|
819 |
else
|
|
indvdum@0
|
820 |
{
|
|
indvdum@0
|
821 |
add_log('mod', $row['forum_id'], $topic_id, 'LOG_DELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']);
|
|
indvdum@0
|
822 |
}
|
|
indvdum@0
|
823 |
}
|
|
indvdum@0
|
824 |
|
|
indvdum@0
|
825 |
$return = delete_topics('topic_id', $topic_ids);
|
|
indvdum@0
|
826 |
}
|
|
indvdum@0
|
827 |
else
|
|
indvdum@0
|
828 |
{
|
|
indvdum@0
|
829 |
confirm_box(false, (sizeof($topic_ids) == 1) ? 'DELETE_TOPIC' : 'DELETE_TOPICS', $s_hidden_fields);
|
|
indvdum@0
|
830 |
}
|
|
indvdum@0
|
831 |
|
|
indvdum@0
|
832 |
if (!isset($_REQUEST['quickmod']))
|
|
indvdum@0
|
833 |
{
|
|
indvdum@0
|
834 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
indvdum@0
|
835 |
$redirect = reapply_sid($redirect);
|
|
indvdum@0
|
836 |
$redirect_message = 'PAGE';
|
|
indvdum@0
|
837 |
}
|
|
indvdum@0
|
838 |
else
|
|
indvdum@0
|
839 |
{
|
|
indvdum@0
|
840 |
$redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
|
|
indvdum@0
|
841 |
$redirect_message = 'FORUM';
|
|
indvdum@0
|
842 |
}
|
|
indvdum@0
|
843 |
|
|
indvdum@0
|
844 |
if (!$success_msg)
|
|
indvdum@0
|
845 |
{
|
|
indvdum@0
|
846 |
redirect($redirect);
|
|
indvdum@0
|
847 |
}
|
|
indvdum@0
|
848 |
else
|
|
indvdum@0
|
849 |
{
|
|
indvdum@0
|
850 |
meta_refresh(3, $redirect);
|
|
indvdum@0
|
851 |
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_' . $redirect_message], '<a href="' . $redirect . '">', '</a>'));
|
|
indvdum@0
|
852 |
}
|
|
indvdum@0
|
853 |
}
|
|
indvdum@0
|
854 |
|
|
indvdum@0
|
855 |
/**
|
|
indvdum@0
|
856 |
* Delete Posts
|
|
indvdum@0
|
857 |
*/
|
|
indvdum@0
|
858 |
function mcp_delete_post($post_ids)
|
|
indvdum@0
|
859 |
{
|
|
indvdum@0
|
860 |
global $auth, $user, $db, $phpEx, $phpbb_root_path;
|
|
indvdum@0
|
861 |
|
|
indvdum@0
|
862 |
if (!check_ids($post_ids, POSTS_TABLE, 'post_id', array('m_delete')))
|
|
indvdum@0
|
863 |
{
|
|
indvdum@0
|
864 |
return;
|
|
indvdum@0
|
865 |
}
|
|
indvdum@0
|
866 |
|
|
indvdum@0
|
867 |
$redirect = request_var('redirect', build_url(array('action', 'quickmod')));
|
|
indvdum@0
|
868 |
$forum_id = request_var('f', 0);
|
|
indvdum@0
|
869 |
|
|
indvdum@0
|
870 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
871 |
'post_id_list' => $post_ids,
|
|
indvdum@0
|
872 |
'f' => $forum_id,
|
|
indvdum@0
|
873 |
'action' => 'delete_post',
|
|
indvdum@0
|
874 |
'redirect' => $redirect)
|
|
indvdum@0
|
875 |
);
|
|
indvdum@0
|
876 |
$success_msg = '';
|
|
indvdum@0
|
877 |
|
|
indvdum@0
|
878 |
if (confirm_box(true))
|
|
indvdum@0
|
879 |
{
|
|
indvdum@0
|
880 |
if (!function_exists('delete_posts'))
|
|
indvdum@0
|
881 |
{
|
|
indvdum@0
|
882 |
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|
indvdum@0
|
883 |
}
|
|
indvdum@0
|
884 |
|
|
indvdum@0
|
885 |
// Count the number of topics that are affected
|
|
indvdum@0
|
886 |
// I did not use COUNT(DISTINCT ...) because I remember having problems
|
|
indvdum@0
|
887 |
// with it on older versions of MySQL -- Ashe
|
|
indvdum@0
|
888 |
|
|
indvdum@0
|
889 |
$sql = 'SELECT DISTINCT topic_id
|
|
indvdum@0
|
890 |
FROM ' . POSTS_TABLE . '
|
|
indvdum@0
|
891 |
WHERE ' . $db->sql_in_set('post_id', $post_ids);
|
|
indvdum@0
|
892 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
893 |
|
|
indvdum@0
|
894 |
$topic_id_list = array();
|
|
indvdum@0
|
895 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
896 |
{
|
|
indvdum@0
|
897 |
$topic_id_list[] = $row['topic_id'];
|
|
indvdum@0
|
898 |
}
|
|
indvdum@0
|
899 |
$affected_topics = sizeof($topic_id_list);
|
|
indvdum@0
|
900 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
901 |
|
|
indvdum@0
|
902 |
$post_data = get_post_data($post_ids);
|
|
indvdum@0
|
903 |
|
|
indvdum@0
|
904 |
foreach ($post_data as $id => $row)
|
|
indvdum@0
|
905 |
{
|
|
indvdum@0
|
906 |
$post_username = ($row['poster_id'] == ANONYMOUS && !empty($row['post_username'])) ? $row['post_username'] : $row['username'];
|
|
indvdum@0
|
907 |
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_DELETE_POST', $row['post_subject'], $post_username);
|
|
indvdum@0
|
908 |
}
|
|
indvdum@0
|
909 |
|
|
indvdum@0
|
910 |
// Now delete the posts, topics and forums are automatically resync'ed
|
|
indvdum@0
|
911 |
delete_posts('post_id', $post_ids);
|
|
indvdum@0
|
912 |
|
|
indvdum@0
|
913 |
$sql = 'SELECT COUNT(topic_id) AS topics_left
|
|
indvdum@0
|
914 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
915 |
WHERE ' . $db->sql_in_set('topic_id', $topic_id_list);
|
|
indvdum@0
|
916 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
917 |
|
|
indvdum@0
|
918 |
$deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics;
|
|
indvdum@0
|
919 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
920 |
|
|
indvdum@0
|
921 |
$topic_id = request_var('t', 0);
|
|
indvdum@0
|
922 |
|
|
indvdum@0
|
923 |
// Return links
|
|
indvdum@0
|
924 |
$return_link = array();
|
|
indvdum@0
|
925 |
if ($affected_topics == 1 && !$deleted_topics && $topic_id)
|
|
indvdum@0
|
926 |
{
|
|
indvdum@0
|
927 |
$return_link[] = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") . '">', '</a>');
|
|
indvdum@0
|
928 |
}
|
|
indvdum@0
|
929 |
$return_link[] = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>');
|
|
indvdum@0
|
930 |
|
|
indvdum@0
|
931 |
if (sizeof($post_ids) == 1)
|
|
indvdum@0
|
932 |
{
|
|
indvdum@0
|
933 |
if ($deleted_topics)
|
|
indvdum@0
|
934 |
{
|
|
indvdum@0
|
935 |
// We deleted the only post of a topic, which in turn has
|
|
indvdum@0
|
936 |
// been removed from the database
|
|
indvdum@0
|
937 |
$success_msg = $user->lang['TOPIC_DELETED_SUCCESS'];
|
|
indvdum@0
|
938 |
}
|
|
indvdum@0
|
939 |
else
|
|
indvdum@0
|
940 |
{
|
|
indvdum@0
|
941 |
$success_msg = $user->lang['POST_DELETED_SUCCESS'];
|
|
indvdum@0
|
942 |
}
|
|
indvdum@0
|
943 |
}
|
|
indvdum@0
|
944 |
else
|
|
indvdum@0
|
945 |
{
|
|
indvdum@0
|
946 |
if ($deleted_topics)
|
|
indvdum@0
|
947 |
{
|
|
indvdum@0
|
948 |
// Some of topics disappeared
|
|
indvdum@0
|
949 |
$success_msg = $user->lang['POSTS_DELETED_SUCCESS'] . '<br /><br />' . $user->lang['EMPTY_TOPICS_REMOVED_WARNING'];
|
|
indvdum@0
|
950 |
}
|
|
indvdum@0
|
951 |
else
|
|
indvdum@0
|
952 |
{
|
|
indvdum@0
|
953 |
$success_msg = $user->lang['POSTS_DELETED_SUCCESS'];
|
|
indvdum@0
|
954 |
}
|
|
indvdum@0
|
955 |
}
|
|
indvdum@0
|
956 |
}
|
|
indvdum@0
|
957 |
else
|
|
indvdum@0
|
958 |
{
|
|
indvdum@0
|
959 |
confirm_box(false, (sizeof($post_ids) == 1) ? 'DELETE_POST' : 'DELETE_POSTS', $s_hidden_fields);
|
|
indvdum@0
|
960 |
}
|
|
indvdum@0
|
961 |
|
|
indvdum@0
|
962 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
indvdum@0
|
963 |
$redirect = reapply_sid($redirect);
|
|
indvdum@0
|
964 |
|
|
indvdum@0
|
965 |
if (!$success_msg)
|
|
indvdum@0
|
966 |
{
|
|
indvdum@0
|
967 |
redirect($redirect);
|
|
indvdum@0
|
968 |
}
|
|
indvdum@0
|
969 |
else
|
|
indvdum@0
|
970 |
{
|
|
indvdum@0
|
971 |
if ($affected_topics != 1 || $deleted_topics || !$topic_id)
|
|
indvdum@0
|
972 |
{
|
|
indvdum@0
|
973 |
$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", false);
|
|
indvdum@0
|
974 |
}
|
|
indvdum@0
|
975 |
|
|
indvdum@0
|
976 |
meta_refresh(3, $redirect);
|
|
indvdum@0
|
977 |
trigger_error($success_msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>') . '<br /><br />' . implode('<br /><br />', $return_link));
|
|
indvdum@0
|
978 |
}
|
|
indvdum@0
|
979 |
}
|
|
indvdum@0
|
980 |
|
|
indvdum@0
|
981 |
/**
|
|
indvdum@0
|
982 |
* Fork Topic
|
|
indvdum@0
|
983 |
*/
|
|
indvdum@0
|
984 |
function mcp_fork_topic($topic_ids)
|
|
indvdum@0
|
985 |
{
|
|
indvdum@0
|
986 |
global $auth, $user, $db, $template, $config;
|
|
indvdum@0
|
987 |
global $phpEx, $phpbb_root_path;
|
|
indvdum@0
|
988 |
|
|
indvdum@0
|
989 |
if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
|
|
indvdum@0
|
990 |
{
|
|
indvdum@0
|
991 |
return;
|
|
indvdum@0
|
992 |
}
|
|
indvdum@0
|
993 |
|
|
indvdum@0
|
994 |
$to_forum_id = request_var('to_forum_id', 0);
|
|
indvdum@0
|
995 |
$forum_id = request_var('f', 0);
|
|
indvdum@0
|
996 |
$redirect = request_var('redirect', build_url(array('action', 'quickmod')));
|
|
indvdum@0
|
997 |
$additional_msg = $success_msg = '';
|
|
indvdum@0
|
998 |
|
|
indvdum@0
|
999 |
$s_hidden_fields = build_hidden_fields(array(
|
|
indvdum@0
|
1000 |
'topic_id_list' => $topic_ids,
|
|
indvdum@0
|
1001 |
'f' => $forum_id,
|
|
indvdum@0
|
1002 |
'action' => 'fork',
|
|
indvdum@0
|
1003 |
'redirect' => $redirect)
|
|
indvdum@0
|
1004 |
);
|
|
indvdum@0
|
1005 |
|
|
indvdum@0
|
1006 |
if ($to_forum_id)
|
|
indvdum@0
|
1007 |
{
|
|
indvdum@0
|
1008 |
$forum_data = get_forum_data($to_forum_id, 'f_post');
|
|
indvdum@0
|
1009 |
|
|
indvdum@0
|
1010 |
if (!sizeof($topic_ids))
|
|
indvdum@0
|
1011 |
{
|
|
indvdum@0
|
1012 |
$additional_msg = $user->lang['NO_TOPIC_SELECTED'];
|
|
indvdum@0
|
1013 |
}
|
|
indvdum@0
|
1014 |
else if (!sizeof($forum_data))
|
|
indvdum@0
|
1015 |
{
|
|
indvdum@0
|
1016 |
$additional_msg = $user->lang['FORUM_NOT_EXIST'];
|
|
indvdum@0
|
1017 |
}
|
|
indvdum@0
|
1018 |
else
|
|
indvdum@0
|
1019 |
{
|
|
indvdum@0
|
1020 |
$forum_data = $forum_data[$to_forum_id];
|
|
indvdum@0
|
1021 |
|
|
indvdum@0
|
1022 |
if ($forum_data['forum_type'] != FORUM_POST)
|
|
indvdum@0
|
1023 |
{
|
|
indvdum@0
|
1024 |
$additional_msg = $user->lang['FORUM_NOT_POSTABLE'];
|
|
indvdum@0
|
1025 |
}
|
|
indvdum@0
|
1026 |
else if (!$auth->acl_get('f_post', $to_forum_id))
|
|
indvdum@0
|
1027 |
{
|
|
indvdum@0
|
1028 |
$additional_msg = $user->lang['USER_CANNOT_POST'];
|
|
indvdum@0
|
1029 |
}
|
|
indvdum@0
|
1030 |
}
|
|
indvdum@0
|
1031 |
}
|
|
indvdum@0
|
1032 |
else if (isset($_POST['confirm']))
|
|
indvdum@0
|
1033 |
{
|
|
indvdum@0
|
1034 |
$additional_msg = $user->lang['FORUM_NOT_EXIST'];
|
|
indvdum@0
|
1035 |
}
|
|
indvdum@0
|
1036 |
|
|
indvdum@0
|
1037 |
if ($additional_msg)
|
|
indvdum@0
|
1038 |
{
|
|
indvdum@0
|
1039 |
unset($_POST['confirm']);
|
|
indvdum@0
|
1040 |
unset($_REQUEST['confirm_key']);
|
|
indvdum@0
|
1041 |
}
|
|
indvdum@0
|
1042 |
|
|
indvdum@0
|
1043 |
if (confirm_box(true))
|
|
indvdum@0
|
1044 |
{
|
|
indvdum@0
|
1045 |
$topic_data = get_topic_data($topic_ids, 'f_post');
|
|
indvdum@0
|
1046 |
|
|
indvdum@0
|
1047 |
$total_posts = 0;
|
|
indvdum@0
|
1048 |
$new_topic_id_list = array();
|
|
indvdum@0
|
1049 |
|
|
indvdum@0
|
1050 |
|
|
indvdum@0
|
1051 |
foreach ($topic_data as $topic_id => $topic_row)
|
|
indvdum@0
|
1052 |
{
|
|
indvdum@0
|
1053 |
if (!isset($search_type) && $topic_row['enable_indexing'])
|
|
indvdum@0
|
1054 |
{
|
|
indvdum@0
|
1055 |
// Select the search method and do some additional checks to ensure it can actually be utilised
|
|
indvdum@0
|
1056 |
$search_type = basename($config['search_type']);
|
|
indvdum@0
|
1057 |
|
|
indvdum@0
|
1058 |
if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
|
|
indvdum@0
|
1059 |
{
|
|
indvdum@0
|
1060 |
trigger_error('NO_SUCH_SEARCH_MODULE');
|
|
indvdum@0
|
1061 |
}
|
|
indvdum@0
|
1062 |
|
|
indvdum@0
|
1063 |
if (!class_exists($search_type))
|
|
indvdum@0
|
1064 |
{
|
|
indvdum@0
|
1065 |
include("{$phpbb_root_path}includes/search/$search_type.$phpEx");
|
|
indvdum@0
|
1066 |
}
|
|
indvdum@0
|
1067 |
|
|
indvdum@0
|
1068 |
$error = false;
|
|
indvdum@0
|
1069 |
$search = new $search_type($error);
|
|
indvdum@0
|
1070 |
$search_mode = 'post';
|
|
indvdum@0
|
1071 |
|
|
indvdum@0
|
1072 |
if ($error)
|
|
indvdum@0
|
1073 |
{
|
|
indvdum@0
|
1074 |
trigger_error($error);
|
|
indvdum@0
|
1075 |
}
|
|
indvdum@0
|
1076 |
}
|
|
indvdum@0
|
1077 |
else if (!isset($search_type) && !$topic_row['enable_indexing'])
|
|
indvdum@0
|
1078 |
{
|
|
indvdum@0
|
1079 |
$search_type = false;
|
|
indvdum@0
|
1080 |
}
|
|
indvdum@0
|
1081 |
|
|
indvdum@0
|
1082 |
$sql_ary = array(
|
|
indvdum@0
|
1083 |
'forum_id' => (int) $to_forum_id,
|
|
indvdum@0
|
1084 |
'icon_id' => (int) $topic_row['icon_id'],
|
|
indvdum@0
|
1085 |
'topic_attachment' => (int) $topic_row['topic_attachment'],
|
|
indvdum@0
|
1086 |
'topic_approved' => 1,
|
|
indvdum@0
|
1087 |
'topic_reported' => 0,
|
|
indvdum@0
|
1088 |
'topic_title' => (string) $topic_row['topic_title'],
|
|
indvdum@0
|
1089 |
'topic_poster' => (int) $topic_row['topic_poster'],
|
|
indvdum@0
|
1090 |
'topic_time' => (int) $topic_row['topic_time'],
|
|
indvdum@0
|
1091 |
'topic_replies' => (int) $topic_row['topic_replies_real'],
|
|
indvdum@0
|
1092 |
'topic_replies_real' => (int) $topic_row['topic_replies_real'],
|
|
indvdum@0
|
1093 |
'topic_status' => (int) $topic_row['topic_status'],
|
|
indvdum@0
|
1094 |
'topic_type' => (int) $topic_row['topic_type'],
|
|
indvdum@0
|
1095 |
'topic_first_poster_name' => (string) $topic_row['topic_first_poster_name'],
|
|
indvdum@0
|
1096 |
'topic_last_poster_id' => (int) $topic_row['topic_last_poster_id'],
|
|
indvdum@0
|
1097 |
'topic_last_poster_name' => (string) $topic_row['topic_last_poster_name'],
|
|
indvdum@0
|
1098 |
'topic_last_post_time' => (int) $topic_row['topic_last_post_time'],
|
|
indvdum@0
|
1099 |
'topic_last_view_time' => (int) $topic_row['topic_last_view_time'],
|
|
indvdum@0
|
1100 |
'topic_bumped' => (int) $topic_row['topic_bumped'],
|
|
indvdum@0
|
1101 |
'topic_bumper' => (int) $topic_row['topic_bumper'],
|
|
indvdum@0
|
1102 |
'poll_title' => (string) $topic_row['poll_title'],
|
|
indvdum@0
|
1103 |
'poll_start' => (int) $topic_row['poll_start'],
|
|
indvdum@0
|
1104 |
'poll_length' => (int) $topic_row['poll_length'],
|
|
indvdum@0
|
1105 |
'poll_max_options' => (int) $topic_row['poll_max_options'],
|
|
indvdum@0
|
1106 |
'poll_vote_change' => (int) $topic_row['poll_vote_change'],
|
|
indvdum@0
|
1107 |
);
|
|
indvdum@0
|
1108 |
|
|
indvdum@0
|
1109 |
$db->sql_query('INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
|
indvdum@0
|
1110 |
$new_topic_id = $db->sql_nextid();
|
|
indvdum@0
|
1111 |
$new_topic_id_list[$topic_id] = $new_topic_id;
|
|
indvdum@0
|
1112 |
|
|
indvdum@0
|
1113 |
if ($topic_row['poll_start'])
|
|
indvdum@0
|
1114 |
{
|
|
indvdum@0
|
1115 |
$poll_rows = array();
|
|
indvdum@0
|
1116 |
|
|
indvdum@0
|
1117 |
$sql = 'SELECT *
|
|
indvdum@0
|
1118 |
FROM ' . POLL_OPTIONS_TABLE . "
|
|
indvdum@0
|
1119 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
1120 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1121 |
|
|
indvdum@0
|
1122 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1123 |
{
|
|
indvdum@0
|
1124 |
$sql_ary = array(
|
|
indvdum@0
|
1125 |
'poll_option_id' => (int) $row['poll_option_id'],
|
|
indvdum@0
|
1126 |
'topic_id' => (int) $new_topic_id,
|
|
indvdum@0
|
1127 |
'poll_option_text' => (string) $row['poll_option_text'],
|
|
indvdum@0
|
1128 |
'poll_option_total' => 0
|
|
indvdum@0
|
1129 |
);
|
|
indvdum@0
|
1130 |
|
|
indvdum@0
|
1131 |
$db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
|
indvdum@0
|
1132 |
}
|
|
indvdum@0
|
1133 |
}
|
|
indvdum@0
|
1134 |
|
|
indvdum@0
|
1135 |
$sql = 'SELECT *
|
|
indvdum@0
|
1136 |
FROM ' . POSTS_TABLE . "
|
|
indvdum@0
|
1137 |
WHERE topic_id = $topic_id
|
|
indvdum@0
|
1138 |
ORDER BY post_time ASC";
|
|
indvdum@0
|
1139 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1140 |
|
|
indvdum@0
|
1141 |
$post_rows = array();
|
|
indvdum@0
|
1142 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1143 |
{
|
|
indvdum@0
|
1144 |
$post_rows[] = $row;
|
|
indvdum@0
|
1145 |
}
|
|
indvdum@0
|
1146 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1147 |
|
|
indvdum@0
|
1148 |
if (!sizeof($post_rows))
|
|
indvdum@0
|
1149 |
{
|
|
indvdum@0
|
1150 |
continue;
|
|
indvdum@0
|
1151 |
}
|
|
indvdum@0
|
1152 |
|
|
indvdum@0
|
1153 |
$total_posts += sizeof($post_rows);
|
|
indvdum@0
|
1154 |
foreach ($post_rows as $row)
|
|
indvdum@0
|
1155 |
{
|
|
indvdum@0
|
1156 |
$sql_ary = array(
|
|
indvdum@0
|
1157 |
'topic_id' => (int) $new_topic_id,
|
|
indvdum@0
|
1158 |
'forum_id' => (int) $to_forum_id,
|
|
indvdum@0
|
1159 |
'poster_id' => (int) $row['poster_id'],
|
|
indvdum@0
|
1160 |
'icon_id' => (int) $row['icon_id'],
|
|
indvdum@0
|
1161 |
'poster_ip' => (string) $row['poster_ip'],
|
|
indvdum@0
|
1162 |
'post_time' => (int) $row['post_time'],
|
|
indvdum@0
|
1163 |
'post_approved' => 1,
|
|
indvdum@0
|
1164 |
'post_reported' => 0,
|
|
indvdum@0
|
1165 |
'enable_bbcode' => (int) $row['enable_bbcode'],
|
|
indvdum@0
|
1166 |
'enable_smilies' => (int) $row['enable_smilies'],
|
|
indvdum@0
|
1167 |
'enable_magic_url' => (int) $row['enable_magic_url'],
|
|
indvdum@0
|
1168 |
'enable_sig' => (int) $row['enable_sig'],
|
|
indvdum@0
|
1169 |
'post_username' => (string) $row['post_username'],
|
|
indvdum@0
|
1170 |
'post_subject' => (string) $row['post_subject'],
|
|
indvdum@0
|
1171 |
'post_text' => (string) $row['post_text'],
|
|
indvdum@0
|
1172 |
'post_edit_reason' => (string) $row['post_edit_reason'],
|
|
indvdum@0
|
1173 |
'post_edit_user' => (int) $row['post_edit_user'],
|
|
indvdum@0
|
1174 |
'post_checksum' => (string) $row['post_checksum'],
|
|
indvdum@0
|
1175 |
'post_attachment' => (int) $row['post_attachment'],
|
|
indvdum@0
|
1176 |
'bbcode_bitfield' => $row['bbcode_bitfield'],
|
|
indvdum@0
|
1177 |
'bbcode_uid' => (string) $row['bbcode_uid'],
|
|
indvdum@0
|
1178 |
'post_edit_time' => (int) $row['post_edit_time'],
|
|
indvdum@0
|
1179 |
'post_edit_count' => (int) $row['post_edit_count'],
|
|
indvdum@0
|
1180 |
'post_edit_locked' => (int) $row['post_edit_locked'],
|
|
indvdum@0
|
1181 |
'post_postcount' => 0,
|
|
indvdum@0
|
1182 |
);
|
|
indvdum@0
|
1183 |
|
|
indvdum@0
|
1184 |
$db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
|
indvdum@0
|
1185 |
$new_post_id = $db->sql_nextid();
|
|
indvdum@0
|
1186 |
|
|
indvdum@0
|
1187 |
// Copy whether the topic is dotted
|
|
indvdum@0
|
1188 |
markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']);
|
|
indvdum@0
|
1189 |
|
|
indvdum@0
|
1190 |
if (!empty($search_type))
|
|
indvdum@0
|
1191 |
{
|
|
indvdum@0
|
1192 |
$search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id);
|
|
indvdum@0
|
1193 |
$search_mode = 'reply'; // After one we index replies
|
|
indvdum@0
|
1194 |
}
|
|
indvdum@0
|
1195 |
|
|
indvdum@0
|
1196 |
// Copy Attachments
|
|
indvdum@0
|
1197 |
if ($row['post_attachment'])
|
|
indvdum@0
|
1198 |
{
|
|
indvdum@0
|
1199 |
$sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . "
|
|
indvdum@0
|
1200 |
WHERE post_msg_id = {$row['post_id']}
|
|
indvdum@0
|
1201 |
AND topic_id = $topic_id
|
|
indvdum@0
|
1202 |
AND in_message = 0";
|
|
indvdum@0
|
1203 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1204 |
|
|
indvdum@0
|
1205 |
$sql_ary = array();
|
|
indvdum@0
|
1206 |
while ($attach_row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1207 |
{
|
|
indvdum@0
|
1208 |
$sql_ary[] = array(
|
|
indvdum@0
|
1209 |
'post_msg_id' => (int) $new_post_id,
|
|
indvdum@0
|
1210 |
'topic_id' => (int) $new_topic_id,
|
|
indvdum@0
|
1211 |
'in_message' => 0,
|
|
indvdum@0
|
1212 |
'is_orphan' => (int) $attach_row['is_orphan'],
|
|
indvdum@0
|
1213 |
'poster_id' => (int) $attach_row['poster_id'],
|
|
indvdum@0
|
1214 |
'physical_filename' => (string) utf8_basename($attach_row['physical_filename']),
|
|
indvdum@0
|
1215 |
'real_filename' => (string) utf8_basename($attach_row['real_filename']),
|
|
indvdum@0
|
1216 |
'download_count' => (int) $attach_row['download_count'],
|
|
indvdum@0
|
1217 |
'attach_comment' => (string) $attach_row['attach_comment'],
|
|
indvdum@0
|
1218 |
'extension' => (string) $attach_row['extension'],
|
|
indvdum@0
|
1219 |
'mimetype' => (string) $attach_row['mimetype'],
|
|
indvdum@0
|
1220 |
'filesize' => (int) $attach_row['filesize'],
|
|
indvdum@0
|
1221 |
'filetime' => (int) $attach_row['filetime'],
|
|
indvdum@0
|
1222 |
'thumbnail' => (int) $attach_row['thumbnail']
|
|
indvdum@0
|
1223 |
);
|
|
indvdum@0
|
1224 |
}
|
|
indvdum@0
|
1225 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1226 |
|
|
indvdum@0
|
1227 |
if (sizeof($sql_ary))
|
|
indvdum@0
|
1228 |
{
|
|
indvdum@0
|
1229 |
$db->sql_multi_insert(ATTACHMENTS_TABLE, $sql_ary);
|
|
indvdum@0
|
1230 |
}
|
|
indvdum@0
|
1231 |
}
|
|
indvdum@0
|
1232 |
}
|
|
indvdum@0
|
1233 |
|
|
indvdum@0
|
1234 |
$sql = 'SELECT user_id, notify_status
|
|
indvdum@0
|
1235 |
FROM ' . TOPICS_WATCH_TABLE . '
|
|
indvdum@0
|
1236 |
WHERE topic_id = ' . $topic_id;
|
|
indvdum@0
|
1237 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1238 |
|
|
indvdum@0
|
1239 |
$sql_ary = array();
|
|
indvdum@0
|
1240 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1241 |
{
|
|
indvdum@0
|
1242 |
$sql_ary[] = array(
|
|
indvdum@0
|
1243 |
'topic_id' => (int) $new_topic_id,
|
|
indvdum@0
|
1244 |
'user_id' => (int) $row['user_id'],
|
|
indvdum@0
|
1245 |
'notify_status' => (int) $row['notify_status'],
|
|
indvdum@0
|
1246 |
);
|
|
indvdum@0
|
1247 |
}
|
|
indvdum@0
|
1248 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1249 |
|
|
indvdum@0
|
1250 |
if (sizeof($sql_ary))
|
|
indvdum@0
|
1251 |
{
|
|
indvdum@0
|
1252 |
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
|
|
indvdum@0
|
1253 |
}
|
|
indvdum@0
|
1254 |
}
|
|
indvdum@0
|
1255 |
|
|
indvdum@0
|
1256 |
// Sync new topics, parent forums and board stats
|
|
indvdum@0
|
1257 |
sync('topic', 'topic_id', $new_topic_id_list);
|
|
indvdum@0
|
1258 |
|
|
indvdum@0
|
1259 |
$sync_sql = array();
|
|
indvdum@0
|
1260 |
|
|
indvdum@0
|
1261 |
$sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . $total_posts;
|
|
indvdum@0
|
1262 |
$sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . sizeof($new_topic_id_list);
|
|
indvdum@0
|
1263 |
$sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . sizeof($new_topic_id_list);
|
|
indvdum@0
|
1264 |
|
|
indvdum@0
|
1265 |
foreach ($sync_sql as $forum_id_key => $array)
|
|
indvdum@0
|
1266 |
{
|
|
indvdum@0
|
1267 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1268 |
SET ' . implode(', ', $array) . '
|
|
indvdum@0
|
1269 |
WHERE forum_id = ' . $forum_id_key;
|
|
indvdum@0
|
1270 |
$db->sql_query($sql);
|
|
indvdum@0
|
1271 |
}
|
|
indvdum@0
|
1272 |
|
|
indvdum@0
|
1273 |
sync('forum', 'forum_id', $to_forum_id);
|
|
indvdum@0
|
1274 |
set_config_count('num_topics', sizeof($new_topic_id_list), true);
|
|
indvdum@0
|
1275 |
set_config_count('num_posts', $total_posts, true);
|
|
indvdum@0
|
1276 |
|
|
indvdum@0
|
1277 |
foreach ($new_topic_id_list as $topic_id => $new_topic_id)
|
|
indvdum@0
|
1278 |
{
|
|
indvdum@0
|
1279 |
add_log('mod', $to_forum_id, $new_topic_id, 'LOG_FORK', $topic_row['forum_name']);
|
|
indvdum@0
|
1280 |
}
|
|
indvdum@0
|
1281 |
|
|
indvdum@0
|
1282 |
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_FORKED_SUCCESS' : 'TOPICS_FORKED_SUCCESS';
|
|
indvdum@0
|
1283 |
}
|
|
indvdum@0
|
1284 |
else
|
|
indvdum@0
|
1285 |
{
|
|
indvdum@0
|
1286 |
$template->assign_vars(array(
|
|
indvdum@0
|
1287 |
'S_FORUM_SELECT' => make_forum_select($to_forum_id, false, false, true, true, true),
|
|
indvdum@0
|
1288 |
'S_CAN_LEAVE_SHADOW' => false,
|
|
indvdum@0
|
1289 |
'ADDITIONAL_MSG' => $additional_msg)
|
|
indvdum@0
|
1290 |
);
|
|
indvdum@0
|
1291 |
|
|
indvdum@0
|
1292 |
confirm_box(false, 'FORK_TOPIC' . ((sizeof($topic_ids) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_move.html');
|
|
indvdum@0
|
1293 |
}
|
|
indvdum@0
|
1294 |
|
|
indvdum@0
|
1295 |
$redirect = request_var('redirect', "index.$phpEx");
|
|
indvdum@0
|
1296 |
$redirect = reapply_sid($redirect);
|
|
indvdum@0
|
1297 |
|
|
indvdum@0
|
1298 |
if (!$success_msg)
|
|
indvdum@0
|
1299 |
{
|
|
indvdum@0
|
1300 |
redirect($redirect);
|
|
indvdum@0
|
1301 |
}
|
|
indvdum@0
|
1302 |
else
|
|
indvdum@0
|
1303 |
{
|
|
indvdum@0
|
1304 |
$redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
|
|
indvdum@0
|
1305 |
meta_refresh(3, $redirect_url);
|
|
indvdum@0
|
1306 |
$return_link = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>');
|
|
indvdum@0
|
1307 |
|
|
indvdum@0
|
1308 |
if ($forum_id != $to_forum_id)
|
|
indvdum@0
|
1309 |
{
|
|
indvdum@0
|
1310 |
$return_link .= '<br /><br />' . sprintf($user->lang['RETURN_NEW_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $to_forum_id) . '">', '</a>');
|
|
indvdum@0
|
1311 |
}
|
|
indvdum@0
|
1312 |
|
|
indvdum@0
|
1313 |
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
|
|
indvdum@0
|
1314 |
}
|
|
indvdum@0
|
1315 |
}
|
|
indvdum@0
|
1316 |
|
|
indvdum@0
|
1317 |
?> |