| 1 |
5330 |
acydburn |
<?php
|
| 2 |
7736 |
acydburn |
/**
|
| 3 |
5330 |
acydburn |
*
|
| 4 |
5330 |
acydburn |
* @package acp
|
| 5 |
5330 |
acydburn |
* @version $Id$
|
| 6 |
7736 |
acydburn |
* @copyright (c) 2005 phpBB Group
|
| 7 |
7736 |
acydburn |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
| 8 |
5330 |
acydburn |
*
|
| 9 |
5330 |
acydburn |
*/
|
| 10 |
5330 |
acydburn |
|
| 11 |
5330 |
acydburn |
/**
|
| 12 |
8147 |
acydburn |
* @ignore
|
| 13 |
8147 |
acydburn |
*/
|
| 14 |
8147 |
acydburn |
if (!defined('IN_PHPBB'))
|
| 15 |
8147 |
acydburn |
{
|
| 16 |
8147 |
acydburn |
exit;
|
| 17 |
8147 |
acydburn |
}
|
| 18 |
8147 |
acydburn |
|
| 19 |
8147 |
acydburn |
/**
|
| 20 |
5330 |
acydburn |
* @package acp
|
| 21 |
5330 |
acydburn |
*/
|
| 22 |
5330 |
acydburn |
class acp_forums
|
| 23 |
5330 |
acydburn |
{
|
| 24 |
5558 |
acydburn |
var $u_action;
|
| 25 |
5330 |
acydburn |
var $parent_id = 0;
|
| 26 |
6015 |
acydburn |
|
| 27 |
5330 |
acydburn |
function main($id, $mode)
|
| 28 |
5330 |
acydburn |
{
|
| 29 |
5643 |
acydburn |
global $db, $user, $auth, $template, $cache;
|
| 30 |
6015 |
acydburn |
global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;
|
| 31 |
5330 |
acydburn |
|
| 32 |
5330 |
acydburn |
$user->add_lang('acp/forums');
|
| 33 |
5330 |
acydburn |
$this->tpl_name = 'acp_forums';
|
| 34 |
5330 |
acydburn |
$this->page_title = 'ACP_MANAGE_FORUMS';
|
| 35 |
5330 |
acydburn |
|
| 36 |
8120 |
kellanved |
$form_key = 'acp_forums';
|
| 37 |
8120 |
kellanved |
add_form_key($form_key);
|
| 38 |
8120 |
kellanved |
|
| 39 |
5330 |
acydburn |
$action = request_var('action', '');
|
| 40 |
5330 |
acydburn |
$update = (isset($_POST['update'])) ? true : false;
|
| 41 |
5330 |
acydburn |
$forum_id = request_var('f', 0);
|
| 42 |
5330 |
acydburn |
|
| 43 |
5330 |
acydburn |
$this->parent_id = request_var('parent_id', 0);
|
| 44 |
5330 |
acydburn |
$forum_data = $errors = array();
|
| 45 |
8120 |
kellanved |
if ($update && !check_form_key($form_key))
|
| 46 |
8120 |
kellanved |
{
|
| 47 |
8120 |
kellanved |
$update = false;
|
| 48 |
8197 |
kellanved |
$errors[] = $user->lang['FORM_INVALID'];
|
| 49 |
8120 |
kellanved |
}
|
| 50 |
8120 |
kellanved |
|
| 51 |
5330 |
acydburn |
// Check additional permissions
|
| 52 |
5330 |
acydburn |
switch ($action)
|
| 53 |
5330 |
acydburn |
{
|
| 54 |
6419 |
acydburn |
case 'progress_bar':
|
| 55 |
6419 |
acydburn |
$start = request_var('start', 0);
|
| 56 |
6419 |
acydburn |
$total = request_var('total', 0);
|
| 57 |
6419 |
acydburn |
|
| 58 |
6419 |
acydburn |
$this->display_progress_bar($start, $total);
|
| 59 |
8655 |
acydburn |
exit;
|
| 60 |
6419 |
acydburn |
break;
|
| 61 |
6419 |
acydburn |
|
| 62 |
5330 |
acydburn |
case 'delete':
|
| 63 |
5330 |
acydburn |
|
| 64 |
5330 |
acydburn |
if (!$auth->acl_get('a_forumdel'))
|
| 65 |
5330 |
acydburn |
{
|
| 66 |
6320 |
acydburn |
trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
| 67 |
5330 |
acydburn |
}
|
| 68 |
5330 |
acydburn |
|
| 69 |
5330 |
acydburn |
break;
|
| 70 |
5330 |
acydburn |
|
| 71 |
5330 |
acydburn |
case 'add':
|
| 72 |
5330 |
acydburn |
|
| 73 |
5330 |
acydburn |
if (!$auth->acl_get('a_forumadd'))
|
| 74 |
5330 |
acydburn |
{
|
| 75 |
6320 |
acydburn |
trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
| 76 |
5330 |
acydburn |
}
|
| 77 |
8655 |
acydburn |
|
| 78 |
5330 |
acydburn |
break;
|
| 79 |
5330 |
acydburn |
}
|
| 80 |
5330 |
acydburn |
|
| 81 |
5330 |
acydburn |
// Major routines
|
| 82 |
5330 |
acydburn |
if ($update)
|
| 83 |
5330 |
acydburn |
{
|
| 84 |
5330 |
acydburn |
switch ($action)
|
| 85 |
5330 |
acydburn |
{
|
| 86 |
5330 |
acydburn |
case 'delete':
|
| 87 |
5330 |
acydburn |
$action_subforums = request_var('action_subforums', '');
|
| 88 |
5330 |
acydburn |
$subforums_to_id = request_var('subforums_to_id', 0);
|
| 89 |
5330 |
acydburn |
$action_posts = request_var('action_posts', '');
|
| 90 |
5330 |
acydburn |
$posts_to_id = request_var('posts_to_id', 0);
|
| 91 |
5330 |
acydburn |
|
| 92 |
5330 |
acydburn |
$errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id);
|
| 93 |
5330 |
acydburn |
|
| 94 |
5330 |
acydburn |
if (sizeof($errors))
|
| 95 |
5330 |
acydburn |
{
|
| 96 |
5330 |
acydburn |
break;
|
| 97 |
5330 |
acydburn |
}
|
| 98 |
5330 |
acydburn |
|
| 99 |
5330 |
acydburn |
$auth->acl_clear_prefetch();
|
| 100 |
5633 |
acydburn |
$cache->destroy('sql', FORUMS_TABLE);
|
| 101 |
5633 |
acydburn |
|
| 102 |
5330 |
acydburn |
trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id));
|
| 103 |
8655 |
acydburn |
|
| 104 |
5330 |
acydburn |
break;
|
| 105 |
5330 |
acydburn |
|
| 106 |
5330 |
acydburn |
case 'edit':
|
| 107 |
5330 |
acydburn |
$forum_data = array(
|
| 108 |
5330 |
acydburn |
'forum_id' => $forum_id
|
| 109 |
5330 |
acydburn |
);
|
| 110 |
5330 |
acydburn |
|
| 111 |
5995 |
acydburn |
// No break here
|
| 112 |
5330 |
acydburn |
|
| 113 |
5330 |
acydburn |
case 'add':
|
| 114 |
5330 |
acydburn |
|
| 115 |
5330 |
acydburn |
$forum_data += array(
|
| 116 |
5603 |
acydburn |
'parent_id' => request_var('forum_parent_id', $this->parent_id),
|
| 117 |
5330 |
acydburn |
'forum_type' => request_var('forum_type', FORUM_POST),
|
| 118 |
5330 |
acydburn |
'type_action' => request_var('type_action', ''),
|
| 119 |
5330 |
acydburn |
'forum_status' => request_var('forum_status', ITEM_UNLOCKED),
|
| 120 |
6524 |
davidmj |
'forum_parents' => '',
|
| 121 |
7920 |
acydburn |
'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)),
|
| 122 |
5330 |
acydburn |
'forum_link' => request_var('forum_link', ''),
|
| 123 |
5330 |
acydburn |
'forum_link_track' => request_var('forum_link_track', false),
|
| 124 |
7920 |
acydburn |
'forum_desc' => utf8_normalize_nfc(request_var('forum_desc', '', true)),
|
| 125 |
5709 |
acydburn |
'forum_desc_uid' => '',
|
| 126 |
6383 |
acydburn |
'forum_desc_options' => 7,
|
| 127 |
6239 |
davidmj |
'forum_desc_bitfield' => '',
|
| 128 |
7920 |
acydburn |
'forum_rules' => utf8_normalize_nfc(request_var('forum_rules', '', true)),
|
| 129 |
5709 |
acydburn |
'forum_rules_uid' => '',
|
| 130 |
6383 |
acydburn |
'forum_rules_options' => 7,
|
| 131 |
6209 |
davidmj |
'forum_rules_bitfield' => '',
|
| 132 |
5330 |
acydburn |
'forum_rules_link' => request_var('forum_rules_link', ''),
|
| 133 |
5330 |
acydburn |
'forum_image' => request_var('forum_image', ''),
|
| 134 |
5330 |
acydburn |
'forum_style' => request_var('forum_style', 0),
|
| 135 |
8374 |
naderman |
'display_subforum_list' => request_var('display_subforum_list', false),
|
| 136 |
5330 |
acydburn |
'display_on_index' => request_var('display_on_index', false),
|
| 137 |
8147 |
acydburn |
'forum_topics_per_page' => request_var('topics_per_page', 0),
|
| 138 |
8147 |
acydburn |
'enable_indexing' => request_var('enable_indexing', true),
|
| 139 |
5330 |
acydburn |
'enable_icons' => request_var('enable_icons', false),
|
| 140 |
5330 |
acydburn |
'enable_prune' => request_var('enable_prune', false),
|
| 141 |
6161 |
acydburn |
'enable_post_review' => request_var('enable_post_review', true),
|
| 142 |
5330 |
acydburn |
'prune_days' => request_var('prune_days', 7),
|
| 143 |
5330 |
acydburn |
'prune_viewed' => request_var('prune_viewed', 7),
|
| 144 |
5330 |
acydburn |
'prune_freq' => request_var('prune_freq', 1),
|
| 145 |
5330 |
acydburn |
'prune_old_polls' => request_var('prune_old_polls', false),
|
| 146 |
5330 |
acydburn |
'prune_announce' => request_var('prune_announce', false),
|
| 147 |
5330 |
acydburn |
'prune_sticky' => request_var('prune_sticky', false),
|
| 148 |
7581 |
acydburn |
'forum_password' => request_var('forum_password', '', true),
|
| 149 |
7581 |
acydburn |
'forum_password_confirm'=> request_var('forum_password_confirm', '', true),
|
| 150 |
8143 |
kellanved |
'forum_password_unset' => request_var('forum_password_unset', false),
|
| 151 |
5330 |
acydburn |
);
|
| 152 |
5330 |
acydburn |
|
| 153 |
6829 |
acydburn |
// Use link_display_on_index setting if forum type is link
|
| 154 |
6829 |
acydburn |
if ($forum_data['forum_type'] == FORUM_LINK)
|
| 155 |
6829 |
acydburn |
{
|
| 156 |
6829 |
acydburn |
$forum_data['display_on_index'] = request_var('link_display_on_index', false);
|
| 157 |
8898 |
acydburn |
}
|
| 158 |
7652 |
acydburn |
|
| 159 |
8898 |
acydburn |
// Linked forums and categories are not able to be locked...
|
| 160 |
8898 |
acydburn |
if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT)
|
| 161 |
8898 |
acydburn |
{
|
| 162 |
7652 |
acydburn |
$forum_data['forum_status'] = ITEM_UNLOCKED;
|
| 163 |
6829 |
acydburn |
}
|
| 164 |
6829 |
acydburn |
|
| 165 |
5330 |
acydburn |
$forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', false) : request_var('display_active', false);
|
| 166 |
5330 |
acydburn |
|
| 167 |
5709 |
acydburn |
// Get data for forum rules if specified...
|
| 168 |
5330 |
acydburn |
if ($forum_data['forum_rules'])
|
| 169 |
5330 |
acydburn |
{
|
| 170 |
6188 |
davidmj |
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));
|
| 171 |
5709 |
acydburn |
}
|
| 172 |
5330 |
acydburn |
|
| 173 |
5709 |
acydburn |
// Get data for forum description if specified
|
| 174 |
5709 |
acydburn |
if ($forum_data['forum_desc'])
|
| 175 |
5709 |
acydburn |
{
|
| 176 |
6188 |
davidmj |
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));
|
| 177 |
5330 |
acydburn |
}
|
| 178 |
5330 |
acydburn |
|
| 179 |
5330 |
acydburn |
$errors = $this->update_forum_data($forum_data);
|
| 180 |
6015 |
acydburn |
|
| 181 |
5330 |
acydburn |
if (!sizeof($errors))
|
| 182 |
5330 |
acydburn |
{
|
| 183 |
5574 |
acydburn |
$forum_perm_from = request_var('forum_perm_from', 0);
|
| 184 |
5574 |
acydburn |
|
| 185 |
5574 |
acydburn |
// Copy permissions?
|
| 186 |
8147 |
acydburn |
if ($forum_perm_from && !empty($forum_perm_from) && $forum_perm_from != $forum_data['forum_id'] &&
|
| 187 |
8170 |
kellanved |
(($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'))))
|
| 188 |
5574 |
acydburn |
{
|
| 189 |
6107 |
naderman |
// if we edit a forum delete current permissions first
|
| 190 |
6107 |
naderman |
if ($action == 'edit')
|
| 191 |
6107 |
naderman |
{
|
| 192 |
6107 |
naderman |
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
|
| 193 |
6107 |
naderman |
WHERE forum_id = ' . (int) $forum_data['forum_id'];
|
| 194 |
6107 |
naderman |
$db->sql_query($sql);
|
| 195 |
8655 |
acydburn |
|
| 196 |
6107 |
naderman |
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
|
| 197 |
6107 |
naderman |
WHERE forum_id = ' . (int) $forum_data['forum_id'];
|
| 198 |
6107 |
naderman |
$db->sql_query($sql);
|
| 199 |
6107 |
naderman |
}
|
| 200 |
6107 |
naderman |
|
| 201 |
5715 |
acydburn |
// From the mysql documentation:
|
| 202 |
5715 |
acydburn |
// Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
|
| 203 |
5715 |
acydburn |
// Due to this we stay on the safe side if we do the insertion "the manual way"
|
| 204 |
5574 |
acydburn |
|
| 205 |
5715 |
acydburn |
// Copy permisisons from/to the acl users table (only forum_id gets changed)
|
| 206 |
5715 |
acydburn |
$sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting
|
| 207 |
5715 |
acydburn |
FROM ' . ACL_USERS_TABLE . '
|
| 208 |
5715 |
acydburn |
WHERE forum_id = ' . $forum_perm_from;
|
| 209 |
5715 |
acydburn |
$result = $db->sql_query($sql);
|
| 210 |
5715 |
acydburn |
|
| 211 |
5715 |
acydburn |
$users_sql_ary = array();
|
| 212 |
5715 |
acydburn |
while ($row = $db->sql_fetchrow($result))
|
| 213 |
5715 |
acydburn |
{
|
| 214 |
5715 |
acydburn |
$users_sql_ary[] = array(
|
| 215 |
5715 |
acydburn |
'user_id' => (int) $row['user_id'],
|
| 216 |
5715 |
acydburn |
'forum_id' => (int) $forum_data['forum_id'],
|
| 217 |
5715 |
acydburn |
'auth_option_id' => (int) $row['auth_option_id'],
|
| 218 |
5715 |
acydburn |
'auth_role_id' => (int) $row['auth_role_id'],
|
| 219 |
5715 |
acydburn |
'auth_setting' => (int) $row['auth_setting']
|
| 220 |
5715 |
acydburn |
);
|
| 221 |
5715 |
acydburn |
}
|
| 222 |
5715 |
acydburn |
$db->sql_freeresult($result);
|
| 223 |
5715 |
acydburn |
|
| 224 |
5715 |
acydburn |
// Copy permisisons from/to the acl groups table (only forum_id gets changed)
|
| 225 |
5715 |
acydburn |
$sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting
|
| 226 |
5715 |
acydburn |
FROM ' . ACL_GROUPS_TABLE . '
|
| 227 |
5715 |
acydburn |
WHERE forum_id = ' . $forum_perm_from;
|
| 228 |
5715 |
acydburn |
$result = $db->sql_query($sql);
|
| 229 |
5715 |
acydburn |
|
| 230 |
5715 |
acydburn |
$groups_sql_ary = array();
|
| 231 |
5715 |
acydburn |
while ($row = $db->sql_fetchrow($result))
|
| 232 |
5715 |
acydburn |
{
|
| 233 |
5715 |
acydburn |
$groups_sql_ary[] = array(
|
| 234 |
5715 |
acydburn |
'group_id' => (int) $row['group_id'],
|
| 235 |
5715 |
acydburn |
'forum_id' => (int) $forum_data['forum_id'],
|
| 236 |
5715 |
acydburn |
'auth_option_id' => (int) $row['auth_option_id'],
|
| 237 |
5715 |
acydburn |
'auth_role_id' => (int) $row['auth_role_id'],
|
| 238 |
5715 |
acydburn |
'auth_setting' => (int) $row['auth_setting']
|
| 239 |
5715 |
acydburn |
);
|
| 240 |
5715 |
acydburn |
}
|
| 241 |
5715 |
acydburn |
$db->sql_freeresult($result);
|
| 242 |
5715 |
acydburn |
|
| 243 |
5715 |
acydburn |
// Now insert the data
|
| 244 |
6497 |
acydburn |
$db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary);
|
| 245 |
6497 |
acydburn |
$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
|
| 246 |
8253 |
kellanved |
cache_moderators();
|
| 247 |
5574 |
acydburn |
}
|
| 248 |
5574 |
acydburn |
|
| 249 |
5330 |
acydburn |
$auth->acl_clear_prefetch();
|
| 250 |
5633 |
acydburn |
$cache->destroy('sql', FORUMS_TABLE);
|
| 251 |
8655 |
acydburn |
|
| 252 |
6905 |
acydburn |
$acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id'];
|
| 253 |
5553 |
acydburn |
|
| 254 |
5330 |
acydburn |
$message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];
|
| 255 |
5330 |
acydburn |
|
| 256 |
6048 |
acydburn |
// Redirect to permissions
|
| 257 |
6048 |
acydburn |
if ($auth->acl_get('a_fauth'))
|
| 258 |
5709 |
acydburn |
{
|
| 259 |
6048 |
acydburn |
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
|
| 260 |
6048 |
acydburn |
}
|
| 261 |
6048 |
acydburn |
|
| 262 |
6048 |
acydburn |
// redirect directly to permission settings screen if authed
|
| 263 |
6048 |
acydburn |
if ($action == 'add' && !$forum_perm_from && $auth->acl_get('a_fauth'))
|
| 264 |
6048 |
acydburn |
{
|
| 265 |
6015 |
acydburn |
meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url));
|
| 266 |
5709 |
acydburn |
}
|
| 267 |
5709 |
acydburn |
|
| 268 |
5330 |
acydburn |
trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id));
|
| 269 |
5330 |
acydburn |
}
|
| 270 |
5330 |
acydburn |
|
| 271 |
5330 |
acydburn |
break;
|
| 272 |
5330 |
acydburn |
}
|
| 273 |
5330 |
acydburn |
}
|
| 274 |
5330 |
acydburn |
|
| 275 |
5330 |
acydburn |
switch ($action)
|
| 276 |
5330 |
acydburn |
{
|
| 277 |
5330 |
acydburn |
case 'move_up':
|
| 278 |
5330 |
acydburn |
case 'move_down':
|
| 279 |
6015 |
acydburn |
|
| 280 |
5330 |
acydburn |
if (!$forum_id)
|
| 281 |
5330 |
acydburn |
{
|
| 282 |
6320 |
acydburn |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
| 283 |
5330 |
acydburn |
}
|
| 284 |
6015 |
acydburn |
|
| 285 |
6073 |
acydburn |
$sql = 'SELECT *
|
| 286 |
5330 |
acydburn |
FROM ' . FORUMS_TABLE . "
|
| 287 |
5330 |
acydburn |
WHERE forum_id = $forum_id";
|
| 288 |
5330 |
acydburn |
$result = $db->sql_query($sql);
|
| 289 |
5330 |
acydburn |
$row = $db->sql_fetchrow($result);
|
| 290 |
5330 |
acydburn |
$db->sql_freeresult($result);
|
| 291 |
5330 |
acydburn |
|
| 292 |
5330 |
acydburn |
if (!$row)
|
| 293 |
5330 |
acydburn |
{
|
| 294 |
6320 |
acydburn |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
| 295 |
5330 |
acydburn |
}
|
| 296 |
5330 |
acydburn |
|
| 297 |
6073 |
acydburn |
$move_forum_name = $this->move_forum_by($row, $action, 1);
|
| 298 |
5330 |
acydburn |
|
| 299 |
6073 |
acydburn |
if ($move_forum_name !== false)
|
| 300 |
5330 |
acydburn |
{
|
| 301 |
6073 |
acydburn |
add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name);
|
| 302 |
6073 |
acydburn |
$cache->destroy('sql', FORUMS_TABLE);
|
| 303 |
5330 |
acydburn |
}
|
| 304 |
5330 |
acydburn |
|
| 305 |
5330 |
acydburn |
break;
|
| 306 |
5330 |
acydburn |
|
| 307 |
5330 |
acydburn |
case 'sync':
|
| 308 |
5330 |
acydburn |
if (!$forum_id)
|
| 309 |
5330 |
acydburn |
{
|
| 310 |
6320 |
acydburn |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
| 311 |
5330 |
acydburn |
}
|
| 312 |
5330 |
acydburn |
|
| 313 |
7517 |
acydburn |
@set_time_limit(0);
|
| 314 |
7517 |
acydburn |
|
| 315 |
7517 |
acydburn |
$sql = 'SELECT forum_name, forum_topics_real
|
| 316 |
5330 |
acydburn |
FROM ' . FORUMS_TABLE . "
|
| 317 |
5330 |
acydburn |
WHERE forum_id = $forum_id";
|
| 318 |
5330 |
acydburn |
$result = $db->sql_query($sql);
|
| 319 |
5330 |
acydburn |
$row = $db->sql_fetchrow($result);
|
| 320 |
5330 |
acydburn |
$db->sql_freeresult($result);
|
| 321 |
5330 |
acydburn |
|
| 322 |
5330 |
acydburn |
if (!$row)
|
| 323 |
5330 |
acydburn |
{
|
| 324 |
6320 |
acydburn |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
| 325 |
5330 |
acydburn |
}
|
| 326 |
5330 |
acydburn |
|
| 327 |
6419 |
acydburn |
if ($row['forum_topics_real'])
|
| 328 |
6419 |
acydburn |
{
|
| 329 |
7188 |
acydburn |
$sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id
|
| 330 |
7188 |
acydburn |
FROM ' . TOPICS_TABLE . '
|
| 331 |
7188 |
acydburn |
WHERE forum_id = ' . $forum_id;
|
| 332 |
7188 |
acydburn |
$result = $db->sql_query($sql);
|
| 333 |
7188 |
acydburn |
$row2 = $db->sql_fetchrow($result);
|
| 334 |
7188 |
acydburn |
$db->sql_freeresult($result);
|
| 335 |
6419 |
acydburn |
|
| 336 |
7517 |
acydburn |
// Typecast to int if there is no data available
|
| 337 |
7517 |
acydburn |
$row2['min_topic_id'] = (int) $row2['min_topic_id'];
|
| 338 |
7517 |
acydburn |
$row2['max_topic_id'] = (int) $row2['max_topic_id'];
|
| 339 |
7517 |
acydburn |
|
| 340 |
7188 |
acydburn |
$start = request_var('start', $row2['min_topic_id']);
|
| 341 |
7188 |
acydburn |
|
| 342 |
7456 |
acydburn |
$batch_size = 2000;
|
| 343 |
6419 |
acydburn |
$end = $start + $batch_size;
|
| 344 |
6419 |
acydburn |
|
| 345 |
6419 |
acydburn |
// Sync all topics in batch mode...
|
| 346 |
6419 |
acydburn |
sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false);
|
| 347 |
6419 |
acydburn |
sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true);
|
| 348 |
6419 |
acydburn |
|
| 349 |
7188 |
acydburn |
if ($end < $row2['max_topic_id'])
|
| 350 |
6419 |
acydburn |
{
|
| 351 |
7188 |
acydburn |
// We really need to find a way of showing statistics... no progress here
|
| 352 |
7188 |
acydburn |
$sql = 'SELECT COUNT(topic_id) as num_topics
|
| 353 |
7188 |
acydburn |
FROM ' . TOPICS_TABLE . '
|
| 354 |
7188 |
acydburn |
WHERE forum_id = ' . $forum_id . '
|
| 355 |
7188 |
acydburn |
AND topic_id BETWEEN ' . $start . ' AND ' . $end;
|
| 356 |
7188 |
acydburn |
$result = $db->sql_query($sql);
|
| 357 |
7188 |
acydburn |
$topics_done = request_var('topics_done', 0) + (int) $db->sql_fetchfield('num_topics');
|
| 358 |
7188 |
acydburn |
$db->sql_freeresult($result);
|
| 359 |
7188 |
acydburn |
|
| 360 |
6419 |
acydburn |
$start += $batch_size;
|
| 361 |
6419 |
acydburn |
|
| 362 |
7517 |
acydburn |
$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']}";
|
| 363 |
6419 |
acydburn |
|
| 364 |
6419 |
acydburn |
meta_refresh(0, $url);
|
| 365 |
6419 |
acydburn |
|
| 366 |
6419 |
acydburn |
$template->assign_vars(array(
|
| 367 |
7456 |
acydburn |
'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}",
|
| 368 |
8099 |
acydburn |
'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}"),
|
| 369 |
6419 |
acydburn |
'S_CONTINUE_SYNC' => true,
|
| 370 |
7188 |
acydburn |
'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['forum_topics_real']))
|
| 371 |
6419 |
acydburn |
);
|
| 372 |
6419 |
acydburn |
|
| 373 |
6419 |
acydburn |
return;
|
| 374 |
6419 |
acydburn |
}
|
| 375 |
6419 |
acydburn |
}
|
| 376 |
6419 |
acydburn |
|
| 377 |
7517 |
acydburn |
$url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_forum";
|
| 378 |
7517 |
acydburn |
meta_refresh(0, $url);
|
| 379 |
7517 |
acydburn |
|
| 380 |
7517 |
acydburn |
$template->assign_vars(array(
|
| 381 |
7517 |
acydburn |
'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar',
|
| 382 |
8099 |
acydburn |
'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'),
|
| 383 |
7517 |
acydburn |
'S_CONTINUE_SYNC' => true,
|
| 384 |
7517 |
acydburn |
'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['forum_topics_real']))
|
| 385 |
7517 |
acydburn |
);
|
| 386 |
7517 |
acydburn |
|
| 387 |
7517 |
acydburn |
return;
|
| 388 |
7517 |
acydburn |
|
| 389 |
7517 |
acydburn |
break;
|
| 390 |
7517 |
acydburn |
|
| 391 |
7517 |
acydburn |
case 'sync_forum':
|
| 392 |
7517 |
acydburn |
|
| 393 |
7517 |
acydburn |
$sql = 'SELECT forum_name, forum_type
|
| 394 |
7517 |
acydburn |
FROM ' . FORUMS_TABLE . "
|
| 395 |
7517 |
acydburn |
WHERE forum_id = $forum_id";
|
| 396 |
7517 |
acydburn |
$result = $db->sql_query($sql);
|
| 397 |
7517 |
acydburn |
$row = $db->sql_fetchrow($result);
|
| 398 |
7517 |
acydburn |
$db->sql_freeresult($result);
|
| 399 |
7517 |
acydburn |
|
| 400 |
7517 |
acydburn |
if (!$row)
|
| 401 |
7517 |
acydburn |
{
|
| 402 |
7517 |
acydburn |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
|
| 403 |
7517 |
acydburn |
}
|
| 404 |
7517 |
acydburn |
|
| 405 |
7517 |
acydburn |
sync('forum', 'forum_id', $forum_id, false, true);
|
| 406 |
7517 |
acydburn |
|
| 407 |
5330 |
acydburn |
add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']);
|
| 408 |
5633 |
acydburn |
$cache->destroy('sql', FORUMS_TABLE);
|
| 409 |
5330 |
acydburn |
|
| 410 |
5330 |
acydburn |
$template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name']));
|
| 411 |
5330 |
acydburn |
|
| 412 |
5330 |
acydburn |
break;
|
| 413 |
5330 |
acydburn |
|
| 414 |
5330 |
acydburn |
case 'add':
|
| 415 |
5330 |
acydburn |
case 'edit':
|
| 416 |
5330 |
acydburn |
|
| 417 |
5330 |
acydburn |
if ($update)
|
| 418 |
5330 |
acydburn |
{
|
| 419 |
6161 |
acydburn |
$forum_data['forum_flags'] = 0;
|
| 420 |
6365 |
acydburn |
$forum_data['forum_flags'] += (request_var('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0;
|
| 421 |
6365 |
acydburn |
$forum_data['forum_flags'] += (request_var('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0;
|
| 422 |
6365 |
acydburn |
$forum_data['forum_flags'] += (request_var('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
|
| 423 |
6365 |
acydburn |
$forum_data['forum_flags'] += (request_var('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0;
|
| 424 |
6365 |
acydburn |
$forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;
|
| 425 |
6365 |
acydburn |
$forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0;
|
| 426 |
5330 |
acydburn |
}
|
| 427 |
5330 |
acydbur |