diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cf611ca951..0d3e96f342 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -177,6 +177,69 @@ $database_update_info = database_update_info(); $error_ary = array(); $errored = false; +$sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; +$result = $db->sql_query_limit($sql, 1); +$has_global = (int) $db->sql_fetchfield('topic_id'); +$db->sql_freeresult($result); +$ga_forum_id = request_var('ga_forum_id', 0); + +if ($has_global && !$ga_forum_id) +{ + ?> + + + + + + + + + + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> + + + + + + +
+ + +
+
+
+ +
+
+ +

+ +
+ +
+ + + + +
+ @@ -1962,6 +2025,83 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $ga_forum_id = request_var('ga_forum_id', 0); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $db->sql_query($sql); + $lastpost = (int) $db->sql_fetchfield('forum_last_post_time'); + $db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + _sql($sql, $errored, $error_ary); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $db->sql_in_set('topic_id', $global_announcements); + _sql($sql, $errored, $error_ary); + } + unset($table_ary); + } + $no_updates = false; break; } diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 021f5eccb0..35fe28d8b5 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -323,6 +323,7 @@ $lang = array_merge($lang, array( 'SERVER_CONFIG' => 'Server configuration', 'SEARCH_INDEX_UNCONVERTED' => 'Search index was not converted', 'SEARCH_INDEX_UNCONVERTED_EXPLAIN' => 'Your old search index was not converted. Searching will always yield an empty result. To create a new search index go to the Administration Control Panel, select Maintenance and then choose Search index from the submenu.', + 'SELECT_FORUM_GA' => 'In phpBB 3.1 the global announcements are linked to forums. Select a forum for your current global announcements (can be moved later):', 'SOFTWARE' => 'Board software', 'SPECIFY_OPTIONS' => 'Specify conversion options', 'STAGE_ADMINISTRATOR' => 'Administrator details',