diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index 9b203023d4..adcc5d18ef 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -283,8 +283,40 @@ + + + + +

{L_FORUM_ADMIN}

+ +

{L_FORUM_ADMIN_EXPLAIN}

+ +

{L_PROGRESS_EXPLAIN}

+ + +

{L_FORUM_ADMIN}

{L_FORUM_ADMIN_EXPLAIN}

@@ -297,12 +329,18 @@ + +

{L_NOTIFY}

{L_FORUM_RESYNCED}

- +

{NAVIGATION} [{L_EDIT} | {L_DELETE} | {L_RESYNC}]

@@ -320,20 +358,20 @@ {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN} + {ICON_MOVE_DOWN} {ICON_MOVE_UP} {ICON_MOVE_DOWN} - + {ICON_MOVE_UP} {ICON_MOVE_DOWN_DISABLED} {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN_DISABLED} - + {ICON_MOVE_DOWN_DISABLED} + {ICON_EDIT} - {ICON_SYNC} + {ICON_SYNC} {ICON_SYNC_DISABLED} @@ -368,4 +406,4 @@ - \ No newline at end of file + diff --git a/phpBB/adm/style/search_index_progress_bar.html b/phpBB/adm/style/progress_bar.html similarity index 100% rename from phpBB/adm/style/search_index_progress_bar.html rename to phpBB/adm/style/progress_bar.html diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 042f5c4e48..fe7f14b330 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -36,6 +36,14 @@ class acp_forums // Check additional permissions switch ($action) { + case 'progress_bar': + $start = request_var('start', 0); + $total = request_var('total', 0); + + $this->display_progress_bar($start, $total); + exit; + break; + case 'delete': if (!$auth->acl_get('a_forumdel')) @@ -308,7 +316,74 @@ class acp_forums trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } - sync('forum', 'forum_id', $forum_id); + sync('forum', 'forum_id', $forum_id, false, true); + $cache->destroy('sql', FORUMS_TABLE); + + $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_topic"; + meta_refresh(0, $url); + + $sql = 'SELECT forum_topics_real + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', + 'UA_PROGRESS_BAR' => str_replace('&', '&', $this->u_action) . '&action=progress_bar', + 'S_CONTINUE_SYNC' => true, + 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['forum_topics_real'])) + ); + +// add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); + + return; + + break; + + case 'sync_topic': + + @set_time_limit(0); + + $sql = 'SELECT forum_name, forum_topics_real + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row['forum_topics_real']) + { + $start = request_var('start', 0); + + $batch_size = 3000; + $end = $start + $batch_size; + + // Sync all topics in batch mode... + // topic_moved + sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); + sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); + + if ($end < $row['forum_topics_real']) + { + $start += $batch_size; + + $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_topic&start=$start&total={$row['forum_topics_real']}"; + + meta_refresh(0, $url); + + $template->assign_vars(array( + 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$start&total={$row['forum_topics_real']}", + 'UA_PROGRESS_BAR' => str_replace('&', '&', $this->u_action) . "&action=progress_bar&start=$start&total={$row['forum_topics_real']}", + 'S_CONTINUE_SYNC' => true, + 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $row['forum_topics_real'])) + ); + + return; + } + } + add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); $cache->destroy('sql', FORUMS_TABLE); @@ -634,7 +709,7 @@ class acp_forums // Jumpbox $forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id); - if ($action == 'sync') + if ($action == 'sync' || $action == 'sync_topic') { $template->assign_var('S_RESYNCED', true); } @@ -716,7 +791,10 @@ class acp_forums 'NAVIGATION' => $navigation, 'FORUM_BOX' => $forum_box, 'U_SEL_ACTION' => $this->u_action, - 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id) + 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id, + + 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', + 'UA_PROGRESS_BAR' => str_replace('&', '&', $this->u_action) . '&action=progress_bar') ); } @@ -1564,6 +1642,27 @@ class acp_forums return $target['forum_name']; } + + /** + * Display progress bar for syncinc forums + */ + function display_progress_bar($start, $total) + { + global $template, $user; + + adm_page_header($user->lang['SYNC_IN_PROGRESS']); + + $template->set_filenames(array( + 'body' => 'progress_bar.html') + ); + + $template->assign_vars(array( + 'L_PROGRESS' => $user->lang['SYNC_IN_PROGRESS'], + 'L_PROGRESS_EXPLAIN' => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS']) + ); + + adm_page_footer(); + } } ?> \ No newline at end of file diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 2ff1b778bb..ca6fab89db 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -441,7 +441,7 @@ class acp_search adm_page_header($user->lang[$l_type]); $template->set_filenames(array( - 'body' => 'search_index_progress_bar.html') + 'body' => 'progress_bar.html') ); $template->assign_vars(array( diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 7ce428a2b7..27e271dbb7 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1068,14 +1068,33 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, } else { - if (!sizeof($where_ids)) + if (!$where_type) { - return; + $where_sql = ''; + $where_sql_and = 'WHERE'; } + else if ($where_type == 'range') + { + // Only check a range of topics/forums. For instance: 'topic_id BETWEEN 1 AND 60' + $where_sql = 'WHERE (' . $mode{0} . ".$where_ids)"; + $where_sql_and = $where_sql . "\n\tAND"; + } + else + { + // Do not sync the "global forum" + $where_ids = array_diff($where_ids, array(0)); - // $where_type contains the field for the where clause (forum_id, topic_id) - $where_sql = 'WHERE ' . $db->sql_in_set($mode{0} . '.' . $where_type, $where_ids); - $where_sql_and = $where_sql . "\n\tAND"; + if (!sizeof($where_ids)) + { + // Empty array with IDs. This means that we don't have any work to do. Just return. + return; + } + + // Limit the topics/forums we are syncing, use specific topic/forum IDs. + // $where_type contains the field for the where clause (forum_id, topic_id) + $where_sql = 'WHERE ' . $db->sql_in_set($mode{0} . '.' . $where_type, $where_ids); + $where_sql_and = $where_sql . "\n\tAND"; + } } switch ($mode) @@ -1129,7 +1148,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $where_sql_and t.topic_first_post_id = p.post_id"; $db->sql_query($sql); break; - + default: $sql = 'SELECT t.topic_id, p.post_approved FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index fccefa0552..e241c1e83e 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -339,7 +339,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'TOPICS' => $row['forum_topics'], + 'TOPICS' => ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'], $l_post_click_count => $post_click_count, 'FORUM_FOLDER_IMG' => ($row['forum_image']) ? '' . $user->lang[$folder_alt] . '' : $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : $user->img($folder_image, $folder_alt, false, '', 'src'), diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index f173e001cf..8dce06c0c7 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -214,7 +214,7 @@ class template_compile // There will be a number of occassions where we switch into and out of // PHP mode instantaneously. Rather than "burden" the parser with this // we'll strip out such occurences, minimising such switching - $template_php = str_replace(' ?> 'Now you are able to %sset permissions%s for this forum.', + 'SYNC_IN_PROGRESS' => 'Synchronizing forum', + 'SYNC_IN_PROGRESS_EXPLAIN' => 'Currently resyncing topic range %1$d/%2$d.', + 'TYPE_CAT' => 'Category', 'TYPE_FORUM' => 'Forum', 'TYPE_LINK' => 'Link', diff --git a/phpBB/language/en/email/admin_activate.txt b/phpBB/language/en/email/admin_activate.txt index 04c8275491..a168ff533c 100644 --- a/phpBB/language/en/email/admin_activate.txt +++ b/phpBB/language/en/email/admin_activate.txt @@ -1,4 +1,4 @@ -Subject: New user account +Subject: Activate user account Hello,