|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package acp
|
|
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 |
* @package acp
|
|
indvdum@0
|
21 |
*/
|
|
indvdum@0
|
22 |
class acp_forums
|
|
indvdum@0
|
23 |
{
|
|
indvdum@0
|
24 |
var $u_action;
|
|
indvdum@0
|
25 |
var $parent_id = 0;
|
|
indvdum@0
|
26 |
|
|
indvdum@0
|
27 |
function main($id, $mode)
|
|
indvdum@0
|
28 |
{
|
|
indvdum@0
|
29 |
global $db, $user, $auth, $template, $cache;
|
|
indvdum@0
|
30 |
global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
31 |
|
|
indvdum@0
|
32 |
$user->add_lang('acp/forums');
|
|
indvdum@0
|
33 |
$this->tpl_name = 'acp_forums';
|
|
indvdum@0
|
34 |
$this->page_title = 'ACP_MANAGE_FORUMS';
|
|
indvdum@0
|
35 |
|
|
indvdum@0
|
36 |
$form_key = 'acp_forums';
|
|
indvdum@0
|
37 |
add_form_key($form_key);
|
|
indvdum@0
|
38 |
|
|
indvdum@0
|
39 |
$action = request_var('action', '');
|
|
indvdum@0
|
40 |
$update = (isset($_POST['update'])) ? true : false;
|
|
indvdum@0
|
41 |
$forum_id = request_var('f', 0);
|
|
indvdum@0
|
42 |
|
|
indvdum@0
|
43 |
$this->parent_id = request_var('parent_id', 0);
|
|
indvdum@0
|
44 |
$forum_data = $errors = array();
|
|
indvdum@0
|
45 |
if ($update && !check_form_key($form_key))
|
|
indvdum@0
|
46 |
{
|
|
indvdum@0
|
47 |
$update = false;
|
|
indvdum@0
|
48 |
$errors[] = $user->lang['FORM_INVALID'];
|
|
indvdum@0
|
49 |
}
|
|
indvdum@0
|
50 |
|
|
indvdum@0
|
51 |
// Check additional permissions
|
|
indvdum@0
|
52 |
switch ($action)
|
|
indvdum@0
|
53 |
{
|
|
indvdum@0
|
54 |
case 'progress_bar':
|
|
indvdum@0
|
55 |
$start = request_var('start', 0);
|
|
indvdum@0
|
56 |
$total = request_var('total', 0);
|
|
indvdum@0
|
57 |
|
|
indvdum@0
|
58 |
$this->display_progress_bar($start, $total);
|
|
indvdum@0
|
59 |
exit;
|
|
indvdum@0
|
60 |
break;
|
|
indvdum@0
|
61 |
|
|
indvdum@0
|
62 |
case 'delete':
|
|
indvdum@0
|
63 |
|
|
indvdum@0
|
64 |
if (!$auth->acl_get('a_forumdel'))
|
|
indvdum@0
|
65 |
{
|
|
indvdum@0
|
66 |
trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
67 |
}
|
|
indvdum@0
|
68 |
|
|
indvdum@0
|
69 |
break;
|
|
indvdum@0
|
70 |
|
|
indvdum@0
|
71 |
case 'add':
|
|
indvdum@0
|
72 |
|
|
indvdum@0
|
73 |
if (!$auth->acl_get('a_forumadd'))
|
|
indvdum@0
|
74 |
{
|
|
indvdum@0
|
75 |
trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
76 |
}
|
|
indvdum@0
|
77 |
|
|
indvdum@0
|
78 |
break;
|
|
indvdum@0
|
79 |
}
|
|
indvdum@0
|
80 |
|
|
indvdum@0
|
81 |
// Major routines
|
|
indvdum@0
|
82 |
if ($update)
|
|
indvdum@0
|
83 |
{
|
|
indvdum@0
|
84 |
switch ($action)
|
|
indvdum@0
|
85 |
{
|
|
indvdum@0
|
86 |
case 'delete':
|
|
indvdum@0
|
87 |
$action_subforums = request_var('action_subforums', '');
|
|
indvdum@0
|
88 |
$subforums_to_id = request_var('subforums_to_id', 0);
|
|
indvdum@0
|
89 |
$action_posts = request_var('action_posts', '');
|
|
indvdum@0
|
90 |
$posts_to_id = request_var('posts_to_id', 0);
|
|
indvdum@0
|
91 |
|
|
indvdum@0
|
92 |
$errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id);
|
|
indvdum@0
|
93 |
|
|
indvdum@0
|
94 |
if (sizeof($errors))
|
|
indvdum@0
|
95 |
{
|
|
indvdum@0
|
96 |
break;
|
|
indvdum@0
|
97 |
}
|
|
indvdum@0
|
98 |
|
|
indvdum@0
|
99 |
$auth->acl_clear_prefetch();
|
|
indvdum@0
|
100 |
$cache->destroy('sql', FORUMS_TABLE);
|
|
indvdum@0
|
101 |
|
|
indvdum@0
|
102 |
trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id));
|
|
indvdum@0
|
103 |
|
|
indvdum@0
|
104 |
break;
|
|
indvdum@0
|
105 |
|
|
indvdum@0
|
106 |
case 'edit':
|
|
indvdum@0
|
107 |
$forum_data = array(
|
|
indvdum@0
|
108 |
'forum_id' => $forum_id
|
|
indvdum@0
|
109 |
);
|
|
indvdum@0
|
110 |
|
|
indvdum@0
|
111 |
// No break here
|
|
indvdum@0
|
112 |
|
|
indvdum@0
|
113 |
case 'add':
|
|
indvdum@0
|
114 |
|
|
indvdum@0
|
115 |
$forum_data += array(
|
|
indvdum@0
|
116 |
'parent_id' => request_var('forum_parent_id', $this->parent_id),
|
|
indvdum@0
|
117 |
'forum_type' => request_var('forum_type', FORUM_POST),
|
|
indvdum@0
|
118 |
'type_action' => request_var('type_action', ''),
|
|
indvdum@0
|
119 |
'forum_status' => request_var('forum_status', ITEM_UNLOCKED),
|
|
indvdum@0
|
120 |
'forum_parents' => '',
|
|
indvdum@0
|
121 |
'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)),
|
|
indvdum@0
|
122 |
'forum_link' => request_var('forum_link', ''),
|
|
indvdum@0
|
123 |
'forum_link_track' => request_var('forum_link_track', false),
|
|
indvdum@0
|
124 |
'forum_desc' => utf8_normalize_nfc(request_var('forum_desc', '', true)),
|
|
indvdum@0
|
125 |
'forum_desc_uid' => '',
|
|
indvdum@0
|
126 |
'forum_desc_options' => 7,
|
|
indvdum@0
|
127 |
'forum_desc_bitfield' => '',
|
|
indvdum@0
|
128 |
'forum_rules' => utf8_normalize_nfc(request_var('forum_rules', '', true)),
|
|
indvdum@0
|
129 |
'forum_rules_uid' => '',
|
|
indvdum@0
|
130 |
'forum_rules_options' => 7,
|
|
indvdum@0
|
131 |
'forum_rules_bitfield' => '',
|
|
indvdum@0
|
132 |
'forum_rules_link' => request_var('forum_rules_link', ''),
|
|
indvdum@0
|
133 |
'forum_image' => request_var('forum_image', ''),
|
|
indvdum@0
|
134 |
'forum_style' => request_var('forum_style', 0),
|
|
indvdum@0
|
135 |
'display_subforum_list' => request_var('display_subforum_list', false),
|
|
indvdum@0
|
136 |
'display_on_index' => request_var('display_on_index', false),
|
|
indvdum@0
|
137 |
'forum_topics_per_page' => request_var('topics_per_page', 0),
|
|
indvdum@0
|
138 |
'enable_indexing' => request_var('enable_indexing', true),
|
|
indvdum@0
|
139 |
'enable_icons' => request_var('enable_icons', false),
|
|
indvdum@0
|
140 |
'enable_prune' => request_var('enable_prune', false),
|
|
indvdum@0
|
141 |
'enable_post_review' => request_var('enable_post_review', true),
|
|
indvdum@0
|
142 |
'enable_quick_reply' => request_var('enable_quick_reply', false),
|
|
indvdum@0
|
143 |
'prune_days' => request_var('prune_days', 7),
|
|
indvdum@0
|
144 |
'prune_viewed' => request_var('prune_viewed', 7),
|
|
indvdum@0
|
145 |
'prune_freq' => request_var('prune_freq', 1),
|
|
indvdum@0
|
146 |
'prune_old_polls' => request_var('prune_old_polls', false),
|
|
indvdum@0
|
147 |
'prune_announce' => request_var('prune_announce', false),
|
|
indvdum@0
|
148 |
'prune_sticky' => request_var('prune_sticky', false),
|
|
indvdum@0
|
149 |
'forum_password' => request_var('forum_password', '', true),
|
|
indvdum@0
|
150 |
'forum_password_confirm'=> request_var('forum_password_confirm', '', true),
|
|
indvdum@0
|
151 |
'forum_password_unset' => request_var('forum_password_unset', false),
|
|
indvdum@0
|
152 |
);
|
|
indvdum@0
|
153 |
|
|
indvdum@0
|
154 |
// On add, add empty forum_options... else do not consider it (not updating it)
|
|
indvdum@0
|
155 |
if ($action == 'add')
|
|
indvdum@0
|
156 |
{
|
|
indvdum@0
|
157 |
$forum_data['forum_options'] = 0;
|
|
indvdum@0
|
158 |
}
|
|
indvdum@0
|
159 |
|
|
indvdum@0
|
160 |
// Use link_display_on_index setting if forum type is link
|
|
indvdum@0
|
161 |
if ($forum_data['forum_type'] == FORUM_LINK)
|
|
indvdum@0
|
162 |
{
|
|
indvdum@0
|
163 |
$forum_data['display_on_index'] = request_var('link_display_on_index', false);
|
|
indvdum@0
|
164 |
}
|
|
indvdum@0
|
165 |
|
|
indvdum@0
|
166 |
// Linked forums and categories are not able to be locked...
|
|
indvdum@0
|
167 |
if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT)
|
|
indvdum@0
|
168 |
{
|
|
indvdum@0
|
169 |
$forum_data['forum_status'] = ITEM_UNLOCKED;
|
|
indvdum@0
|
170 |
}
|
|
indvdum@0
|
171 |
|
|
indvdum@0
|
172 |
$forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', false);
|
|
indvdum@0
|
173 |
|
|
indvdum@0
|
174 |
// Get data for forum rules if specified...
|
|
indvdum@0
|
175 |
if ($forum_data['forum_rules'])
|
|
indvdum@0
|
176 |
{
|
|
indvdum@0
|
177 |
generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_parse_bbcode', false), request_var('rules_parse_urls', false), request_var('rules_parse_smilies', false));
|
|
indvdum@0
|
178 |
}
|
|
indvdum@0
|
179 |
|
|
indvdum@0
|
180 |
// Get data for forum description if specified
|
|
indvdum@0
|
181 |
if ($forum_data['forum_desc'])
|
|
indvdum@0
|
182 |
{
|
|
indvdum@0
|
183 |
generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_parse_bbcode', false), request_var('desc_parse_urls', false), request_var('desc_parse_smilies', false));
|
|
indvdum@0
|
184 |
}
|
|
indvdum@0
|
185 |
|
|
indvdum@0
|
186 |
$errors = $this->update_forum_data($forum_data);
|
|
indvdum@0
|
187 |
|
|
indvdum@0
|
188 |
if (!sizeof($errors))
|
|
indvdum@0
|
189 |
{
|
|
indvdum@0
|
190 |
$forum_perm_from = request_var('forum_perm_from', 0);
|
|
indvdum@0
|
191 |
$cache->destroy('sql', FORUMS_TABLE);
|
|
indvdum@0
|
192 |
|
|
indvdum@0
|
193 |
$copied_permissions = false;
|
|
indvdum@0
|
194 |
// Copy permissions?
|
|
indvdum@0
|
195 |
if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] &&
|
|
indvdum@0
|
196 |
($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))))
|
|
indvdum@0
|
197 |
{
|
|
indvdum@0
|
198 |
copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
|
|
indvdum@0
|
199 |
cache_moderators();
|
|
indvdum@0
|
200 |
$copied_permissions = true;
|
|
indvdum@0
|
201 |
}
|
|
indvdum@0
|
202 |
/* Commented out because of questionable UI workflow - re-visit for 3.0.7
|
|
indvdum@0
|
203 |
else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))
|
|
indvdum@0
|
204 |
{
|
|
indvdum@0
|
205 |
$this->copy_permission_page($forum_data);
|
|
indvdum@0
|
206 |
return;
|
|
indvdum@0
|
207 |
}
|
|
indvdum@0
|
208 |
*/
|
|
indvdum@0
|
209 |
$auth->acl_clear_prefetch();
|
|
indvdum@0
|
210 |
|
|
indvdum@0
|
211 |
$acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id'];
|
|
indvdum@0
|
212 |
|
|
indvdum@0
|
213 |
$message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];
|
|
indvdum@0
|
214 |
|
|
indvdum@0
|
215 |
// redirect directly to permission settings screen if authed
|
|
indvdum@0
|
216 |
if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth'))
|
|
indvdum@0
|
217 |
{
|
|
indvdum@0
|
218 |
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
|
|
indvdum@0
|
219 |
|
|
indvdum@0
|
220 |
meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url));
|
|
indvdum@0
|
221 |
}
|
|
indvdum@0
|
222 |
|
|
indvdum@0
|
223 |
trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id));
|
|
indvdum@0
|
224 |
}
|
|
indvdum@0
|
225 |
|
|
indvdum@0
|
226 |
break;
|
|
indvdum@0
|
227 |
}
|
|
indvdum@0
|
228 |
}
|
|
indvdum@0
|
229 |
|
|
indvdum@0
|
230 |
switch ($action)
|
|
indvdum@0
|
231 |
{
|
|
indvdum@0
|
232 |
case 'move_up':
|
|
indvdum@0
|
233 |
case 'move_down':
|
|
indvdum@0
|
234 |
|
|
indvdum@0
|
235 |
if (!$forum_id)
|
|
indvdum@0
|
236 |
{
|
|
indvdum@0
|
237 |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
238 |
}
|
|
indvdum@0
|
239 |
|
|
indvdum@0
|
240 |
$sql = 'SELECT *
|
|
indvdum@0
|
241 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
242 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
243 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
244 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
245 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
246 |
|
|
indvdum@0
|
247 |
if (!$row)
|
|
indvdum@0
|
248 |
{
|
|
indvdum@0
|
249 |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
250 |
}
|
|
indvdum@0
|
251 |
|
|
indvdum@0
|
252 |
$move_forum_name = $this->move_forum_by($row, $action, 1);
|
|
indvdum@0
|
253 |
|
|
indvdum@0
|
254 |
if ($move_forum_name !== false)
|
|
indvdum@0
|
255 |
{
|
|
indvdum@0
|
256 |
add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name);
|
|
indvdum@0
|
257 |
$cache->destroy('sql', FORUMS_TABLE);
|
|
indvdum@0
|
258 |
}
|
|
indvdum@0
|
259 |
|
|
indvdum@0
|
260 |
break;
|
|
indvdum@0
|
261 |
|
|
indvdum@0
|
262 |
case 'sync':
|
|
indvdum@0
|
263 |
if (!$forum_id)
|
|
indvdum@0
|
264 |
{
|
|
indvdum@0
|
265 |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
266 |
}
|
|
indvdum@0
|
267 |
|
|
indvdum@0
|
268 |
@set_time_limit(0);
|
|
indvdum@0
|
269 |
|
|
indvdum@0
|
270 |
$sql = 'SELECT forum_name, forum_topics_real
|
|
indvdum@0
|
271 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
272 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
273 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
274 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
275 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
276 |
|
|
indvdum@0
|
277 |
if (!$row)
|
|
indvdum@0
|
278 |
{
|
|
indvdum@0
|
279 |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
280 |
}
|
|
indvdum@0
|
281 |
|
|
indvdum@0
|
282 |
if ($row['forum_topics_real'])
|
|
indvdum@0
|
283 |
{
|
|
indvdum@0
|
284 |
$sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id
|
|
indvdum@0
|
285 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
286 |
WHERE forum_id = ' . $forum_id;
|
|
indvdum@0
|
287 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
288 |
$row2 = $db->sql_fetchrow($result);
|
|
indvdum@0
|
289 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
290 |
|
|
indvdum@0
|
291 |
// Typecast to int if there is no data available
|
|
indvdum@0
|
292 |
$row2['min_topic_id'] = (int) $row2['min_topic_id'];
|
|
indvdum@0
|
293 |
$row2['max_topic_id'] = (int) $row2['max_topic_id'];
|
|
indvdum@0
|
294 |
|
|
indvdum@0
|
295 |
$start = request_var('start', $row2['min_topic_id']);
|
|
indvdum@0
|
296 |
|
|
indvdum@0
|
297 |
$batch_size = 2000;
|
|
indvdum@0
|
298 |
$end = $start + $batch_size;
|
|
indvdum@0
|
299 |
|
|
indvdum@0
|
300 |
// Sync all topics in batch mode...
|
|
indvdum@0
|
301 |
sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false);
|
|
indvdum@0
|
302 |
sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true);
|
|
indvdum@0
|
303 |
|
|
indvdum@0
|
304 |
if ($end < $row2['max_topic_id'])
|
|
indvdum@0
|
305 |
{
|
|
indvdum@0
|
306 |
// We really need to find a way of showing statistics... no progress here
|
|
indvdum@0
|
307 |
$sql = 'SELECT COUNT(topic_id) as num_topics
|
|
indvdum@0
|
308 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
309 |
WHERE forum_id = ' . $forum_id . '
|
|
indvdum@0
|
310 |
AND topic_id BETWEEN ' . $start . ' AND ' . $end;
|
|
indvdum@0
|
311 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
312 |
$topics_done = request_var('topics_done', 0) + (int) $db->sql_fetchfield('num_topics');
|
|
indvdum@0
|
313 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
314 |
|
|
indvdum@0
|
315 |
$start += $batch_size;
|
|
indvdum@0
|
316 |
|
|
indvdum@0
|
317 |
$url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['forum_topics_real']}";
|
|
indvdum@0
|
318 |
|
|
indvdum@0
|
319 |
meta_refresh(0, $url);
|
|
indvdum@0
|
320 |
|
|
indvdum@0
|
321 |
$template->assign_vars(array(
|
|
indvdum@0
|
322 |
'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}",
|
|
indvdum@0
|
323 |
'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}"),
|
|
indvdum@0
|
324 |
'S_CONTINUE_SYNC' => true,
|
|
indvdum@0
|
325 |
'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['forum_topics_real']))
|
|
indvdum@0
|
326 |
);
|
|
indvdum@0
|
327 |
|
|
indvdum@0
|
328 |
return;
|
|
indvdum@0
|
329 |
}
|
|
indvdum@0
|
330 |
}
|
|
indvdum@0
|
331 |
|
|
indvdum@0
|
332 |
$url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_forum";
|
|
indvdum@0
|
333 |
meta_refresh(0, $url);
|
|
indvdum@0
|
334 |
|
|
indvdum@0
|
335 |
$template->assign_vars(array(
|
|
indvdum@0
|
336 |
'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar',
|
|
indvdum@0
|
337 |
'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'),
|
|
indvdum@0
|
338 |
'S_CONTINUE_SYNC' => true,
|
|
indvdum@0
|
339 |
'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['forum_topics_real']))
|
|
indvdum@0
|
340 |
);
|
|
indvdum@0
|
341 |
|
|
indvdum@0
|
342 |
return;
|
|
indvdum@0
|
343 |
|
|
indvdum@0
|
344 |
break;
|
|
indvdum@0
|
345 |
|
|
indvdum@0
|
346 |
case 'sync_forum':
|
|
indvdum@0
|
347 |
|
|
indvdum@0
|
348 |
$sql = 'SELECT forum_name, forum_type
|
|
indvdum@0
|
349 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
350 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
351 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
352 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
353 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
354 |
|
|
indvdum@0
|
355 |
if (!$row)
|
|
indvdum@0
|
356 |
{
|
|
indvdum@0
|
357 |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
358 |
}
|
|
indvdum@0
|
359 |
|
|
indvdum@0
|
360 |
sync('forum', 'forum_id', $forum_id, false, true);
|
|
indvdum@0
|
361 |
|
|
indvdum@0
|
362 |
add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']);
|
|
indvdum@0
|
363 |
$cache->destroy('sql', FORUMS_TABLE);
|
|
indvdum@0
|
364 |
|
|
indvdum@0
|
365 |
$template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name']));
|
|
indvdum@0
|
366 |
|
|
indvdum@0
|
367 |
break;
|
|
indvdum@0
|
368 |
|
|
indvdum@0
|
369 |
case 'add':
|
|
indvdum@0
|
370 |
case 'edit':
|
|
indvdum@0
|
371 |
|
|
indvdum@0
|
372 |
if ($update)
|
|
indvdum@0
|
373 |
{
|
|
indvdum@0
|
374 |
$forum_data['forum_flags'] = 0;
|
|
indvdum@0
|
375 |
$forum_data['forum_flags'] += (request_var('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0;
|
|
indvdum@0
|
376 |
$forum_data['forum_flags'] += (request_var('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0;
|
|
indvdum@0
|
377 |
$forum_data['forum_flags'] += (request_var('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
|
|
indvdum@0
|
378 |
$forum_data['forum_flags'] += (request_var('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0;
|
|
indvdum@0
|
379 |
$forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;
|
|
indvdum@0
|
380 |
$forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0;
|
|
indvdum@0
|
381 |
$forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0;
|
|
indvdum@0
|
382 |
}
|
|
indvdum@0
|
383 |
|
|
indvdum@0
|
384 |
// Show form to create/modify a forum
|
|
indvdum@0
|
385 |
if ($action == 'edit')
|
|
indvdum@0
|
386 |
{
|
|
indvdum@0
|
387 |
$this->page_title = 'EDIT_FORUM';
|
|
indvdum@0
|
388 |
$row = $this->get_forum_info($forum_id);
|
|
indvdum@0
|
389 |
$old_forum_type = $row['forum_type'];
|
|
indvdum@0
|
390 |
|
|
indvdum@0
|
391 |
if (!$update)
|
|
indvdum@0
|
392 |
{
|
|
indvdum@0
|
393 |
$forum_data = $row;
|
|
indvdum@0
|
394 |
}
|
|
indvdum@0
|
395 |
else
|
|
indvdum@0
|
396 |
{
|
|
indvdum@0
|
397 |
$forum_data['left_id'] = $row['left_id'];
|
|
indvdum@0
|
398 |
$forum_data['right_id'] = $row['right_id'];
|
|
indvdum@0
|
399 |
}
|
|
indvdum@0
|
400 |
|
|
indvdum@0
|
401 |
// Make sure no direct child forums are able to be selected as parents.
|
|
indvdum@0
|
402 |
$exclude_forums = array();
|
|
indvdum@0
|
403 |
foreach (get_forum_branch($forum_id, 'children') as $row)
|
|
indvdum@0
|
404 |
{
|
|
indvdum@0
|
405 |
$exclude_forums[] = $row['forum_id'];
|
|
indvdum@0
|
406 |
}
|
|
indvdum@0
|
407 |
|
|
indvdum@0
|
408 |
$parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false);
|
|
indvdum@0
|
409 |
|
|
indvdum@0
|
410 |
$forum_data['forum_password_confirm'] = $forum_data['forum_password'];
|
|
indvdum@0
|
411 |
}
|
|
indvdum@0
|
412 |
else
|
|
indvdum@0
|
413 |
{
|
|
indvdum@0
|
414 |
$this->page_title = 'CREATE_FORUM';
|
|
indvdum@0
|
415 |
|
|
indvdum@0
|
416 |
$forum_id = $this->parent_id;
|
|
indvdum@0
|
417 |
$parents_list = make_forum_select($this->parent_id, false, false, false, false);
|
|
indvdum@0
|
418 |
|
|
indvdum@0
|
419 |
// Fill forum data with default values
|
|
indvdum@0
|
420 |
if (!$update)
|
|
indvdum@0
|
421 |
{
|
|
indvdum@0
|
422 |
$forum_data = array(
|
|
indvdum@0
|
423 |
'parent_id' => $this->parent_id,
|
|
indvdum@0
|
424 |
'forum_type' => FORUM_POST,
|
|
indvdum@0
|
425 |
'forum_status' => ITEM_UNLOCKED,
|
|
indvdum@0
|
426 |
'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)),
|
|
indvdum@0
|
427 |
'forum_link' => '',
|
|
indvdum@0
|
428 |
'forum_link_track' => false,
|
|
indvdum@0
|
429 |
'forum_desc' => '',
|
|
indvdum@0
|
430 |
'forum_rules' => '',
|
|
indvdum@0
|
431 |
'forum_rules_link' => '',
|
|
indvdum@0
|
432 |
'forum_image' => '',
|
|
indvdum@0
|
433 |
'forum_style' => 0,
|
|
indvdum@0
|
434 |
'display_subforum_list' => true,
|
|
indvdum@0
|
435 |
'display_on_index' => false,
|
|
indvdum@0
|
436 |
'forum_topics_per_page' => 0,
|
|
indvdum@0
|
437 |
'enable_indexing' => true,
|
|
indvdum@0
|
438 |
'enable_icons' => false,
|
|
indvdum@0
|
439 |
'enable_prune' => false,
|
|
indvdum@0
|
440 |
'prune_days' => 7,
|
|
indvdum@0
|
441 |
'prune_viewed' => 7,
|
|
indvdum@0
|
442 |
'prune_freq' => 1,
|
|
indvdum@0
|
443 |
'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS,
|
|
indvdum@0
|
444 |
'forum_options' => 0,
|
|
indvdum@0
|
445 |
'forum_password' => '',
|
|
indvdum@0
|
446 |
'forum_password_confirm'=> '',
|
|
indvdum@0
|
447 |
);
|
|
indvdum@0
|
448 |
}
|
|
indvdum@0
|
449 |
}
|
|
indvdum@0
|
450 |
|
|
indvdum@0
|
451 |
$forum_rules_data = array(
|
|
indvdum@0
|
452 |
'text' => $forum_data['forum_rules'],
|
|
indvdum@0
|
453 |
'allow_bbcode' => true,
|
|
indvdum@0
|
454 |
'allow_smilies' => true,
|
|
indvdum@0
|
455 |
'allow_urls' => true
|
|
indvdum@0
|
456 |
);
|
|
indvdum@0
|
457 |
|
|
indvdum@0
|
458 |
$forum_desc_data = array(
|
|
indvdum@0
|
459 |
'text' => $forum_data['forum_desc'],
|
|
indvdum@0
|
460 |
'allow_bbcode' => true,
|
|
indvdum@0
|
461 |
'allow_smilies' => true,
|
|
indvdum@0
|
462 |
'allow_urls' => true
|
|
indvdum@0
|
463 |
);
|
|
indvdum@0
|
464 |
|
|
indvdum@0
|
465 |
$forum_rules_preview = '';
|
|
indvdum@0
|
466 |
|
|
indvdum@0
|
467 |
// Parse rules if specified
|
|
indvdum@0
|
468 |
if ($forum_data['forum_rules'])
|
|
indvdum@0
|
469 |
{
|
|
indvdum@0
|
470 |
if (!isset($forum_data['forum_rules_uid']))
|
|
indvdum@0
|
471 |
{
|
|
indvdum@0
|
472 |
// Before we are able to display the preview and plane text, we need to parse our request_var()'d value...
|
|
indvdum@0
|
473 |
$forum_data['forum_rules_uid'] = '';
|
|
indvdum@0
|
474 |
$forum_data['forum_rules_bitfield'] = '';
|
|
indvdum@0
|
475 |
$forum_data['forum_rules_options'] = 0;
|
|
indvdum@0
|
476 |
|
|
indvdum@0
|
477 |
generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_allow_bbcode', false), request_var('rules_allow_urls', false), request_var('rules_allow_smilies', false));
|
|
indvdum@0
|
478 |
}
|
|
indvdum@0
|
479 |
|
|
indvdum@0
|
480 |
// Generate preview content
|
|
indvdum@0
|
481 |
$forum_rules_preview = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']);
|
|
indvdum@0
|
482 |
|
|
indvdum@0
|
483 |
// decode...
|
|
indvdum@0
|
484 |
$forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']);
|
|
indvdum@0
|
485 |
}
|
|
indvdum@0
|
486 |
|
|
indvdum@0
|
487 |
// Parse desciption if specified
|
|
indvdum@0
|
488 |
if ($forum_data['forum_desc'])
|
|
indvdum@0
|
489 |
{
|
|
indvdum@0
|
490 |
if (!isset($forum_data['forum_desc_uid']))
|
|
indvdum@0
|
491 |
{
|
|
indvdum@0
|
492 |
// Before we are able to display the preview and plane text, we need to parse our request_var()'d value...
|
|
indvdum@0
|
493 |
$forum_data['forum_desc_uid'] = '';
|
|
indvdum@0
|
494 |
$forum_data['forum_desc_bitfield'] = '';
|
|
indvdum@0
|
495 |
$forum_data['forum_desc_options'] = 0;
|
|
indvdum@0
|
496 |
|
|
indvdum@0
|
497 |
generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_allow_bbcode', false), request_var('desc_allow_urls', false), request_var('desc_allow_smilies', false));
|
|
indvdum@0
|
498 |
}
|
|
indvdum@0
|
499 |
|
|
indvdum@0
|
500 |
// decode...
|
|
indvdum@0
|
501 |
$forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']);
|
|
indvdum@0
|
502 |
}
|
|
indvdum@0
|
503 |
|
|
indvdum@0
|
504 |
$forum_type_options = '';
|
|
indvdum@0
|
505 |
$forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK');
|
|
indvdum@0
|
506 |
|
|
indvdum@0
|
507 |
foreach ($forum_type_ary as $value => $lang)
|
|
indvdum@0
|
508 |
{
|
|
indvdum@0
|
509 |
$forum_type_options .= '<option value="' . $value . '"' . (($value == $forum_data['forum_type']) ? ' selected="selected"' : '') . '>' . $user->lang['TYPE_' . $lang] . '</option>';
|
|
indvdum@0
|
510 |
}
|
|
indvdum@0
|
511 |
|
|
indvdum@0
|
512 |
$styles_list = style_select($forum_data['forum_style'], true);
|
|
indvdum@0
|
513 |
|
|
indvdum@0
|
514 |
$statuslist = '<option value="' . ITEM_UNLOCKED . '"' . (($forum_data['forum_status'] == ITEM_UNLOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['UNLOCKED'] . '</option><option value="' . ITEM_LOCKED . '"' . (($forum_data['forum_status'] == ITEM_LOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['LOCKED'] . '</option>';
|
|
indvdum@0
|
515 |
|
|
indvdum@0
|
516 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
517 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
518 |
WHERE forum_type = ' . FORUM_POST . "
|
|
indvdum@0
|
519 |
AND forum_id <> $forum_id";
|
|
indvdum@0
|
520 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
521 |
|
|
indvdum@0
|
522 |
$postable_forum_exists = false;
|
|
indvdum@0
|
523 |
if ($db->sql_fetchrow($result))
|
|
indvdum@0
|
524 |
{
|
|
indvdum@0
|
525 |
$postable_forum_exists = true;
|
|
indvdum@0
|
526 |
}
|
|
indvdum@0
|
527 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
528 |
|
|
indvdum@0
|
529 |
// Subforum move options
|
|
indvdum@0
|
530 |
if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT)
|
|
indvdum@0
|
531 |
{
|
|
indvdum@0
|
532 |
$subforums_id = array();
|
|
indvdum@0
|
533 |
$subforums = get_forum_branch($forum_id, 'children');
|
|
indvdum@0
|
534 |
|
|
indvdum@0
|
535 |
foreach ($subforums as $row)
|
|
indvdum@0
|
536 |
{
|
|
indvdum@0
|
537 |
$subforums_id[] = $row['forum_id'];
|
|
indvdum@0
|
538 |
}
|
|
indvdum@0
|
539 |
|
|
indvdum@0
|
540 |
$forums_list = make_forum_select($forum_data['parent_id'], $subforums_id);
|
|
indvdum@0
|
541 |
|
|
indvdum@0
|
542 |
if ($postable_forum_exists)
|
|
indvdum@0
|
543 |
{
|
|
indvdum@0
|
544 |
$template->assign_vars(array(
|
|
indvdum@0
|
545 |
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false???
|
|
indvdum@0
|
546 |
);
|
|
indvdum@0
|
547 |
}
|
|
indvdum@0
|
548 |
|
|
indvdum@0
|
549 |
$template->assign_vars(array(
|
|
indvdum@0
|
550 |
'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
|
|
indvdum@0
|
551 |
'S_FORUMS_LIST' => $forums_list)
|
|
indvdum@0
|
552 |
);
|
|
indvdum@0
|
553 |
}
|
|
indvdum@0
|
554 |
else if ($postable_forum_exists)
|
|
indvdum@0
|
555 |
{
|
|
indvdum@0
|
556 |
$template->assign_vars(array(
|
|
indvdum@0
|
557 |
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false))
|
|
indvdum@0
|
558 |
);
|
|
indvdum@0
|
559 |
}
|
|
indvdum@0
|
560 |
|
|
indvdum@0
|
561 |
$s_show_display_on_index = false;
|
|
indvdum@0
|
562 |
|
|
indvdum@0
|
563 |
if ($forum_data['parent_id'] > 0)
|
|
indvdum@0
|
564 |
{
|
|
indvdum@0
|
565 |
// if this forum is a subforum put the "display on index" checkbox
|
|
indvdum@0
|
566 |
if ($parent_info = $this->get_forum_info($forum_data['parent_id']))
|
|
indvdum@0
|
567 |
{
|
|
indvdum@0
|
568 |
if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT)
|
|
indvdum@0
|
569 |
{
|
|
indvdum@0
|
570 |
$s_show_display_on_index = true;
|
|
indvdum@0
|
571 |
}
|
|
indvdum@0
|
572 |
}
|
|
indvdum@0
|
573 |
}
|
|
indvdum@0
|
574 |
|
|
indvdum@0
|
575 |
if (strlen($forum_data['forum_password']) == 32)
|
|
indvdum@0
|
576 |
{
|
|
indvdum@0
|
577 |
$errors[] = $user->lang['FORUM_PASSWORD_OLD'];
|
|
indvdum@0
|
578 |
}
|
|
indvdum@0
|
579 |
|
|
indvdum@0
|
580 |
$template->assign_vars(array(
|
|
indvdum@0
|
581 |
'S_EDIT_FORUM' => true,
|
|
indvdum@0
|
582 |
'S_ERROR' => (sizeof($errors)) ? true : false,
|
|
indvdum@0
|
583 |
'S_PARENT_ID' => $this->parent_id,
|
|
indvdum@0
|
584 |
'S_FORUM_PARENT_ID' => $forum_data['parent_id'],
|
|
indvdum@0
|
585 |
'S_ADD_ACTION' => ($action == 'add') ? true : false,
|
|
indvdum@0
|
586 |
|
|
indvdum@0
|
587 |
'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id,
|
|
indvdum@0
|
588 |
'U_EDIT_ACTION' => $this->u_action . "&parent_id={$this->parent_id}&action=$action&f=$forum_id",
|
|
indvdum@0
|
589 |
|
|
indvdum@0
|
590 |
'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'],
|
|
indvdum@0
|
591 |
'L_TITLE' => $user->lang[$this->page_title],
|
|
indvdum@0
|
592 |
'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',
|
|
indvdum@0
|
593 |
|
|
indvdum@0
|
594 |
'FORUM_NAME' => $forum_data['forum_name'],
|
|
indvdum@0
|
595 |
'FORUM_DATA_LINK' => $forum_data['forum_link'],
|
|
indvdum@0
|
596 |
'FORUM_IMAGE' => $forum_data['forum_image'],
|
|
indvdum@0
|
597 |
'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? $phpbb_root_path . $forum_data['forum_image'] : '',
|
|
indvdum@0
|
598 |
'FORUM_POST' => FORUM_POST,
|
|
indvdum@0
|
599 |
'FORUM_LINK' => FORUM_LINK,
|
|
indvdum@0
|
600 |
'FORUM_CAT' => FORUM_CAT,
|
|
indvdum@0
|
601 |
'PRUNE_FREQ' => $forum_data['prune_freq'],
|
|
indvdum@0
|
602 |
'PRUNE_DAYS' => $forum_data['prune_days'],
|
|
indvdum@0
|
603 |
'PRUNE_VIEWED' => $forum_data['prune_viewed'],
|
|
indvdum@0
|
604 |
'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'],
|
|
indvdum@0
|
605 |
'FORUM_RULES_LINK' => $forum_data['forum_rules_link'],
|
|
indvdum@0
|
606 |
'FORUM_RULES' => $forum_data['forum_rules'],
|
|
indvdum@0
|
607 |
'FORUM_RULES_PREVIEW' => $forum_rules_preview,
|
|
indvdum@0
|
608 |
'FORUM_RULES_PLAIN' => $forum_rules_data['text'],
|
|
indvdum@0
|
609 |
'S_BBCODE_CHECKED' => ($forum_rules_data['allow_bbcode']) ? true : false,
|
|
indvdum@0
|
610 |
'S_SMILIES_CHECKED' => ($forum_rules_data['allow_smilies']) ? true : false,
|
|
indvdum@0
|
611 |
'S_URLS_CHECKED' => ($forum_rules_data['allow_urls']) ? true : false,
|
|
indvdum@0
|
612 |
'S_FORUM_PASSWORD_SET' => (empty($forum_data['forum_password'])) ? false : true,
|
|
indvdum@0
|
613 |
|
|
indvdum@0
|
614 |
'FORUM_DESC' => $forum_desc_data['text'],
|
|
indvdum@0
|
615 |
'S_DESC_BBCODE_CHECKED' => ($forum_desc_data['allow_bbcode']) ? true : false,
|
|
indvdum@0
|
616 |
'S_DESC_SMILIES_CHECKED' => ($forum_desc_data['allow_smilies']) ? true : false,
|
|
indvdum@0
|
617 |
'S_DESC_URLS_CHECKED' => ($forum_desc_data['allow_urls']) ? true : false,
|
|
indvdum@0
|
618 |
|
|
indvdum@0
|
619 |
'S_FORUM_TYPE_OPTIONS' => $forum_type_options,
|
|
indvdum@0
|
620 |
'S_STATUS_OPTIONS' => $statuslist,
|
|
indvdum@0
|
621 |
'S_PARENT_OPTIONS' => $parents_list,
|
|
indvdum@0
|
622 |
'S_STYLES_OPTIONS' => $styles_list,
|
|
indvdum@0
|
623 |
'S_FORUM_OPTIONS' => make_forum_select(($action == 'add') ? $forum_data['parent_id'] : false, ($action == 'edit') ? $forum_data['forum_id'] : false, false, false, false),
|
|
indvdum@0
|
624 |
'S_SHOW_DISPLAY_ON_INDEX' => $s_show_display_on_index,
|
|
indvdum@0
|
625 |
'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
|
|
indvdum@0
|
626 |
'S_FORUM_ORIG_POST' => (isset($old_forum_type) && $old_forum_type == FORUM_POST) ? true : false,
|
|
indvdum@0
|
627 |
'S_FORUM_ORIG_CAT' => (isset($old_forum_type) && $old_forum_type == FORUM_CAT) ? true : false,
|
|
indvdum@0
|
628 |
'S_FORUM_ORIG_LINK' => (isset($old_forum_type) && $old_forum_type == FORUM_LINK) ? true : false,
|
|
indvdum@0
|
629 |
'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
|
|
indvdum@0
|
630 |
'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
|
|
indvdum@0
|
631 |
'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false,
|
|
indvdum@0
|
632 |
'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false,
|
|
indvdum@0
|
633 |
'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false,
|
|
indvdum@0
|
634 |
'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false,
|
|
indvdum@0
|
635 |
'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false,
|
|
indvdum@0
|
636 |
'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? true : false,
|
|
indvdum@0
|
637 |
'S_PRUNE_OLD_POLLS' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false,
|
|
indvdum@0
|
638 |
'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false,
|
|
indvdum@0
|
639 |
'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false,
|
|
indvdum@0
|
640 |
'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true,
|
|
indvdum@0
|
641 |
'S_ENABLE_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false,
|
|
indvdum@0
|
642 |
'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false,
|
|
indvdum@0
|
643 |
'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false,
|
|
indvdum@0
|
644 |
'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false,
|
|
indvdum@0
|
645 |
));
|
|
indvdum@0
|
646 |
|
|
indvdum@0
|
647 |
return;
|
|
indvdum@0
|
648 |
|
|
indvdum@0
|
649 |
break;
|
|
indvdum@0
|
650 |
|
|
indvdum@0
|
651 |
case 'delete':
|
|
indvdum@0
|
652 |
|
|
indvdum@0
|
653 |
if (!$forum_id)
|
|
indvdum@0
|
654 |
{
|
|
indvdum@0
|
655 |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
656 |
}
|
|
indvdum@0
|
657 |
|
|
indvdum@0
|
658 |
$forum_data = $this->get_forum_info($forum_id);
|
|
indvdum@0
|
659 |
|
|
indvdum@0
|
660 |
$subforums_id = array();
|
|
indvdum@0
|
661 |
$subforums = get_forum_branch($forum_id, 'children');
|
|
indvdum@0
|
662 |
|
|
indvdum@0
|
663 |
foreach ($subforums as $row)
|
|
indvdum@0
|
664 |
{
|
|
indvdum@0
|
665 |
$subforums_id[] = $row['forum_id'];
|
|
indvdum@0
|
666 |
}
|
|
indvdum@0
|
667 |
|
|
indvdum@0
|
668 |
$forums_list = make_forum_select($forum_data['parent_id'], $subforums_id);
|
|
indvdum@0
|
669 |
|
|
indvdum@0
|
670 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
671 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
672 |
WHERE forum_type = ' . FORUM_POST . "
|
|
indvdum@0
|
673 |
AND forum_id <> $forum_id";
|
|
indvdum@0
|
674 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
675 |
|
|
indvdum@0
|
676 |
if ($db->sql_fetchrow($result))
|
|
indvdum@0
|
677 |
{
|
|
indvdum@0
|
678 |
$template->assign_vars(array(
|
|
indvdum@0
|
679 |
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false???
|
|
indvdum@0
|
680 |
);
|
|
indvdum@0
|
681 |
}
|
|
indvdum@0
|
682 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
683 |
|
|
indvdum@0
|
684 |
$parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id;
|
|
indvdum@0
|
685 |
|
|
indvdum@0
|
686 |
$template->assign_vars(array(
|
|
indvdum@0
|
687 |
'S_DELETE_FORUM' => true,
|
|
indvdum@0
|
688 |
'U_ACTION' => $this->u_action . "&parent_id={$parent_id}&action=delete&f=$forum_id",
|
|
indvdum@0
|
689 |
'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id,
|
|
indvdum@0
|
690 |
|
|
indvdum@0
|
691 |
'FORUM_NAME' => $forum_data['forum_name'],
|
|
indvdum@0
|
692 |
'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
|
|
indvdum@0
|
693 |
'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
|
|
indvdum@0
|
694 |
'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
|
|
indvdum@0
|
695 |
'S_FORUMS_LIST' => $forums_list,
|
|
indvdum@0
|
696 |
'S_ERROR' => (sizeof($errors)) ? true : false,
|
|
indvdum@0
|
697 |
'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '')
|
|
indvdum@0
|
698 |
);
|
|
indvdum@0
|
699 |
|
|
indvdum@0
|
700 |
return;
|
|
indvdum@0
|
701 |
break;
|
|
indvdum@0
|
702 |
|
|
indvdum@0
|
703 |
case 'copy_perm':
|
|
indvdum@0
|
704 |
$forum_perm_from = request_var('forum_perm_from', 0);
|
|
indvdum@0
|
705 |
|
|
indvdum@0
|
706 |
// Copy permissions?
|
|
indvdum@0
|
707 |
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
|
|
indvdum@0
|
708 |
{
|
|
indvdum@0
|
709 |
copy_forum_permissions($forum_perm_from, $forum_id, true);
|
|
indvdum@0
|
710 |
cache_moderators();
|
|
indvdum@0
|
711 |
$auth->acl_clear_prefetch();
|
|
indvdum@0
|
712 |
$cache->destroy('sql', FORUMS_TABLE);
|
|
indvdum@0
|
713 |
|
|
indvdum@0
|
714 |
$acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_id;
|
|
indvdum@0
|
715 |
|
|
indvdum@0
|
716 |
$message = $user->lang['FORUM_UPDATED'];
|
|
indvdum@0
|
717 |
|
|
indvdum@0
|
718 |
// Redirect to permissions
|
|
indvdum@0
|
719 |
if ($auth->acl_get('a_fauth'))
|
|
indvdum@0
|
720 |
{
|
|
indvdum@0
|
721 |
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
|
|
indvdum@0
|
722 |
}
|
|
indvdum@0
|
723 |
|
|
indvdum@0
|
724 |
trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id));
|
|
indvdum@0
|
725 |
}
|
|
indvdum@0
|
726 |
|
|
indvdum@0
|
727 |
break;
|
|
indvdum@0
|
728 |
}
|
|
indvdum@0
|
729 |
|
|
indvdum@0
|
730 |
// Default management page
|
|
indvdum@0
|
731 |
if (!$this->parent_id)
|
|
indvdum@0
|
732 |
{
|
|
indvdum@0
|
733 |
$navigation = $user->lang['FORUM_INDEX'];
|
|
indvdum@0
|
734 |
}
|
|
indvdum@0
|
735 |
else
|
|
indvdum@0
|
736 |
{
|
|
indvdum@0
|
737 |
$navigation = '<a href="' . $this->u_action . '">' . $user->lang['FORUM_INDEX'] . '</a>';
|
|
indvdum@0
|
738 |
|
|
indvdum@0
|
739 |
$forums_nav = get_forum_branch($this->parent_id, 'parents', 'descending');
|
|
indvdum@0
|
740 |
foreach ($forums_nav as $row)
|
|
indvdum@0
|
741 |
{
|
|
indvdum@0
|
742 |
if ($row['forum_id'] == $this->parent_id)
|
|
indvdum@0
|
743 |
{
|
|
indvdum@0
|
744 |
$navigation .= ' -> ' . $row['forum_name'];
|
|
indvdum@0
|
745 |
}
|
|
indvdum@0
|
746 |
else
|
|
indvdum@0
|
747 |
{
|
|
indvdum@0
|
748 |
$navigation .= ' -> <a href="' . $this->u_action . '&parent_id=' . $row['forum_id'] . '">' . $row['forum_name'] . '</a>';
|
|
indvdum@0
|
749 |
}
|
|
indvdum@0
|
750 |
}
|
|
indvdum@0
|
751 |
}
|
|
indvdum@0
|
752 |
|
|
indvdum@0
|
753 |
// Jumpbox
|
|
indvdum@0
|
754 |
$forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id);
|
|
indvdum@0
|
755 |
|
|
indvdum@0
|
756 |
if ($action == 'sync' || $action == 'sync_forum')
|
|
indvdum@0
|
757 |
{
|
|
indvdum@0
|
758 |
$template->assign_var('S_RESYNCED', true);
|
|
indvdum@0
|
759 |
}
|
|
indvdum@0
|
760 |
|
|
indvdum@0
|
761 |
$sql = 'SELECT *
|
|
indvdum@0
|
762 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
763 |
WHERE parent_id = $this->parent_id
|
|
indvdum@0
|
764 |
ORDER BY left_id";
|
|
indvdum@0
|
765 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
766 |
|
|
indvdum@0
|
767 |
if ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
768 |
{
|
|
indvdum@0
|
769 |
do
|
|
indvdum@0
|
770 |
{
|
|
indvdum@0
|
771 |
$forum_type = $row['forum_type'];
|
|
indvdum@0
|
772 |
|
|
indvdum@0
|
773 |
if ($row['forum_status'] == ITEM_LOCKED)
|
|
indvdum@0
|
774 |
{
|
|
indvdum@0
|
775 |
$folder_image = '<img src="images/icon_folder_lock.gif" alt="' . $user->lang['LOCKED'] . '" />';
|
|
indvdum@0
|
776 |
}
|
|
indvdum@0
|
777 |
else
|
|
indvdum@0
|
778 |
{
|
|
indvdum@0
|
779 |
switch ($forum_type)
|
|
indvdum@0
|
780 |
{
|
|
indvdum@0
|
781 |
case FORUM_LINK:
|
|
indvdum@0
|
782 |
$folder_image = '<img src="images/icon_folder_link.gif" alt="' . $user->lang['LINK'] . '" />';
|
|
indvdum@0
|
783 |
break;
|
|
indvdum@0
|
784 |
|
|
indvdum@0
|
785 |
default:
|
|
indvdum@0
|
786 |
$folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="' . $user->lang['SUBFORUM'] . '" />' : '<img src="images/icon_folder.gif" alt="' . $user->lang['FOLDER'] . '" />';
|
|
indvdum@0
|
787 |
break;
|
|
indvdum@0
|
788 |
}
|
|
indvdum@0
|
789 |
}
|
|
indvdum@0
|
790 |
|
|
indvdum@0
|
791 |
$url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}";
|
|
indvdum@0
|
792 |
|
|
indvdum@0
|
793 |
$template->assign_block_vars('forums', array(
|
|
indvdum@0
|
794 |
'FOLDER_IMAGE' => $folder_image,
|
|
indvdum@0
|
795 |
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="" />' : '',
|
|
indvdum@0
|
796 |
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
|
|
indvdum@0
|
797 |
'FORUM_NAME' => $row['forum_name'],
|
|
indvdum@0
|
798 |
'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
|
|
indvdum@0
|
799 |
'FORUM_TOPICS' => $row['forum_topics'],
|
|
indvdum@0
|
800 |
'FORUM_POSTS' => $row['forum_posts'],
|
|
indvdum@0
|
801 |
|
|
indvdum@0
|
802 |
'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false,
|
|
indvdum@0
|
803 |
'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false,
|
|
indvdum@0
|
804 |
|
|
indvdum@0
|
805 |
'U_FORUM' => $this->u_action . '&parent_id=' . $row['forum_id'],
|
|
indvdum@0
|
806 |
'U_MOVE_UP' => $url . '&action=move_up',
|
|
indvdum@0
|
807 |
'U_MOVE_DOWN' => $url . '&action=move_down',
|
|
indvdum@0
|
808 |
'U_EDIT' => $url . '&action=edit',
|
|
indvdum@0
|
809 |
'U_DELETE' => $url . '&action=delete',
|
|
indvdum@0
|
810 |
'U_SYNC' => $url . '&action=sync')
|
|
indvdum@0
|
811 |
);
|
|
indvdum@0
|
812 |
}
|
|
indvdum@0
|
813 |
while ($row = $db->sql_fetchrow($result));
|
|
indvdum@0
|
814 |
}
|
|
indvdum@0
|
815 |
else if ($this->parent_id)
|
|
indvdum@0
|
816 |
{
|
|
indvdum@0
|
817 |
$row = $this->get_forum_info($this->parent_id);
|
|
indvdum@0
|
818 |
|
|
indvdum@0
|
819 |
$url = $this->u_action . '&parent_id=' . $this->parent_id . '&f=' . $row['forum_id'];
|
|
indvdum@0
|
820 |
|
|
indvdum@0
|
821 |
$template->assign_vars(array(
|
|
indvdum@0
|
822 |
'S_NO_FORUMS' => true,
|
|
indvdum@0
|
823 |
|
|
indvdum@0
|
824 |
'U_EDIT' => $url . '&action=edit',
|
|
indvdum@0
|
825 |
'U_DELETE' => $url . '&action=delete',
|
|
indvdum@0
|
826 |
'U_SYNC' => $url . '&action=sync')
|
|
indvdum@0
|
827 |
);
|
|
indvdum@0
|
828 |
}
|
|
indvdum@0
|
829 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
830 |
|
|
indvdum@0
|
831 |
$template->assign_vars(array(
|
|
indvdum@0
|
832 |
'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',
|
|
indvdum@0
|
833 |
'NAVIGATION' => $navigation,
|
|
indvdum@0
|
834 |
'FORUM_BOX' => $forum_box,
|
|
indvdum@0
|
835 |
'U_SEL_ACTION' => $this->u_action,
|
|
indvdum@0
|
836 |
'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id,
|
|
indvdum@0
|
837 |
|
|
indvdum@0
|
838 |
'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar',
|
|
indvdum@0
|
839 |
'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'),
|
|
indvdum@0
|
840 |
));
|
|
indvdum@0
|
841 |
}
|
|
indvdum@0
|
842 |
|
|
indvdum@0
|
843 |
/**
|
|
indvdum@0
|
844 |
* Get forum details
|
|
indvdum@0
|
845 |
*/
|
|
indvdum@0
|
846 |
function get_forum_info($forum_id)
|
|
indvdum@0
|
847 |
{
|
|
indvdum@0
|
848 |
global $db;
|
|
indvdum@0
|
849 |
|
|
indvdum@0
|
850 |
$sql = 'SELECT *
|
|
indvdum@0
|
851 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
852 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
853 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
854 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
855 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
856 |
|
|
indvdum@0
|
857 |
if (!$row)
|
|
indvdum@0
|
858 |
{
|
|
indvdum@0
|
859 |
trigger_error("Forum #$forum_id does not exist", E_USER_ERROR);
|
|
indvdum@0
|
860 |
}
|
|
indvdum@0
|
861 |
|
|
indvdum@0
|
862 |
return $row;
|
|
indvdum@0
|
863 |
}
|
|
indvdum@0
|
864 |
|
|
indvdum@0
|
865 |
/**
|
|
indvdum@0
|
866 |
* Update forum data
|
|
indvdum@0
|
867 |
*/
|
|
indvdum@0
|
868 |
function update_forum_data(&$forum_data)
|
|
indvdum@0
|
869 |
{
|
|
indvdum@0
|
870 |
global $db, $user, $cache, $phpbb_root_path;
|
|
indvdum@0
|
871 |
|
|
indvdum@0
|
872 |
$errors = array();
|
|
indvdum@0
|
873 |
|
|
indvdum@0
|
874 |
if ($forum_data['forum_name'] == '')
|
|
indvdum@0
|
875 |
{
|
|
indvdum@0
|
876 |
$errors[] = $user->lang['FORUM_NAME_EMPTY'];
|
|
indvdum@0
|
877 |
}
|
|
indvdum@0
|
878 |
|
|
indvdum@0
|
879 |
if (utf8_strlen($forum_data['forum_desc']) > 4000)
|
|
indvdum@0
|
880 |
{
|
|
indvdum@0
|
881 |
$errors[] = $user->lang['FORUM_DESC_TOO_LONG'];
|
|
indvdum@0
|
882 |
}
|
|
indvdum@0
|
883 |
|
|
indvdum@0
|
884 |
if (utf8_strlen($forum_data['forum_rules']) > 4000)
|
|
indvdum@0
|
885 |
{
|
|
indvdum@0
|
886 |
$errors[] = $user->lang['FORUM_RULES_TOO_LONG'];
|
|
indvdum@0
|
887 |
}
|
|
indvdum@0
|
888 |
|
|
indvdum@0
|
889 |
if ($forum_data['forum_password'] || $forum_data['forum_password_confirm'])
|
|
indvdum@0
|
890 |
{
|
|
indvdum@0
|
891 |
if ($forum_data['forum_password'] != $forum_data['forum_password_confirm'])
|
|
indvdum@0
|
892 |
{
|
|
indvdum@0
|
893 |
$forum_data['forum_password'] = $forum_data['forum_password_confirm'] = '';
|
|
indvdum@0
|
894 |
$errors[] = $user->lang['FORUM_PASSWORD_MISMATCH'];
|
|
indvdum@0
|
895 |
}
|
|
indvdum@0
|
896 |
}
|
|
indvdum@0
|
897 |
|
|
indvdum@0
|
898 |
if ($forum_data['prune_days'] < 0 || $forum_data['prune_viewed'] < 0 || $forum_data['prune_freq'] < 0)
|
|
indvdum@0
|
899 |
{
|
|
indvdum@0
|
900 |
$forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0;
|
|
indvdum@0
|
901 |
$errors[] = $user->lang['FORUM_DATA_NEGATIVE'];
|
|
indvdum@0
|
902 |
}
|
|
indvdum@0
|
903 |
|
|
indvdum@0
|
904 |
$range_test_ary = array(
|
|
indvdum@0
|
905 |
array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'),
|
|
indvdum@0
|
906 |
);
|
|
indvdum@0
|
907 |
|
|
indvdum@0
|
908 |
if (!empty($forum_data['forum_image']) && !file_exists($phpbb_root_path . $forum_data['forum_image']))
|
|
indvdum@0
|
909 |
{
|
|
indvdum@0
|
910 |
$errors[] = $user->lang['FORUM_IMAGE_NO_EXIST'];
|
|
indvdum@0
|
911 |
}
|
|
indvdum@0
|
912 |
|
|
indvdum@0
|
913 |
validate_range($range_test_ary, $errors);
|
|
indvdum@0
|
914 |
|
|
indvdum@0
|
915 |
// Set forum flags
|
|
indvdum@0
|
916 |
// 1 = link tracking
|
|
indvdum@0
|
917 |
// 2 = prune old polls
|
|
indvdum@0
|
918 |
// 4 = prune announcements
|
|
indvdum@0
|
919 |
// 8 = prune stickies
|
|
indvdum@0
|
920 |
// 16 = show active topics
|
|
indvdum@0
|
921 |
// 32 = enable post review
|
|
indvdum@0
|
922 |
$forum_data['forum_flags'] = 0;
|
|
indvdum@0
|
923 |
$forum_data['forum_flags'] += ($forum_data['forum_link_track']) ? FORUM_FLAG_LINK_TRACK : 0;
|
|
indvdum@0
|
924 |
$forum_data['forum_flags'] += ($forum_data['prune_old_polls']) ? FORUM_FLAG_PRUNE_POLL : 0;
|
|
indvdum@0
|
925 |
$forum_data['forum_flags'] += ($forum_data['prune_announce']) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
|
|
indvdum@0
|
926 |
$forum_data['forum_flags'] += ($forum_data['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0;
|
|
indvdum@0
|
927 |
$forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;
|
|
indvdum@0
|
928 |
$forum_data['forum_flags'] += ($forum_data['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0;
|
|
indvdum@0
|
929 |
$forum_data['forum_flags'] += ($forum_data['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0;
|
|
indvdum@0
|
930 |
|
|
indvdum@0
|
931 |
// Unset data that are not database fields
|
|
indvdum@0
|
932 |
$forum_data_sql = $forum_data;
|
|
indvdum@0
|
933 |
|
|
indvdum@0
|
934 |
unset($forum_data_sql['forum_link_track']);
|
|
indvdum@0
|
935 |
unset($forum_data_sql['prune_old_polls']);
|
|
indvdum@0
|
936 |
unset($forum_data_sql['prune_announce']);
|
|
indvdum@0
|
937 |
unset($forum_data_sql['prune_sticky']);
|
|
indvdum@0
|
938 |
unset($forum_data_sql['show_active']);
|
|
indvdum@0
|
939 |
unset($forum_data_sql['enable_post_review']);
|
|
indvdum@0
|
940 |
unset($forum_data_sql['enable_quick_reply']);
|
|
indvdum@0
|
941 |
unset($forum_data_sql['forum_password_confirm']);
|
|
indvdum@0
|
942 |
|
|
indvdum@0
|
943 |
// What are we going to do tonight Brain? The same thing we do everynight,
|
|
indvdum@0
|
944 |
// try to take over the world ... or decide whether to continue update
|
|
indvdum@0
|
945 |
// and if so, whether it's a new forum/cat/link or an existing one
|
|
indvdum@0
|
946 |
if (sizeof($errors))
|
|
indvdum@0
|
947 |
{
|
|
indvdum@0
|
948 |
return $errors;
|
|
indvdum@0
|
949 |
}
|
|
indvdum@0
|
950 |
|
|
indvdum@0
|
951 |
// As we don't know the old password, it's kinda tricky to detect changes
|
|
indvdum@0
|
952 |
if ($forum_data_sql['forum_password_unset'])
|
|
indvdum@0
|
953 |
{
|
|
indvdum@0
|
954 |
$forum_data_sql['forum_password'] = '';
|
|
indvdum@0
|
955 |
}
|
|
indvdum@0
|
956 |
else if (empty($forum_data_sql['forum_password']))
|
|
indvdum@0
|
957 |
{
|
|
indvdum@0
|
958 |
unset($forum_data_sql['forum_password']);
|
|
indvdum@0
|
959 |
}
|
|
indvdum@0
|
960 |
else
|
|
indvdum@0
|
961 |
{
|
|
indvdum@0
|
962 |
$forum_data_sql['forum_password'] = phpbb_hash($forum_data_sql['forum_password']);
|
|
indvdum@0
|
963 |
}
|
|
indvdum@0
|
964 |
unset($forum_data_sql['forum_password_unset']);
|
|
indvdum@0
|
965 |
|
|
indvdum@0
|
966 |
if (!isset($forum_data_sql['forum_id']))
|
|
indvdum@0
|
967 |
{
|
|
indvdum@0
|
968 |
// no forum_id means we're creating a new forum
|
|
indvdum@0
|
969 |
unset($forum_data_sql['type_action']);
|
|
indvdum@0
|
970 |
|
|
indvdum@0
|
971 |
if ($forum_data_sql['parent_id'])
|
|
indvdum@0
|
972 |
{
|
|
indvdum@0
|
973 |
$sql = 'SELECT left_id, right_id, forum_type
|
|
indvdum@0
|
974 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
975 |
WHERE forum_id = ' . $forum_data_sql['parent_id'];
|
|
indvdum@0
|
976 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
977 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
978 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
979 |
|
|
indvdum@0
|
980 |
if (!$row)
|
|
indvdum@0
|
981 |
{
|
|
indvdum@0
|
982 |
trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
|
indvdum@0
|
983 |
}
|
|
indvdum@0
|
984 |
|
|
indvdum@0
|
985 |
if ($row['forum_type'] == FORUM_LINK)
|
|
indvdum@0
|
986 |
{
|
|
indvdum@0
|
987 |
$errors[] = $user->lang['PARENT_IS_LINK_FORUM'];
|
|
indvdum@0
|
988 |
return $errors;
|
|
indvdum@0
|
989 |
}
|
|
indvdum@0
|
990 |
|
|
indvdum@0
|
991 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
992 |
SET left_id = left_id + 2, right_id = right_id + 2
|
|
indvdum@0
|
993 |
WHERE left_id > ' . $row['right_id'];
|
|
indvdum@0
|
994 |
$db->sql_query($sql);
|
|
indvdum@0
|
995 |
|
|
indvdum@0
|
996 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
997 |
SET right_id = right_id + 2
|
|
indvdum@0
|
998 |
WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id';
|
|
indvdum@0
|
999 |
$db->sql_query($sql);
|
|
indvdum@0
|
1000 |
|
|
indvdum@0
|
1001 |
$forum_data_sql['left_id'] = $row['right_id'];
|
|
indvdum@0
|
1002 |
$forum_data_sql['right_id'] = $row['right_id'] + 1;
|
|
indvdum@0
|
1003 |
}
|
|
indvdum@0
|
1004 |
else
|
|
indvdum@0
|
1005 |
{
|
|
indvdum@0
|
1006 |
$sql = 'SELECT MAX(right_id) AS right_id
|
|
indvdum@0
|
1007 |
FROM ' . FORUMS_TABLE;
|
|
indvdum@0
|
1008 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1009 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1010 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1011 |
|
|
indvdum@0
|
1012 |
$forum_data_sql['left_id'] = $row['right_id'] + 1;
|
|
indvdum@0
|
1013 |
$forum_data_sql['right_id'] = $row['right_id'] + 2;
|
|
indvdum@0
|
1014 |
}
|
|
indvdum@0
|
1015 |
|
|
indvdum@0
|
1016 |
$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql);
|
|
indvdum@0
|
1017 |
$db->sql_query($sql);
|
|
indvdum@0
|
1018 |
|
|
indvdum@0
|
1019 |
$forum_data['forum_id'] = $db->sql_nextid();
|
|
indvdum@0
|
1020 |
|
|
indvdum@0
|
1021 |
add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']);
|
|
indvdum@0
|
1022 |
}
|
|
indvdum@0
|
1023 |
else
|
|
indvdum@0
|
1024 |
{
|
|
indvdum@0
|
1025 |
$row = $this->get_forum_info($forum_data_sql['forum_id']);
|
|
indvdum@0
|
1026 |
|
|
indvdum@0
|
1027 |
if ($row['forum_type'] == FORUM_POST && $row['forum_type'] != $forum_data_sql['forum_type'])
|
|
indvdum@0
|
1028 |
{
|
|
indvdum@0
|
1029 |
// Has subforums and want to change into a link?
|
|
indvdum@0
|
1030 |
if ($row['right_id'] - $row['left_id'] > 1 && $forum_data_sql['forum_type'] == FORUM_LINK)
|
|
indvdum@0
|
1031 |
{
|
|
indvdum@0
|
1032 |
$errors[] = $user->lang['FORUM_WITH_SUBFORUMS_NOT_TO_LINK'];
|
|
indvdum@0
|
1033 |
return $errors;
|
|
indvdum@0
|
1034 |
}
|
|
indvdum@0
|
1035 |
|
|
indvdum@0
|
1036 |
// we're turning a postable forum into a non-postable forum
|
|
indvdum@0
|
1037 |
if ($forum_data_sql['type_action'] == 'move')
|
|
indvdum@0
|
1038 |
{
|
|
indvdum@0
|
1039 |
$to_forum_id = request_var('to_forum_id', 0);
|
|
indvdum@0
|
1040 |
|
|
indvdum@0
|
1041 |
if ($to_forum_id)
|
|
indvdum@0
|
1042 |
{
|
|
indvdum@0
|
1043 |
$errors = $this->move_forum_content($forum_data_sql['forum_id'], $to_forum_id);
|
|
indvdum@0
|
1044 |
}
|
|
indvdum@0
|
1045 |
else
|
|
indvdum@0
|
1046 |
{
|
|
indvdum@0
|
1047 |
return array($user->lang['NO_DESTINATION_FORUM']);
|
|
indvdum@0
|
1048 |
}
|
|
indvdum@0
|
1049 |
}
|
|
indvdum@0
|
1050 |
else if ($forum_data_sql['type_action'] == 'delete')
|
|
indvdum@0
|
1051 |
{
|
|
indvdum@0
|
1052 |
$errors = $this->delete_forum_content($forum_data_sql['forum_id']);
|
|
indvdum@0
|
1053 |
}
|
|
indvdum@0
|
1054 |
else
|
|
indvdum@0
|
1055 |
{
|
|
indvdum@0
|
1056 |
return array($user->lang['NO_FORUM_ACTION']);
|
|
indvdum@0
|
1057 |
}
|
|
indvdum@0
|
1058 |
|
|
indvdum@0
|
1059 |
$forum_data_sql['forum_posts'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_real'] = $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0;
|
|
indvdum@0
|
1060 |
$forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = '';
|
|
indvdum@0
|
1061 |
}
|
|
indvdum@0
|
1062 |
else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK)
|
|
indvdum@0
|
1063 |
{
|
|
indvdum@0
|
1064 |
// Has subforums?
|
|
indvdum@0
|
1065 |
if ($row['right_id'] - $row['left_id'] > 1)
|
|
indvdum@0
|
1066 |
{
|
|
indvdum@0
|
1067 |
// We are turning a category into a link - but need to decide what to do with the subforums.
|
|
indvdum@0
|
1068 |
$action_subforums = request_var('action_subforums', '');
|
|
indvdum@0
|
1069 |
$subforums_to_id = request_var('subforums_to_id', 0);
|
|
indvdum@0
|
1070 |
|
|
indvdum@0
|
1071 |
if ($action_subforums == 'delete')
|
|
indvdum@0
|
1072 |
{
|
|
indvdum@0
|
1073 |
$rows = get_forum_branch($row['forum_id'], 'children', 'descending', false);
|
|
indvdum@0
|
1074 |
|
|
indvdum@0
|
1075 |
foreach ($rows as $_row)
|
|
indvdum@0
|
1076 |
{
|
|
indvdum@0
|
1077 |
// Do not remove the forum id we are about to change. ;)
|
|
indvdum@0
|
1078 |
if ($_row['forum_id'] == $row['forum_id'])
|
|
indvdum@0
|
1079 |
{
|
|
indvdum@0
|
1080 |
continue;
|
|
indvdum@0
|
1081 |
}
|
|
indvdum@0
|
1082 |
|
|
indvdum@0
|
1083 |
$forum_ids[] = $_row['forum_id'];
|
|
indvdum@0
|
1084 |
$errors = array_merge($errors, $this->delete_forum_content($_row['forum_id']));
|
|
indvdum@0
|
1085 |
}
|
|
indvdum@0
|
1086 |
|
|
indvdum@0
|
1087 |
if (sizeof($errors))
|
|
indvdum@0
|
1088 |
{
|
|
indvdum@0
|
1089 |
return $errors;
|
|
indvdum@0
|
1090 |
}
|
|
indvdum@0
|
1091 |
|
|
indvdum@0
|
1092 |
if (sizeof($forum_ids))
|
|
indvdum@0
|
1093 |
{
|
|
indvdum@0
|
1094 |
$sql = 'DELETE FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1095 |
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
|
|
indvdum@0
|
1096 |
$db->sql_query($sql);
|
|
indvdum@0
|
1097 |
|
|
indvdum@0
|
1098 |
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
|
|
indvdum@0
|
1099 |
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
|
|
indvdum@0
|
1100 |
$db->sql_query($sql);
|
|
indvdum@0
|
1101 |
|
|
indvdum@0
|
1102 |
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
|
|
indvdum@0
|
1103 |
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
|
|
indvdum@0
|
1104 |
$db->sql_query($sql);
|
|
indvdum@0
|
1105 |
|
|
indvdum@0
|
1106 |
// Delete forum ids from extension groups table
|
|
indvdum@0
|
1107 |
$sql = 'SELECT group_id, allowed_forums
|
|
indvdum@0
|
1108 |
FROM ' . EXTENSION_GROUPS_TABLE;
|
|
indvdum@0
|
1109 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1110 |
|
|
indvdum@0
|
1111 |
while ($_row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1112 |
{
|
|
indvdum@0
|
1113 |
if (!$_row['allowed_forums'])
|
|
indvdum@0
|
1114 |
{
|
|
indvdum@0
|
1115 |
continue;
|
|
indvdum@0
|
1116 |
}
|
|
indvdum@0
|
1117 |
|
|
indvdum@0
|
1118 |
$allowed_forums = unserialize(trim($_row['allowed_forums']));
|
|
indvdum@0
|
1119 |
$allowed_forums = array_diff($allowed_forums, $forum_ids);
|
|
indvdum@0
|
1120 |
|
|
indvdum@0
|
1121 |
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
|
|
indvdum@0
|
1122 |
SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "'
|
|
indvdum@0
|
1123 |
WHERE group_id = {$_row['group_id']}";
|
|
indvdum@0
|
1124 |
$db->sql_query($sql);
|
|
indvdum@0
|
1125 |
}
|
|
indvdum@0
|
1126 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1127 |
|
|
indvdum@0
|
1128 |
$cache->destroy('_extensions');
|
|
indvdum@0
|
1129 |
}
|
|
indvdum@0
|
1130 |
}
|
|
indvdum@0
|
1131 |
else if ($action_subforums == 'move')
|
|
indvdum@0
|
1132 |
{
|
|
indvdum@0
|
1133 |
if (!$subforums_to_id)
|
|
indvdum@0
|
1134 |
{
|
|
indvdum@0
|
1135 |
return array($user->lang['NO_DESTINATION_FORUM']);
|
|
indvdum@0
|
1136 |
}
|
|
indvdum@0
|
1137 |
|
|
indvdum@0
|
1138 |
$sql = 'SELECT forum_name
|
|
indvdum@0
|
1139 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1140 |
WHERE forum_id = ' . $subforums_to_id;
|
|
indvdum@0
|
1141 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1142 |
$_row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1143 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1144 |
|
|
indvdum@0
|
1145 |
if (!$_row)
|
|
indvdum@0
|
1146 |
{
|
|
indvdum@0
|
1147 |
return array($user->lang['NO_FORUM']);
|
|
indvdum@0
|
1148 |
}
|
|
indvdum@0
|
1149 |
|
|
indvdum@0
|
1150 |
$subforums_to_name = $_row['forum_name'];
|
|
indvdum@0
|
1151 |
|
|
indvdum@0
|
1152 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
1153 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1154 |
WHERE parent_id = {$row['forum_id']}";
|
|
indvdum@0
|
1155 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1156 |
|
|
indvdum@0
|
1157 |
while ($_row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1158 |
{
|
|
indvdum@0
|
1159 |
$this->move_forum($_row['forum_id'], $subforums_to_id);
|
|
indvdum@0
|
1160 |
}
|
|
indvdum@0
|
1161 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1162 |
|
|
indvdum@0
|
1163 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1164 |
SET parent_id = $subforums_to_id
|
|
indvdum@0
|
1165 |
WHERE parent_id = {$row['forum_id']}";
|
|
indvdum@0
|
1166 |
$db->sql_query($sql);
|
|
indvdum@0
|
1167 |
}
|
|
indvdum@0
|
1168 |
|
|
indvdum@0
|
1169 |
// Adjust the left/right id
|
|
indvdum@0
|
1170 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1171 |
SET right_id = left_id + 1
|
|
indvdum@0
|
1172 |
WHERE forum_id = ' . $row['forum_id'];
|
|
indvdum@0
|
1173 |
$db->sql_query($sql);
|
|
indvdum@0
|
1174 |
}
|
|
indvdum@0
|
1175 |
}
|
|
indvdum@0
|
1176 |
else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST)
|
|
indvdum@0
|
1177 |
{
|
|
indvdum@0
|
1178 |
// Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum)
|
|
indvdum@0
|
1179 |
$forum_data_sql['forum_posts'] = 0;
|
|
indvdum@0
|
1180 |
$forum_data_sql['forum_topics'] = 0;
|
|
indvdum@0
|
1181 |
$forum_data_sql['forum_topics_real'] = 0;
|
|
indvdum@0
|
1182 |
$forum_data_sql['forum_last_post_id'] = 0;
|
|
indvdum@0
|
1183 |
$forum_data_sql['forum_last_post_subject'] = '';
|
|
indvdum@0
|
1184 |
$forum_data_sql['forum_last_post_time'] = 0;
|
|
indvdum@0
|
1185 |
$forum_data_sql['forum_last_poster_id'] = 0;
|
|
indvdum@0
|
1186 |
$forum_data_sql['forum_last_poster_name'] = '';
|
|
indvdum@0
|
1187 |
$forum_data_sql['forum_last_poster_colour'] = '';
|
|
indvdum@0
|
1188 |
}
|
|
indvdum@0
|
1189 |
|
|
indvdum@0
|
1190 |
if (sizeof($errors))
|
|
indvdum@0
|
1191 |
{
|
|
indvdum@0
|
1192 |
return $errors;
|
|
indvdum@0
|
1193 |
}
|
|
indvdum@0
|
1194 |
|
|
indvdum@0
|
1195 |
if ($row['parent_id'] != $forum_data_sql['parent_id'])
|
|
indvdum@0
|
1196 |
{
|
|
indvdum@0
|
1197 |
if ($row['forum_id'] != $forum_data_sql['parent_id'])
|
|
indvdum@0
|
1198 |
{
|
|
indvdum@0
|
1199 |
$errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']);
|
|
indvdum@0
|
1200 |
}
|
|
indvdum@0
|
1201 |
else
|
|
indvdum@0
|
1202 |
{
|
|
indvdum@0
|
1203 |
$forum_data_sql['parent_id'] = $row['parent_id'];
|
|
indvdum@0
|
1204 |
}
|
|
indvdum@0
|
1205 |
}
|
|
indvdum@0
|
1206 |
|
|
indvdum@0
|
1207 |
if (sizeof($errors))
|
|
indvdum@0
|
1208 |
{
|
|
indvdum@0
|
1209 |
return $errors;
|
|
indvdum@0
|
1210 |
}
|
|
indvdum@0
|
1211 |
|
|
indvdum@0
|
1212 |
unset($forum_data_sql['type_action']);
|
|
indvdum@0
|
1213 |
|
|
indvdum@0
|
1214 |
if ($row['forum_name'] != $forum_data_sql['forum_name'])
|
|
indvdum@0
|
1215 |
{
|
|
indvdum@0
|
1216 |
// the forum name has changed, clear the parents list of all forums (for safety)
|
|
indvdum@0
|
1217 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1218 |
SET forum_parents = ''";
|
|
indvdum@0
|
1219 |
$db->sql_query($sql);
|
|
indvdum@0
|
1220 |
}
|
|
indvdum@0
|
1221 |
|
|
indvdum@0
|
1222 |
// Setting the forum id to the forum id is not really received well by some dbs. ;)
|
|
indvdum@0
|
1223 |
$forum_id = $forum_data_sql['forum_id'];
|
|
indvdum@0
|
1224 |
unset($forum_data_sql['forum_id']);
|
|
indvdum@0
|
1225 |
|
|
indvdum@0
|
1226 |
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1227 |
SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . '
|
|
indvdum@0
|
1228 |
WHERE forum_id = ' . $forum_id;
|
|
indvdum@0
|
1229 |
$db->sql_query($sql);
|
|
indvdum@0
|
1230 |
|
|
indvdum@0
|
1231 |
// Add it back
|
|
indvdum@0
|
1232 |
$forum_data['forum_id'] = $forum_id;
|
|
indvdum@0
|
1233 |
|
|
indvdum@0
|
1234 |
add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']);
|
|
indvdum@0
|
1235 |
}
|
|
indvdum@0
|
1236 |
|
|
indvdum@0
|
1237 |
return $errors;
|
|
indvdum@0
|
1238 |
}
|
|
indvdum@0
|
1239 |
|
|
indvdum@0
|
1240 |
/**
|
|
indvdum@0
|
1241 |
* Move forum
|
|
indvdum@0
|
1242 |
*/
|
|
indvdum@0
|
1243 |
function move_forum($from_id, $to_id)
|
|
indvdum@0
|
1244 |
{
|
|
indvdum@0
|
1245 |
global $db, $user;
|
|
indvdum@0
|
1246 |
|
|
indvdum@0
|
1247 |
$to_data = $moved_ids = $errors = array();
|
|
indvdum@0
|
1248 |
|
|
indvdum@0
|
1249 |
// Check if we want to move to a parent with link type
|
|
indvdum@0
|
1250 |
if ($to_id > 0)
|
|
indvdum@0
|
1251 |
{
|
|
indvdum@0
|
1252 |
$to_data = $this->get_forum_info($to_id);
|
|
indvdum@0
|
1253 |
|
|
indvdum@0
|
1254 |
if ($to_data['forum_type'] == FORUM_LINK)
|
|
indvdum@0
|
1255 |
{
|
|
indvdum@0
|
1256 |
$errors[] = $user->lang['PARENT_IS_LINK_FORUM'];
|
|
indvdum@0
|
1257 |
return $errors;
|
|
indvdum@0
|
1258 |
}
|
|
indvdum@0
|
1259 |
}
|
|
indvdum@0
|
1260 |
|
|
indvdum@0
|
1261 |
$moved_forums = get_forum_branch($from_id, 'children', 'descending');
|
|
indvdum@0
|
1262 |
$from_data = $moved_forums[0];
|
|
indvdum@0
|
1263 |
$diff = sizeof($moved_forums) * 2;
|
|
indvdum@0
|
1264 |
|
|
indvdum@0
|
1265 |
$moved_ids = array();
|
|
indvdum@0
|
1266 |
for ($i = 0; $i < sizeof($moved_forums); ++$i)
|
|
indvdum@0
|
1267 |
{
|
|
indvdum@0
|
1268 |
$moved_ids[] = $moved_forums[$i]['forum_id'];
|
|
indvdum@0
|
1269 |
}
|
|
indvdum@0
|
1270 |
|
|
indvdum@0
|
1271 |
// Resync parents
|
|
indvdum@0
|
1272 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1273 |
SET right_id = right_id - $diff, forum_parents = ''
|
|
indvdum@0
|
1274 |
WHERE left_id < " . $from_data['right_id'] . "
|
|
indvdum@0
|
1275 |
AND right_id > " . $from_data['right_id'];
|
|
indvdum@0
|
1276 |
$db->sql_query($sql);
|
|
indvdum@0
|
1277 |
|
|
indvdum@0
|
1278 |
// Resync righthand side of tree
|
|
indvdum@0
|
1279 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1280 |
SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = ''
|
|
indvdum@0
|
1281 |
WHERE left_id > " . $from_data['right_id'];
|
|
indvdum@0
|
1282 |
$db->sql_query($sql);
|
|
indvdum@0
|
1283 |
|
|
indvdum@0
|
1284 |
if ($to_id > 0)
|
|
indvdum@0
|
1285 |
{
|
|
indvdum@0
|
1286 |
// Retrieve $to_data again, it may have been changed...
|
|
indvdum@0
|
1287 |
$to_data = $this->get_forum_info($to_id);
|
|
indvdum@0
|
1288 |
|
|
indvdum@0
|
1289 |
// Resync new parents
|
|
indvdum@0
|
1290 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1291 |
SET right_id = right_id + $diff, forum_parents = ''
|
|
indvdum@0
|
1292 |
WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id
|
|
indvdum@0
|
1293 |
AND ' . $db->sql_in_set('forum_id', $moved_ids, true);
|
|
indvdum@0
|
1294 |
$db->sql_query($sql);
|
|
indvdum@0
|
1295 |
|
|
indvdum@0
|
1296 |
// Resync the righthand side of the tree
|
|
indvdum@0
|
1297 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1298 |
SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = ''
|
|
indvdum@0
|
1299 |
WHERE left_id > " . $to_data['right_id'] . '
|
|
indvdum@0
|
1300 |
AND ' . $db->sql_in_set('forum_id', $moved_ids, true);
|
|
indvdum@0
|
1301 |
$db->sql_query($sql);
|
|
indvdum@0
|
1302 |
|
|
indvdum@0
|
1303 |
// Resync moved branch
|
|
indvdum@0
|
1304 |
$to_data['right_id'] += $diff;
|
|
indvdum@0
|
1305 |
|
|
indvdum@0
|
1306 |
if ($to_data['right_id'] > $from_data['right_id'])
|
|
indvdum@0
|
1307 |
{
|
|
indvdum@0
|
1308 |
$diff = '+ ' . ($to_data['right_id'] - $from_data['right_id'] - 1);
|
|
indvdum@0
|
1309 |
}
|
|
indvdum@0
|
1310 |
else
|
|
indvdum@0
|
1311 |
{
|
|
indvdum@0
|
1312 |
$diff = '- ' . abs($to_data['right_id'] - $from_data['right_id'] - 1);
|
|
indvdum@0
|
1313 |
}
|
|
indvdum@0
|
1314 |
}
|
|
indvdum@0
|
1315 |
else
|
|
indvdum@0
|
1316 |
{
|
|
indvdum@0
|
1317 |
$sql = 'SELECT MAX(right_id) AS right_id
|
|
indvdum@0
|
1318 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1319 |
WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true);
|
|
indvdum@0
|
1320 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1321 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1322 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1323 |
|
|
indvdum@0
|
1324 |
$diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1);
|
|
indvdum@0
|
1325 |
}
|
|
indvdum@0
|
1326 |
|
|
indvdum@0
|
1327 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1328 |
SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = ''
|
|
indvdum@0
|
1329 |
WHERE " . $db->sql_in_set('forum_id', $moved_ids);
|
|
indvdum@0
|
1330 |
$db->sql_query($sql);
|
|
indvdum@0
|
1331 |
|
|
indvdum@0
|
1332 |
return $errors;
|
|
indvdum@0
|
1333 |
}
|
|
indvdum@0
|
1334 |
|
|
indvdum@0
|
1335 |
/**
|
|
indvdum@0
|
1336 |
* Move forum content from one to another forum
|
|
indvdum@0
|
1337 |
*/
|
|
indvdum@0
|
1338 |
function move_forum_content($from_id, $to_id, $sync = true)
|
|
indvdum@0
|
1339 |
{
|
|
indvdum@0
|
1340 |
global $db;
|
|
indvdum@0
|
1341 |
|
|
indvdum@0
|
1342 |
$table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
|
|
indvdum@0
|
1343 |
|
|
indvdum@0
|
1344 |
foreach ($table_ary as $table)
|
|
indvdum@0
|
1345 |
{
|
|
indvdum@0
|
1346 |
$sql = "UPDATE $table
|
|
indvdum@0
|
1347 |
SET forum_id = $to_id
|
|
indvdum@0
|
1348 |
WHERE forum_id = $from_id";
|
|
indvdum@0
|
1349 |
$db->sql_query($sql);
|
|
indvdum@0
|
1350 |
}
|
|
indvdum@0
|
1351 |
unset($table_ary);
|
|
indvdum@0
|
1352 |
|
|
indvdum@0
|
1353 |
$table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE);
|
|
indvdum@0
|
1354 |
|
|
indvdum@0
|
1355 |
foreach ($table_ary as $table)
|
|
indvdum@0
|
1356 |
{
|
|
indvdum@0
|
1357 |
$sql = "DELETE FROM $table
|
|
indvdum@0
|
1358 |
WHERE forum_id = $from_id";
|
|
indvdum@0
|
1359 |
$db->sql_query($sql);
|
|
indvdum@0
|
1360 |
}
|
|
indvdum@0
|
1361 |
|
|
indvdum@0
|
1362 |
if ($sync)
|
|
indvdum@0
|
1363 |
{
|
|
indvdum@0
|
1364 |
// Delete ghost topics that link back to the same forum then resync counters
|
|
indvdum@0
|
1365 |
sync('topic_moved');
|
|
indvdum@0
|
1366 |
sync('forum', 'forum_id', $to_id, false, true);
|
|
indvdum@0
|
1367 |
}
|
|
indvdum@0
|
1368 |
|
|
indvdum@0
|
1369 |
return array();
|
|
indvdum@0
|
1370 |
}
|
|
indvdum@0
|
1371 |
|
|
indvdum@0
|
1372 |
/**
|
|
indvdum@0
|
1373 |
* Remove complete forum
|
|
indvdum@0
|
1374 |
*/
|
|
indvdum@0
|
1375 |
function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0)
|
|
indvdum@0
|
1376 |
{
|
|
indvdum@0
|
1377 |
global $db, $user, $cache;
|
|
indvdum@0
|
1378 |
|
|
indvdum@0
|
1379 |
$forum_data = $this->get_forum_info($forum_id);
|
|
indvdum@0
|
1380 |
|
|
indvdum@0
|
1381 |
$errors = array();
|
|
indvdum@0
|
1382 |
$log_action_posts = $log_action_forums = $posts_to_name = $subforums_to_name = '';
|
|
indvdum@0
|
1383 |
$forum_ids = array($forum_id);
|
|
indvdum@0
|
1384 |
|
|
indvdum@0
|
1385 |
if ($action_posts == 'delete')
|
|
indvdum@0
|
1386 |
{
|
|
indvdum@0
|
1387 |
$log_action_posts = 'POSTS';
|
|
indvdum@0
|
1388 |
$errors = array_merge($errors, $this->delete_forum_content($forum_id));
|
|
indvdum@0
|
1389 |
}
|
|
indvdum@0
|
1390 |
else if ($action_posts == 'move')
|
|
indvdum@0
|
1391 |
{
|
|
indvdum@0
|
1392 |
if (!$posts_to_id)
|
|
indvdum@0
|
1393 |
{
|
|
indvdum@0
|
1394 |
$errors[] = $user->lang['NO_DESTINATION_FORUM'];
|
|
indvdum@0
|
1395 |
}
|
|
indvdum@0
|
1396 |
else
|
|
indvdum@0
|
1397 |
{
|
|
indvdum@0
|
1398 |
$log_action_posts = 'MOVE_POSTS';
|
|
indvdum@0
|
1399 |
|
|
indvdum@0
|
1400 |
$sql = 'SELECT forum_name
|
|
indvdum@0
|
1401 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1402 |
WHERE forum_id = ' . $posts_to_id;
|
|
indvdum@0
|
1403 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1404 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1405 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1406 |
|
|
indvdum@0
|
1407 |
if (!$row)
|
|
indvdum@0
|
1408 |
{
|
|
indvdum@0
|
1409 |
$errors[] = $user->lang['NO_FORUM'];
|
|
indvdum@0
|
1410 |
}
|
|
indvdum@0
|
1411 |
else
|
|
indvdum@0
|
1412 |
{
|
|
indvdum@0
|
1413 |
$posts_to_name = $row['forum_name'];
|
|
indvdum@0
|
1414 |
$errors = array_merge($errors, $this->move_forum_content($forum_id, $posts_to_id));
|
|
indvdum@0
|
1415 |
}
|
|
indvdum@0
|
1416 |
}
|
|
indvdum@0
|
1417 |
}
|
|
indvdum@0
|
1418 |
|
|
indvdum@0
|
1419 |
if (sizeof($errors))
|
|
indvdum@0
|
1420 |
{
|
|
indvdum@0
|
1421 |
return $errors;
|
|
indvdum@0
|
1422 |
}
|
|
indvdum@0
|
1423 |
|
|
indvdum@0
|
1424 |
if ($action_subforums == 'delete')
|
|
indvdum@0
|
1425 |
{
|
|
indvdum@0
|
1426 |
$log_action_forums = 'FORUMS';
|
|
indvdum@0
|
1427 |
$rows = get_forum_branch($forum_id, 'children', 'descending', false);
|
|
indvdum@0
|
1428 |
|
|
indvdum@0
|
1429 |
foreach ($rows as $row)
|
|
indvdum@0
|
1430 |
{
|
|
indvdum@0
|
1431 |
$forum_ids[] = $row['forum_id'];
|
|
indvdum@0
|
1432 |
$errors = array_merge($errors, $this->delete_forum_content($row['forum_id']));
|
|
indvdum@0
|
1433 |
}
|
|
indvdum@0
|
1434 |
|
|
indvdum@0
|
1435 |
if (sizeof($errors))
|
|
indvdum@0
|
1436 |
{
|
|
indvdum@0
|
1437 |
return $errors;
|
|
indvdum@0
|
1438 |
}
|
|
indvdum@0
|
1439 |
|
|
indvdum@0
|
1440 |
$diff = sizeof($forum_ids) * 2;
|
|
indvdum@0
|
1441 |
|
|
indvdum@0
|
1442 |
$sql = 'DELETE FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1443 |
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
|
|
indvdum@0
|
1444 |
$db->sql_query($sql);
|
|
indvdum@0
|
1445 |
|
|
indvdum@0
|
1446 |
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
|
|
indvdum@0
|
1447 |
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
|
|
indvdum@0
|
1448 |
$db->sql_query($sql);
|
|
indvdum@0
|
1449 |
|
|
indvdum@0
|
1450 |
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
|
|
indvdum@0
|
1451 |
WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
|
|
indvdum@0
|
1452 |
$db->sql_query($sql);
|
|
indvdum@0
|
1453 |
}
|
|
indvdum@0
|
1454 |
else if ($action_subforums == 'move')
|
|
indvdum@0
|
1455 |
{
|
|
indvdum@0
|
1456 |
if (!$subforums_to_id)
|
|
indvdum@0
|
1457 |
{
|
|
indvdum@0
|
1458 |
$errors[] = $user->lang['NO_DESTINATION_FORUM'];
|
|
indvdum@0
|
1459 |
}
|
|
indvdum@0
|
1460 |
else
|
|
indvdum@0
|
1461 |
{
|
|
indvdum@0
|
1462 |
$log_action_forums = 'MOVE_FORUMS';
|
|
indvdum@0
|
1463 |
|
|
indvdum@0
|
1464 |
$sql = 'SELECT forum_name
|
|
indvdum@0
|
1465 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1466 |
WHERE forum_id = ' . $subforums_to_id;
|
|
indvdum@0
|
1467 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1468 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1469 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1470 |
|
|
indvdum@0
|
1471 |
if (!$row)
|
|
indvdum@0
|
1472 |
{
|
|
indvdum@0
|
1473 |
$errors[] = $user->lang['NO_FORUM'];
|
|
indvdum@0
|
1474 |
}
|
|
indvdum@0
|
1475 |
else
|
|
indvdum@0
|
1476 |
{
|
|
indvdum@0
|
1477 |
$subforums_to_name = $row['forum_name'];
|
|
indvdum@0
|
1478 |
|
|
indvdum@0
|
1479 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
1480 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1481 |
WHERE parent_id = $forum_id";
|
|
indvdum@0
|
1482 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1483 |
|
|
indvdum@0
|
1484 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1485 |
{
|
|
indvdum@0
|
1486 |
$this->move_forum($row['forum_id'], $subforums_to_id);
|
|
indvdum@0
|
1487 |
}
|
|
indvdum@0
|
1488 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1489 |
|
|
indvdum@0
|
1490 |
// Grab new forum data for correct tree updating later
|
|
indvdum@0
|
1491 |
$forum_data = $this->get_forum_info($forum_id);
|
|
indvdum@0
|
1492 |
|
|
indvdum@0
|
1493 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1494 |
SET parent_id = $subforums_to_id
|
|
indvdum@0
|
1495 |
WHERE parent_id = $forum_id";
|
|
indvdum@0
|
1496 |
$db->sql_query($sql);
|
|
indvdum@0
|
1497 |
|
|
indvdum@0
|
1498 |
$diff = 2;
|
|
indvdum@0
|
1499 |
$sql = 'DELETE FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1500 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
1501 |
$db->sql_query($sql);
|
|
indvdum@0
|
1502 |
|
|
indvdum@0
|
1503 |
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "
|
|
indvdum@0
|
1504 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
1505 |
$db->sql_query($sql);
|
|
indvdum@0
|
1506 |
|
|
indvdum@0
|
1507 |
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . "
|
|
indvdum@0
|
1508 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
1509 |
$db->sql_query($sql);
|
|
indvdum@0
|
1510 |
}
|
|
indvdum@0
|
1511 |
}
|
|
indvdum@0
|
1512 |
|
|
indvdum@0
|
1513 |
if (sizeof($errors))
|
|
indvdum@0
|
1514 |
{
|
|
indvdum@0
|
1515 |
return $errors;
|
|
indvdum@0
|
1516 |
}
|
|
indvdum@0
|
1517 |
}
|
|
indvdum@0
|
1518 |
else
|
|
indvdum@0
|
1519 |
{
|
|
indvdum@0
|
1520 |
$diff = 2;
|
|
indvdum@0
|
1521 |
$sql = 'DELETE FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1522 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
1523 |
$db->sql_query($sql);
|
|
indvdum@0
|
1524 |
|
|
indvdum@0
|
1525 |
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "
|
|
indvdum@0
|
1526 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
1527 |
$db->sql_query($sql);
|
|
indvdum@0
|
1528 |
|
|
indvdum@0
|
1529 |
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . "
|
|
indvdum@0
|
1530 |
WHERE forum_id = $forum_id";
|
|
indvdum@0
|
1531 |
$db->sql_query($sql);
|
|
indvdum@0
|
1532 |
}
|
|
indvdum@0
|
1533 |
|
|
indvdum@0
|
1534 |
// Resync tree
|
|
indvdum@0
|
1535 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1536 |
SET right_id = right_id - $diff
|
|
indvdum@0
|
1537 |
WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}";
|
|
indvdum@0
|
1538 |
$db->sql_query($sql);
|
|
indvdum@0
|
1539 |
|
|
indvdum@0
|
1540 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1541 |
SET left_id = left_id - $diff, right_id = right_id - $diff
|
|
indvdum@0
|
1542 |
WHERE left_id > {$forum_data['right_id']}";
|
|
indvdum@0
|
1543 |
$db->sql_query($sql);
|
|
indvdum@0
|
1544 |
|
|
indvdum@0
|
1545 |
// Delete forum ids from extension groups table
|
|
indvdum@0
|
1546 |
$sql = 'SELECT group_id, allowed_forums
|
|
indvdum@0
|
1547 |
FROM ' . EXTENSION_GROUPS_TABLE;
|
|
indvdum@0
|
1548 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1549 |
|
|
indvdum@0
|
1550 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1551 |
{
|
|
indvdum@0
|
1552 |
if (!$row['allowed_forums'])
|
|
indvdum@0
|
1553 |
{
|
|
indvdum@0
|
1554 |
continue;
|
|
indvdum@0
|
1555 |
}
|
|
indvdum@0
|
1556 |
|
|
indvdum@0
|
1557 |
$allowed_forums = unserialize(trim($row['allowed_forums']));
|
|
indvdum@0
|
1558 |
$allowed_forums = array_diff($allowed_forums, $forum_ids);
|
|
indvdum@0
|
1559 |
|
|
indvdum@0
|
1560 |
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
|
|
indvdum@0
|
1561 |
SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "'
|
|
indvdum@0
|
1562 |
WHERE group_id = {$row['group_id']}";
|
|
indvdum@0
|
1563 |
$db->sql_query($sql);
|
|
indvdum@0
|
1564 |
}
|
|
indvdum@0
|
1565 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1566 |
|
|
indvdum@0
|
1567 |
$cache->destroy('_extensions');
|
|
indvdum@0
|
1568 |
|
|
indvdum@0
|
1569 |
$log_action = implode('_', array($log_action_posts, $log_action_forums));
|
|
indvdum@0
|
1570 |
|
|
indvdum@0
|
1571 |
switch ($log_action)
|
|
indvdum@0
|
1572 |
{
|
|
indvdum@0
|
1573 |
case 'MOVE_POSTS_MOVE_FORUMS':
|
|
indvdum@0
|
1574 |
add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS', $posts_to_name, $subforums_to_name, $forum_data['forum_name']);
|
|
indvdum@0
|
1575 |
break;
|
|
indvdum@0
|
1576 |
|
|
indvdum@0
|
1577 |
case 'MOVE_POSTS_FORUMS':
|
|
indvdum@0
|
1578 |
add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', $posts_to_name, $forum_data['forum_name']);
|
|
indvdum@0
|
1579 |
break;
|
|
indvdum@0
|
1580 |
|
|
indvdum@0
|
1581 |
case 'POSTS_MOVE_FORUMS':
|
|
indvdum@0
|
1582 |
add_log('admin', 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']);
|
|
indvdum@0
|
1583 |
break;
|
|
indvdum@0
|
1584 |
|
|
indvdum@0
|
1585 |
case '_MOVE_FORUMS':
|
|
indvdum@0
|
1586 |
add_log('admin', 'LOG_FORUM_DEL_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']);
|
|
indvdum@0
|
1587 |
break;
|
|
indvdum@0
|
1588 |
|
|
indvdum@0
|
1589 |
case 'MOVE_POSTS_':
|
|
indvdum@0
|
1590 |
add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS', $posts_to_name, $forum_data['forum_name']);
|
|
indvdum@0
|
1591 |
break;
|
|
indvdum@0
|
1592 |
|
|
indvdum@0
|
1593 |
case 'POSTS_FORUMS':
|
|
indvdum@0
|
1594 |
add_log('admin', 'LOG_FORUM_DEL_POSTS_FORUMS', $forum_data['forum_name']);
|
|
indvdum@0
|
1595 |
break;
|
|
indvdum@0
|
1596 |
|
|
indvdum@0
|
1597 |
case '_FORUMS':
|
|
indvdum@0
|
1598 |
add_log('admin', 'LOG_FORUM_DEL_FORUMS', $forum_data['forum_name']);
|
|
indvdum@0
|
1599 |
break;
|
|
indvdum@0
|
1600 |
|
|
indvdum@0
|
1601 |
case 'POSTS_':
|
|
indvdum@0
|
1602 |
add_log('admin', 'LOG_FORUM_DEL_POSTS', $forum_data['forum_name']);
|
|
indvdum@0
|
1603 |
break;
|
|
indvdum@0
|
1604 |
|
|
indvdum@0
|
1605 |
default:
|
|
indvdum@0
|
1606 |
add_log('admin', 'LOG_FORUM_DEL_FORUM', $forum_data['forum_name']);
|
|
indvdum@0
|
1607 |
break;
|
|
indvdum@0
|
1608 |
}
|
|
indvdum@0
|
1609 |
|
|
indvdum@0
|
1610 |
return $errors;
|
|
indvdum@0
|
1611 |
}
|
|
indvdum@0
|
1612 |
|
|
indvdum@0
|
1613 |
/**
|
|
indvdum@0
|
1614 |
* Delete forum content
|
|
indvdum@0
|
1615 |
*/
|
|
indvdum@0
|
1616 |
function delete_forum_content($forum_id)
|
|
indvdum@0
|
1617 |
{
|
|
indvdum@0
|
1618 |
global $db, $config, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
1619 |
|
|
indvdum@0
|
1620 |
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
|
indvdum@0
|
1621 |
|
|
indvdum@0
|
1622 |
$db->sql_transaction('begin');
|
|
indvdum@0
|
1623 |
|
|
indvdum@0
|
1624 |
// Select then delete all attachments
|
|
indvdum@0
|
1625 |
$sql = 'SELECT a.topic_id
|
|
indvdum@0
|
1626 |
FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a
|
|
indvdum@0
|
1627 |
WHERE p.forum_id = $forum_id
|
|
indvdum@0
|
1628 |
AND a.in_message = 0
|
|
indvdum@0
|
1629 |
AND a.topic_id = p.topic_id";
|
|
indvdum@0
|
1630 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1631 |
|
|
indvdum@0
|
1632 |
$topic_ids = array();
|
|
indvdum@0
|
1633 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1634 |
{
|
|
indvdum@0
|
1635 |
$topic_ids[] = $row['topic_id'];
|
|
indvdum@0
|
1636 |
}
|
|
indvdum@0
|
1637 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1638 |
|
|
indvdum@0
|
1639 |
delete_attachments('topic', $topic_ids, false);
|
|
indvdum@0
|
1640 |
|
|
indvdum@0
|
1641 |
// Delete shadow topics pointing to topics in this forum
|
|
indvdum@0
|
1642 |
delete_topic_shadows($forum_id);
|
|
indvdum@0
|
1643 |
|
|
indvdum@0
|
1644 |
// Before we remove anything we make sure we are able to adjust the post counts later. ;)
|
|
indvdum@0
|
1645 |
$sql = 'SELECT poster_id
|
|
indvdum@0
|
1646 |
FROM ' . POSTS_TABLE . '
|
|
indvdum@0
|
1647 |
WHERE forum_id = ' . $forum_id . '
|
|
indvdum@0
|
1648 |
AND post_postcount = 1
|
|
indvdum@0
|
1649 |
AND post_approved = 1';
|
|
indvdum@0
|
1650 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1651 |
|
|
indvdum@0
|
1652 |
$post_counts = array();
|
|
indvdum@0
|
1653 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1654 |
{
|
|
indvdum@0
|
1655 |
$post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1;
|
|
indvdum@0
|
1656 |
}
|
|
indvdum@0
|
1657 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1658 |
|
|
indvdum@0
|
1659 |
switch ($db->sql_layer)
|
|
indvdum@0
|
1660 |
{
|
|
indvdum@0
|
1661 |
case 'mysql4':
|
|
indvdum@0
|
1662 |
case 'mysqli':
|
|
indvdum@0
|
1663 |
|
|
indvdum@0
|
1664 |
// Delete everything else and thank MySQL for offering multi-table deletion
|
|
indvdum@0
|
1665 |
$tables_ary = array(
|
|
indvdum@0
|
1666 |
SEARCH_WORDMATCH_TABLE => 'post_id',
|
|
indvdum@0
|
1667 |
REPORTS_TABLE => 'post_id',
|
|
indvdum@0
|
1668 |
WARNINGS_TABLE => 'post_id',
|
|
indvdum@0
|
1669 |
BOOKMARKS_TABLE => 'topic_id',
|
|
indvdum@0
|
1670 |
TOPICS_WATCH_TABLE => 'topic_id',
|
|
indvdum@0
|
1671 |
TOPICS_POSTED_TABLE => 'topic_id',
|
|
indvdum@0
|
1672 |
POLL_OPTIONS_TABLE => 'topic_id',
|
|
indvdum@0
|
1673 |
POLL_VOTES_TABLE => 'topic_id',
|
|
indvdum@0
|
1674 |
);
|
|
indvdum@0
|
1675 |
|
|
indvdum@0
|
1676 |
$sql = 'DELETE ' . POSTS_TABLE;
|
|
indvdum@0
|
1677 |
$sql_using = "\nFROM " . POSTS_TABLE;
|
|
indvdum@0
|
1678 |
$sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = $forum_id\n";
|
|
indvdum@0
|
1679 |
|
|
indvdum@0
|
1680 |
foreach ($tables_ary as $table => $field)
|
|
indvdum@0
|
1681 |
{
|
|
indvdum@0
|
1682 |
$sql .= ", $table ";
|
|
indvdum@0
|
1683 |
$sql_using .= ", $table ";
|
|
indvdum@0
|
1684 |
$sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field";
|
|
indvdum@0
|
1685 |
}
|
|
indvdum@0
|
1686 |
|
|
indvdum@0
|
1687 |
$db->sql_query($sql . $sql_using . $sql_where);
|
|
indvdum@0
|
1688 |
|
|
indvdum@0
|
1689 |
break;
|
|
indvdum@0
|
1690 |
|
|
indvdum@0
|
1691 |
default:
|
|
indvdum@0
|
1692 |
|
|
indvdum@0
|
1693 |
// Delete everything else and curse your DB for not offering multi-table deletion
|
|
indvdum@0
|
1694 |
$tables_ary = array(
|
|
indvdum@0
|
1695 |
'post_id' => array(
|
|
indvdum@0
|
1696 |
SEARCH_WORDMATCH_TABLE,
|
|
indvdum@0
|
1697 |
REPORTS_TABLE,
|
|
indvdum@0
|
1698 |
WARNINGS_TABLE,
|
|
indvdum@0
|
1699 |
),
|
|
indvdum@0
|
1700 |
|
|
indvdum@0
|
1701 |
'topic_id' => array(
|
|
indvdum@0
|
1702 |
BOOKMARKS_TABLE,
|
|
indvdum@0
|
1703 |
TOPICS_WATCH_TABLE,
|
|
indvdum@0
|
1704 |
TOPICS_POSTED_TABLE,
|
|
indvdum@0
|
1705 |
POLL_OPTIONS_TABLE,
|
|
indvdum@0
|
1706 |
POLL_VOTES_TABLE,
|
|
indvdum@0
|
1707 |
)
|
|
indvdum@0
|
1708 |
);
|
|
indvdum@0
|
1709 |
|
|
indvdum@0
|
1710 |
// Amount of rows we select and delete in one iteration.
|
|
indvdum@0
|
1711 |
$batch_size = 500;
|
|
indvdum@0
|
1712 |
|
|
indvdum@0
|
1713 |
foreach ($tables_ary as $field => $tables)
|
|
indvdum@0
|
1714 |
{
|
|
indvdum@0
|
1715 |
$start = 0;
|
|
indvdum@0
|
1716 |
|
|
indvdum@0
|
1717 |
do
|
|
indvdum@0
|
1718 |
{
|
|
indvdum@0
|
1719 |
$sql = "SELECT $field
|
|
indvdum@0
|
1720 |
FROM " . POSTS_TABLE . '
|
|
indvdum@0
|
1721 |
WHERE forum_id = ' . $forum_id;
|
|
indvdum@0
|
1722 |
$result = $db->sql_query_limit($sql, $batch_size, $start);
|
|
indvdum@0
|
1723 |
|
|
indvdum@0
|
1724 |
$ids = array();
|
|
indvdum@0
|
1725 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1726 |
{
|
|
indvdum@0
|
1727 |
$ids[] = $row[$field];
|
|
indvdum@0
|
1728 |
}
|
|
indvdum@0
|
1729 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1730 |
|
|
indvdum@0
|
1731 |
if (sizeof($ids))
|
|
indvdum@0
|
1732 |
{
|
|
indvdum@0
|
1733 |
$start += sizeof($ids);
|
|
indvdum@0
|
1734 |
|
|
indvdum@0
|
1735 |
foreach ($tables as $table)
|
|
indvdum@0
|
1736 |
{
|
|
indvdum@0
|
1737 |
$db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids));
|
|
indvdum@0
|
1738 |
}
|
|
indvdum@0
|
1739 |
}
|
|
indvdum@0
|
1740 |
}
|
|
indvdum@0
|
1741 |
while (sizeof($ids) == $batch_size);
|
|
indvdum@0
|
1742 |
}
|
|
indvdum@0
|
1743 |
unset($ids);
|
|
indvdum@0
|
1744 |
|
|
indvdum@0
|
1745 |
break;
|
|
indvdum@0
|
1746 |
}
|
|
indvdum@0
|
1747 |
|
|
indvdum@0
|
1748 |
$table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE);
|
|
indvdum@0
|
1749 |
|
|
indvdum@0
|
1750 |
foreach ($table_ary as $table)
|
|
indvdum@0
|
1751 |
{
|
|
indvdum@0
|
1752 |
$db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id");
|
|
indvdum@0
|
1753 |
}
|
|
indvdum@0
|
1754 |
|
|
indvdum@0
|
1755 |
// Set forum ids to 0
|
|
indvdum@0
|
1756 |
$table_ary = array(DRAFTS_TABLE);
|
|
indvdum@0
|
1757 |
|
|
indvdum@0
|
1758 |
foreach ($table_ary as $table)
|
|
indvdum@0
|
1759 |
{
|
|
indvdum@0
|
1760 |
$db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id");
|
|
indvdum@0
|
1761 |
}
|
|
indvdum@0
|
1762 |
|
|
indvdum@0
|
1763 |
// Adjust users post counts
|
|
indvdum@0
|
1764 |
if (sizeof($post_counts))
|
|
indvdum@0
|
1765 |
{
|
|
indvdum@0
|
1766 |
foreach ($post_counts as $poster_id => $substract)
|
|
indvdum@0
|
1767 |
{
|
|
indvdum@0
|
1768 |
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
indvdum@0
|
1769 |
SET user_posts = 0
|
|
indvdum@0
|
1770 |
WHERE user_id = ' . $poster_id . '
|
|
indvdum@0
|
1771 |
AND user_posts < ' . $substract;
|
|
indvdum@0
|
1772 |
$db->sql_query($sql);
|
|
indvdum@0
|
1773 |
|
|
indvdum@0
|
1774 |
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
indvdum@0
|
1775 |
SET user_posts = user_posts - ' . $substract . '
|
|
indvdum@0
|
1776 |
WHERE user_id = ' . $poster_id . '
|
|
indvdum@0
|
1777 |
AND user_posts >= ' . $substract;
|
|
indvdum@0
|
1778 |
$db->sql_query($sql);
|
|
indvdum@0
|
1779 |
}
|
|
indvdum@0
|
1780 |
}
|
|
indvdum@0
|
1781 |
|
|
indvdum@0
|
1782 |
$db->sql_transaction('commit');
|
|
indvdum@0
|
1783 |
|
|
indvdum@0
|
1784 |
// Make sure the overall post/topic count is correct...
|
|
indvdum@0
|
1785 |
$sql = 'SELECT COUNT(post_id) AS stat
|
|
indvdum@0
|
1786 |
FROM ' . POSTS_TABLE . '
|
|
indvdum@0
|
1787 |
WHERE post_approved = 1';
|
|
indvdum@0
|
1788 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1789 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1790 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1791 |
|
|
indvdum@0
|
1792 |
set_config('num_posts', (int) $row['stat'], true);
|
|
indvdum@0
|
1793 |
|
|
indvdum@0
|
1794 |
$sql = 'SELECT COUNT(topic_id) AS stat
|
|
indvdum@0
|
1795 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
1796 |
WHERE topic_approved = 1';
|
|
indvdum@0
|
1797 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1798 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1799 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1800 |
|
|
indvdum@0
|
1801 |
set_config('num_topics', (int) $row['stat'], true);
|
|
indvdum@0
|
1802 |
|
|
indvdum@0
|
1803 |
$sql = 'SELECT COUNT(attach_id) as stat
|
|
indvdum@0
|
1804 |
FROM ' . ATTACHMENTS_TABLE;
|
|
indvdum@0
|
1805 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1806 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1807 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1808 |
|
|
indvdum@0
|
1809 |
set_config('num_files', (int) $row['stat'], true);
|
|
indvdum@0
|
1810 |
|
|
indvdum@0
|
1811 |
$sql = 'SELECT SUM(filesize) as stat
|
|
indvdum@0
|
1812 |
FROM ' . ATTACHMENTS_TABLE;
|
|
indvdum@0
|
1813 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1814 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1815 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1816 |
|
|
indvdum@0
|
1817 |
set_config('upload_dir_size', (float) $row['stat'], true);
|
|
indvdum@0
|
1818 |
|
|
indvdum@0
|
1819 |
return array();
|
|
indvdum@0
|
1820 |
}
|
|
indvdum@0
|
1821 |
|
|
indvdum@0
|
1822 |
/**
|
|
indvdum@0
|
1823 |
* Move forum position by $steps up/down
|
|
indvdum@0
|
1824 |
*/
|
|
indvdum@0
|
1825 |
function move_forum_by($forum_row, $action = 'move_up', $steps = 1)
|
|
indvdum@0
|
1826 |
{
|
|
indvdum@0
|
1827 |
global $db;
|
|
indvdum@0
|
1828 |
|
|
indvdum@0
|
1829 |
/**
|
|
indvdum@0
|
1830 |
* Fetch all the siblings between the module's current spot
|
|
indvdum@0
|
1831 |
* and where we want to move it to. If there are less than $steps
|
|
indvdum@0
|
1832 |
* siblings between the current spot and the target then the
|
|
indvdum@0
|
1833 |
* module will move as far as possible
|
|
indvdum@0
|
1834 |
*/
|
|
indvdum@0
|
1835 |
$sql = 'SELECT forum_id, forum_name, left_id, right_id
|
|
indvdum@0
|
1836 |
FROM ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1837 |
WHERE parent_id = {$forum_row['parent_id']}
|
|
indvdum@0
|
1838 |
AND " . (($action == 'move_up') ? "right_id < {$forum_row['right_id']} ORDER BY right_id DESC" : "left_id > {$forum_row['left_id']} ORDER BY left_id ASC");
|
|
indvdum@0
|
1839 |
$result = $db->sql_query_limit($sql, $steps);
|
|
indvdum@0
|
1840 |
|
|
indvdum@0
|
1841 |
$target = array();
|
|
indvdum@0
|
1842 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1843 |
{
|
|
indvdum@0
|
1844 |
$target = $row;
|
|
indvdum@0
|
1845 |
}
|
|
indvdum@0
|
1846 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1847 |
|
|
indvdum@0
|
1848 |
if (!sizeof($target))
|
|
indvdum@0
|
1849 |
{
|
|
indvdum@0
|
1850 |
// The forum is already on top or bottom
|
|
indvdum@0
|
1851 |
return false;
|
|
indvdum@0
|
1852 |
}
|
|
indvdum@0
|
1853 |
|
|
indvdum@0
|
1854 |
/**
|
|
indvdum@0
|
1855 |
* $left_id and $right_id define the scope of the nodes that are affected by the move.
|
|
indvdum@0
|
1856 |
* $diff_up and $diff_down are the values to substract or add to each node's left_id
|
|
indvdum@0
|
1857 |
* and right_id in order to move them up or down.
|
|
indvdum@0
|
1858 |
* $move_up_left and $move_up_right define the scope of the nodes that are moving
|
|
indvdum@0
|
1859 |
* up. Other nodes in the scope of ($left_id, $right_id) are considered to move down.
|
|
indvdum@0
|
1860 |
*/
|
|
indvdum@0
|
1861 |
if ($action == 'move_up')
|
|
indvdum@0
|
1862 |
{
|
|
indvdum@0
|
1863 |
$left_id = $target['left_id'];
|
|
indvdum@0
|
1864 |
$right_id = $forum_row['right_id'];
|
|
indvdum@0
|
1865 |
|
|
indvdum@0
|
1866 |
$diff_up = $forum_row['left_id'] - $target['left_id'];
|
|
indvdum@0
|
1867 |
$diff_down = $forum_row['right_id'] + 1 - $forum_row['left_id'];
|
|
indvdum@0
|
1868 |
|
|
indvdum@0
|
1869 |
$move_up_left = $forum_row['left_id'];
|
|
indvdum@0
|
1870 |
$move_up_right = $forum_row['right_id'];
|
|
indvdum@0
|
1871 |
}
|
|
indvdum@0
|
1872 |
else
|
|
indvdum@0
|
1873 |
{
|
|
indvdum@0
|
1874 |
$left_id = $forum_row['left_id'];
|
|
indvdum@0
|
1875 |
$right_id = $target['right_id'];
|
|
indvdum@0
|
1876 |
|
|
indvdum@0
|
1877 |
$diff_up = $forum_row['right_id'] + 1 - $forum_row['left_id'];
|
|
indvdum@0
|
1878 |
$diff_down = $target['right_id'] - $forum_row['right_id'];
|
|
indvdum@0
|
1879 |
|
|
indvdum@0
|
1880 |
$move_up_left = $forum_row['right_id'] + 1;
|
|
indvdum@0
|
1881 |
$move_up_right = $target['right_id'];
|
|
indvdum@0
|
1882 |
}
|
|
indvdum@0
|
1883 |
|
|
indvdum@0
|
1884 |
// Now do the dirty job
|
|
indvdum@0
|
1885 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
1886 |
SET left_id = left_id + CASE
|
|
indvdum@0
|
1887 |
WHEN left_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
|
|
indvdum@0
|
1888 |
ELSE {$diff_down}
|
|
indvdum@0
|
1889 |
END,
|
|
indvdum@0
|
1890 |
right_id = right_id + CASE
|
|
indvdum@0
|
1891 |
WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
|
|
indvdum@0
|
1892 |
ELSE {$diff_down}
|
|
indvdum@0
|
1893 |
END,
|
|
indvdum@0
|
1894 |
forum_parents = ''
|
|
indvdum@0
|
1895 |
WHERE
|
|
indvdum@0
|
1896 |
left_id BETWEEN {$left_id} AND {$right_id}
|
|
indvdum@0
|
1897 |
AND right_id BETWEEN {$left_id} AND {$right_id}";
|
|
indvdum@0
|
1898 |
$db->sql_query($sql);
|
|
indvdum@0
|
1899 |
|
|
indvdum@0
|
1900 |
return $target['forum_name'];
|
|
indvdum@0
|
1901 |
}
|
|
indvdum@0
|
1902 |
|
|
indvdum@0
|
1903 |
/**
|
|
indvdum@0
|
1904 |
* Display progress bar for syncinc forums
|
|
indvdum@0
|
1905 |
*/
|
|
indvdum@0
|
1906 |
function display_progress_bar($start, $total)
|
|
indvdum@0
|
1907 |
{
|
|
indvdum@0
|
1908 |
global $template, $user;
|
|
indvdum@0
|
1909 |
|
|
indvdum@0
|
1910 |
adm_page_header($user->lang['SYNC_IN_PROGRESS']);
|
|
indvdum@0
|
1911 |
|
|
indvdum@0
|
1912 |
$template->set_filenames(array(
|
|
indvdum@0
|
1913 |
'body' => 'progress_bar.html')
|
|
indvdum@0
|
1914 |
);
|
|
indvdum@0
|
1915 |
|
|
indvdum@0
|
1916 |
$template->assign_vars(array(
|
|
indvdum@0
|
1917 |
'L_PROGRESS' => $user->lang['SYNC_IN_PROGRESS'],
|
|
indvdum@0
|
1918 |
'L_PROGRESS_EXPLAIN' => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS'])
|
|
indvdum@0
|
1919 |
);
|
|
indvdum@0
|
1920 |
|
|
indvdum@0
|
1921 |
adm_page_footer();
|
|
indvdum@0
|
1922 |
}
|
|
indvdum@0
|
1923 |
|
|
indvdum@0
|
1924 |
/**
|
|
indvdum@0
|
1925 |
* Display copy permission page
|
|
indvdum@0
|
1926 |
* Not used at the moment - we will have a look at it for 3.0.7
|
|
indvdum@0
|
1927 |
*/
|
|
indvdum@0
|
1928 |
function copy_permission_page($forum_data)
|
|
indvdum@0
|
1929 |
{
|
|
indvdum@0
|
1930 |
global $phpEx, $phpbb_admin_path, $template, $user;
|
|
indvdum@0
|
1931 |
|
|
indvdum@0
|
1932 |
$acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id'];
|
|
indvdum@0
|
1933 |
$action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm");
|
|
indvdum@0
|
1934 |
|
|
indvdum@0
|
1935 |
$l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
|
|
indvdum@0
|
1936 |
|
|
indvdum@0
|
1937 |
$this->tpl_name = 'acp_forums_copy_perm';
|
|
indvdum@0
|
1938 |
|
|
indvdum@0
|
1939 |
$template->assign_vars(array(
|
|
indvdum@0
|
1940 |
'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url),
|
|
indvdum@0
|
1941 |
'L_ACL_LINK' => $l_acl,
|
|
indvdum@0
|
1942 |
'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id),
|
|
indvdum@0
|
1943 |
'S_COPY_ACTION' => $action,
|
|
indvdum@0
|
1944 |
'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false),
|
|
indvdum@0
|
1945 |
));
|
|
indvdum@0
|
1946 |
}
|
|
indvdum@0
|
1947 |
|
|
indvdum@0
|
1948 |
}
|
|
indvdum@0
|
1949 |
|
|
indvdum@0
|
1950 |
?> |